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

3 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Parth Dethaliya
Parth Dethaliya el 24 de Dic. de 2020
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)

Más respuestas (0)

Categorías

Más información sobre Images en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by