How to get find() results as a matrix?
이전 댓글 표시
Hi,
I have a binary image that was obtained from a color image (both were attached here). The background of the segmented image is black and the main object is white. I'm trying to use that binary image to get only the main object of the color image by using find() function.
I was able to do it using the following code:
I = imread(<binaryImage>);
I2 = imread(<color image>);
IMNONZERO = find(I); % this code returns only indexes of non-zero values
I3 = I2(IMNONZERO); % this gets all indexes of IMNONZERO in the I2 color image
imshow(I3);
This is my question: I saw that find() returns linear indexes. Also, I tried [row, col] = find(I) and it brings me the indexes of non-zero values as 2 separated arrays (one for row and another for column). However, I would like to know if it's possible to obtain those indexes as a regular matrix.
Is it possible?
Thank you in advance,
Queila
채택된 답변
추가 답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!