Selecting multiple ROI in images for processing

I would like to select multiple rectangular regions in an image and would like to plot the selected 2D region's as 1D plots.How can I do this in matlab. Also is there a easy way to use the same ROI on multiple images.

2 个评论

When you say you want to plot the regions as a 1D plot, are you trying to plot the intensity profile along the polyline that defines the border of the ROI?
If so, do the images all share the same geometry?
hello,
How can we use matlab to transform an image into short lines in the length of micrometers,
all short lines will represent the grayscale, or maybe the lightness of the image,
after we get the short lines file, we will use it for etching out textures.
Thank you.
Mikko

请先登录,再进行评论。

 采纳的回答

7 个评论

Thank you image analyst. Is there a function to draw a polygon instead of lines as in the demo ?
There is a drawpolygon function demo but it's on my other computer, not this one. If I remember I'll post it tomorrow.
OK, I've uploaded all my roi drawing demos and attached them to my original answer.
@Image Analyst Hello! i used your code of drawpoint_demo.m and drawrectangle_demo.m.
but i am getting this error. Please can you help me resolve it. Thank You.
@Muhammad Mubeen Tariq what versiojn of MATLAB do you have?
drawpoint was introduced in R2018b.
>> which -all drawpoint
C:\Program Files\MATLAB\R2022b\toolbox\images\imuitools\drawpoint.m
Note that drawpoint(), drawpolygon(), etc all require Image Processing Toolbox. Otherwise, if you have IPT, but are running something older than R2018b, there may be other options. If that's the case, you'll have to describe your needs.
@Image Analyst Hello Sir! Thank you so much for replying. Basically, there is picture of bubble sheet (like used in exams) which contains about 10 to 20 MCQs based bubble options. Each option has 4 bubbles, one bubble filled and other 3 are empty. I need any method or code by which i can pick only filled bubbles from picture because i have to apply ink mismatch on those bubbles to detect ink forgery. If i use your codes provided above, i have to manually select those filled bubbles and it would be very difficult to select ROI on 10 to 20 bubbles. Please can you help me little bit, i would be very thankful to you. If you have any mail or social media where i can contact you and could explain the whole scenario in detail. Hoping for positive response.

请先登录,再进行评论。

更多回答(2 个)

yes,sir,may be use roipoly to make shape,such as
im = imread('cameraman.tif');
figure; imshow(im); hold on;
pts = [];
while 1
[bw,xi,yi] = roipoly(im);
hold on;
pts{end+1} = [xi(:) yi(:)];
plot(xi(:), yi(:), 'r-');
tm = [];
for i = 1 : length(xi)-1
tm=[tm; xi(i) yi(i) xi(i+1) yi(i+1)];
end
im=insertShape(im,'Line',tm,'Color','r','LineWidth',1);
choice = questdlg('break?', ...
'break', ...
'Yes','No','No');
switch choice
case 'Yes'
break;
case 'No'
continue;
end
end
when we run,we can get

产品

版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by