Divide an image using just 2 pixel locations
2 views (last 30 days)
Show older comments
Hi, I want to be able to iteratively divide input images into 2 regions with a line formed from 2 input 'cut points'. I was thinking of looking for where this line crossed the image domain boundaries (1200X1600 pixels). Depending on the slope of the line (which we will not know in advance, since we do not know the 'cut points' in advance), I will have a 3-sided or a 4-sided polygon. Then I create a mask using the (ROI-based) poly2mask function.
Would there be a quicker way to do it?
Thanks! Greg
0 Comments
Answers (3)
Image Analyst
on 2 Oct 2013
An image has to be rectangular. What is your line slants across your image at an angle? What then? Do you want two sub images extracted using the bounding box of the quadrilateral? Or do you simply want two binary images, at the full original image resolution that map out where the two regions are? Please explain in much, much more detail what form you want the output image(s) to take on.
1 Comment
Image Analyst
on 2 Oct 2013
Responding to Gregory's "Answer" below (which should have been a "comment" here):
There is no built-in function that will take a line segment with two endpoints in the image, then extend the line segment to the edges of the image, then give you two binary images out, one representing the left half and one representing the right half. That's just too specialized. You can easily do it in a few lines, and I guess you've already done that.
Gregory
on 2 Oct 2013
1 Comment
Image Analyst
on 3 Oct 2013
If we're done with this question then mark my answer (not yours) as "Accepted" - thanks.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!