Split a binary image into 2 parts by specifying the separation point

4 次查看(过去 30 天)
Hi all!
Unfortunately, I had not formulated my earlier question properly, for which I am extremely sorry. I am starting a new question as I have reformulated my problem.
I have a binary image attached:
The corresponding .mat file is also attached.
I want to separate the binary image into 2 parts, with the separation point being the cell having cell value 1 in the top-most row (of the cells having 1 as their cell value). For example, for the above image, I would like to get the following 2 images:
and
The separation point is at [X Y] = [342 60]. Row 60 is the top most row which has cells with cell value 1. Column 342 is the last column on this particular row which has cell value 1. I hope I am satisfactorily able to define the separation point.
Unlike my previous question, I have made sure that there is only one 8-connectivity component. This can be verified by using the command:
cc = bwconncomp(binary_image1,8)
If there are more than one cell having value 1 on the top-most row (of the cells having 1 as their cell value), we can select either the first or the last cells having 1 in that particular row as the separation point. I would love if there is an option to change between the first or last cells, but this is a very important requirement. In that case, we can select the last cell as the separation point, as done in the figures attached above.
I tried the answers given for my previous question, they don't work. I think its obvious, as my question was ill-formulated. I hope this new question can help me.
Please let me know if I can clarify anything else. Thank you.

采纳的回答

Parth Dethaliya
Parth Dethaliya 2020-12-24
A simple solution to what you have asked could be setting the value of seperation point to 0 then finding connected components again, Now there will be two components because you have broked the connectivity.
Comment here for further clarification if i am not clear.
You can find the top most row containing 1 by,
[r,c] = find(B==1);
min(r)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by