how to create logical image from plot in a given scale?

5 ビュー (過去 30 日間)
Osama Tabbakh
Osama Tabbakh 2019 年 2 月 23 日
コメント済み: Osama Tabbakh 2019 年 2 月 27 日
I want to transform two vectors (x, y) that describe a straight line in the domain (axis([1e-2 7e-2 1e-2 7e-2])) into a logical matrix.
x = linspace (2e-2,6e-2,20);
y = 4e-2 * ones (1,20);
a = [x' y'];
plot (x,y);
axis([1e-2 7e-2 1e-2 7e-2])
I want to get 100*100 matrix, which describe this plot. For that I can creat zeros matrix and then I have to put the ones in the correct place in this matrix. But I don't know where are the correct places.
  2 件のコメント
Image Analyst
Image Analyst 2019 年 2 月 23 日
It would just be a line since your y values are all the same:
logImage = true(1, length(y));
imshow(logImage);
Do you have some kind of formula for y?
Osama Tabbakh
Osama Tabbakh 2019 年 2 月 23 日
No, y has contant number, because it is a line. But in this way I get a vector. Besides I need a matrix, which hasn't the same size like the vectors, but (100*100).

サインインしてコメントする。

採用された回答

Munish Raj
Munish Raj 2019 年 2 月 27 日
Since the line is in the middle of your plot, the row indices of the plot will be the 50th row(middle).
Since the line goes from 0.02 - 0.06 and the axes start from 0.01 and ends at 0.07, your line will start in the 17th position and end at the 83rd position on the x axis.
The following code implements this
im = zeros(100); %Create a 100x100 matrix of zeros
im(50,17:83)=1 % make the necessary elements
I = mat2gray(im);
imshow(I); %Displays the image
  4 件のコメント
Munish Raj
Munish Raj 2019 年 2 月 27 日
編集済み: Munish Raj 2019 年 2 月 27 日
Hello
use your mouse , and drag the corner of the image window to youmake the image as big as tou want it.
Thank you
Osama Tabbakh
Osama Tabbakh 2019 年 2 月 27 日
And do u know how i can do that automatically? I have different shape of lines and i dont want every time to calculate the position of the ones on hand.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by