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:
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.