フィルターのクリア

how can I find whether the x and y values ​​are within an image ?

4 ビュー (過去 30 日間)
busra dogru
busra dogru 2019 年 4 月 12 日
コメント済み: Walter Roberson 2019 年 4 月 13 日
Hello to everyone. I have binary pictures and x y coordinate values. I want to check if these points are in the picture. How can I do this using the loop ?
Thanks in advance ...

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 4 月 12 日
margin = 0.5;
in_image = x >= margin & x <= size(YourImage,2) + margin & y >= margin & y <= size(YourImage,1) + margin;
The margin is there to account for pixel width. When you position an image at (1,1) on one side and (maxcolumn,maxrow) on the other, then those are the coordinates of pixel centers so down to (0.5,0.5) and up to (maxcolumn+0.5,maxrow+0.5) is still "within" the image.
  2 件のコメント
busra dogru
busra dogru 2019 年 4 月 12 日
Firstly, thanks for your response. Actually I want to check if x and y values ​​are inside a letter written in white on top of the black background. That is, if the values ​​are in the white part. There are no spaces in my pictures. How do you think I can do that?
Walter Roberson
Walter Roberson 2019 年 4 月 13 日
margin = 0.5;
in_image = x >= margin & x < size(YourImage,2) + margin & y >= margin & y < size(YourImage,1) + margin;
ind = sub2ind(size(YourImage), round(y(in_image)), round(x(in_image)) );
is_white = false(size(in_image));
is_white(ind) = YourImage(ind) == 1;

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by