creat mask from random border lines for time frame cropping

Hi all,
I want to crop the maximum rectangle area in image 'frame' as the red rec. in image 'frame1'. I am looking to have a mask from this image for another images, means I am looking for coordinates of the red frame. The red frame has to keep the original image x, y ratio.
Thanks, HM

Answers (1)

This is not that well defined. What if you have a hairline black line meandering from the upper left corner down into the lower right quadrant? What would be the inner bounding box then? Why does the mask need to be a perfect rectangle anyway? Maybe you can just use what you got and call imclose() or bwconvhull(), and then shrink it a few layers by calling imerode().

4 Comments

The image is an output of maximum image projection of time frames. Therefore, no hairline in the middle of the image. The black lines in the attached image are the alignment boundaries of the stacked time frames and I want to cut them out and use the remaining (mask) corrdinates in order to cut all the gray images that I have to present, so the mask have to be rectangle shap. I tried divid the image to 4 and ask distances from the center of the original image. No success besause of the black line on the left that covers all y values! Thanks,
I don't think you're envisioning all the possibilities for a robust solution. Unlike the outer bounding box, there are many, many possible inner bounding boxes, even if you require that it encompass the centroid. So how do you pick one? Just think about it some - think up lots of possible different boundary shapes - and you'll realize what I'm saying.
The image that I sent is the final version in terms of additional noise (black lines) that can be in the image. Suggestion for a solution: If I take a frame on the outer borders of the image and start a while loop shrinking this frame 1px each loop from all directions until no black lines (dots in this case) touches the frame. At the end I will get one solution. What do you think? Could you please help me to write such code? Thanks, HM
hi follow this link https://www.mathworks.com/help/images/examples/detecting-a-cell-using-image-segmentation.html

Sign in to comment.

Asked:

on 11 Oct 2015

Commented:

on 3 Oct 2017

Community Treasure Hunt

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

Start Hunting!