save only specefic connected components
이전 댓글 표시
Hi, From a gray image , I extract all the connected components using bwconcomp, Then I work on each connected component. I want to draw in a new image with the size of the originam image some specefic connected components. I saw many works based on the area , the biggest component ... but for me I have new parameter that will filter the cinnected components, How can I draw in a new image with the original image size a specific connected component in its original place?? Thank you :)
답변 (1개)
Image Analyst
2017년 3월 1일
편집: Image Analyst
2017년 3월 1일
You can extract any component from your labeled image into a new binary image using ismember:
binaryImage = ismember(labeledImage, index);
This will get only one blob - the one that was labeled with a number of "index".
If you want to mask the image with that blob and get a gray scale image then do this:
maskedImage = grayImage; % Initialize
maskedImage(~binaryImage) = 0; % Do the masking.
댓글 수: 7
Flore Massoulié
2017년 3월 1일
편집: Flore Massoulié
2017년 3월 1일
Flore Massoulié
2017년 3월 1일
Image Analyst
2017년 3월 1일
index can be an array of indexes if you want to extract several components.
Flore Massoulié
2017년 3월 1일
Image Analyst
2017년 3월 1일
Is "F(i).Image" a scalar integer that contains the ID label of the blob you want to extract? If so, then yes, that should work.
Flore Massoulié
2017년 3월 2일
Image Analyst
2017년 3월 2일
Since you already have the image of the connected component, you can just use it as a mask on the original image:
If you want to mask the image with that blob and get a gray scale image then do this:
maskedImage = grayImage; % Initialize
mask = F(i).Image > 0; % Convert "the image of the connected component" into a logical mask.
maskedImage(~mask) = 0; % Do the masking.
카테고리
도움말 센터 및 File Exchange에서 Region and Image Properties에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!