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

조회 수: 6 (최근 30일)
Ankit Sahay 2020년 10월 5일
댓글: Ankit Sahay 2021년 1월 4일
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 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)
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Ankit Sahay 2021년 1월 4일
Yup. That worked. Thanks a lot!

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Image Arithmetic에 대해 자세히 알아보기

R2019a

### Community Treasure Hunt

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

Start Hunting!

Translated by