Clear Filters
Clear Filters

How to let the user choose where to process on an image?

4 views (last 30 days)
Hello everybody,
I want to create a GUI which lets the user choose on an image where the area of interest is. So I want a picture to come up on the GUI, and then the user can click four points on the image indicating the four corners of a piece of paper (area of interest)? Then my programme could record these four sets of coordinates and use then to then start the image processing? Is there a way to do this? I really can't find a way looking online.
Many thanks, Ellis

Answers (2)

Walter Roberson
Walter Roberson on 16 May 2016

Image Analyst
Image Analyst on 16 May 2016
Try imrect() or rbbox() if the edges of your ROI align with the edges of the image. If they don't, use impoly() or roipoly() or roipolyold(). Then you'll have the vertex coordinates. Then use poly2mask() to make a mask. After that, use the mask to restrict processing some way. For example, maybe you could use the mask to blacken everywhere outside the mask:
mask = poly2mask(xVector, yVector, numRows, numColumns);
maskedImage = grayImage; % Initialize
maskedImage(~mask) = 0; % Blacken outside mask.

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!