Hello, i do have some points (which i know the coordinates) of a greyscale image and i used them to generate a polygon (using boundary function since they are not connected in some regions) so i have an area closed.
Now i want to extract all the info thats outside that region, (everything inside 1, outside 0) so i have a binary image.
I guess the easiest form is to generate a ROI and create a mask trough that ROI, but I see no way to do it automatically ( I dont want to click on the points of my poligon, its not an accurate procedure and it takes too much time).
Anyone has any idea of how to proceed?
Thanks

 採用された回答

Subhadeep Koley
Subhadeep Koley 2020 年 2 月 1 日

1 投票

I am assuming you are trying to create Polygonal ROI Non-interactively. The code below might help!
% Read the image into the workspace
I = imread('cameraman.tif');
% Display the image
imshow(I, []);
% Draw a Point ROI on the image with specified points
roi = images.roi.Polygon(gca, 'Position', [115 30; 80 45; 80 80; 115 90; 145 65]);
ROINI.PNG

4 件のコメント

JoaquinB
JoaquinB 2020 年 2 月 3 日
Hello, what about if i have a really big number of points?
Can i....
roi = images.roi.Polygon(gca, 'Position', [PIX_pos]);
Where Pix_pos is an array (1000x2) for example:
X Y
200 300
400 600
etc etc
or do i need to automatise it like:
roi = images.roi.Polygon(gca, 'Position', [PIX_pos(1,1) PIX_pos(1,2);PIX_pos(2,1) PIX_pos(2,2); etc etc;]);
Thanks
Subhadeep Koley
Subhadeep Koley 2020 年 2 月 3 日
You can specify point values like below also.
% Read the image into the workspace
I = imread('cameraman.tif');
% Display the image
imshow(I, []);
% Specify the points
pointVals = [115 30; 80 45; 80 80; 115 90; 145 65]; % Here "pointVals" is a (5x2) vector
% Draw a Point ROI on the image with specified points
roi = images.roi.Polygon(gca, 'Position', pointVals);
Hope this helps!
JoaquinB
JoaquinB 2020 年 2 月 3 日
編集済み: JoaquinB 2020 年 2 月 3 日
Yea, that was obvious, forgot the Matlab notation.
Thanks a lot Subhadeep!
Subhadeep Koley
Subhadeep Koley 2020 年 2 月 3 日
No problem!

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by