Hi, I am using Matlab version 7.9.0(R2009b). I need to select a rectangular region of interest for my tif image. I tried imrect but the rectangular appeared on an empty coordinat system, not in my tif image. Could you please help me on this?
1 view (last 30 days)
Show older comments
mathworks
9 Comments
Image Analyst
on 29 May 2013
Lisa, please put your comments after my answer. Then I'll continue the discussion.
Accepted Answer
Image Analyst
on 28 May 2013
Edited: Image Analyst
on 29 May 2013
Try this:
txtInfo = sprintf('Draw a box over the image by clicking and dragging over the image.\nDouble click inside the box to finish drawing.');
text(10, 40, txtInfo, 'color', 'r', 'FontSize', 24);
% Prompt user to draw a region on the image.
msgboxw(txtInfo);
hBox = imrect;
roiPosition = wait(hBox);
roiPosition % Echo coordinates to the command window.
% Erase all previous lines.
if ~enlargeForDrawing
axes(handleToImage);
% ClearLinesFromAxes(handles);
end
xCoords = [roiPosition(1), roiPosition(1)+roiPosition(3), roiPosition(1)+roiPosition(3), roiPosition(1), roiPosition(1)];
yCoords = [roiPosition(2), roiPosition(2), roiPosition(2)+roiPosition(4), roiPosition(2)+roiPosition(4), roiPosition(2)];
% Plot the mask as an outline over the image.
hold on;
plot(xCoords, yCoords, 'linewidth', 2);
6 Comments
Image Analyst
on 2 Jun 2013
After you get each profile, plot it:
hold on;
plot(horizontalProfile);
Don't use 'r-' or else all plots will be in red and you won't be able to tell them apart.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!