I have a image of two circles which are partially occulded. I have to label them as two different label. is there any way to label them differently? I am adding some more images. Images have some regular & non-regular shapes.

조회 수: 1 (최근 30일)
>>
>>
  댓글 수: 2
poonam
poonam 2016년 1월 1일
Hi harjeet, I am adding some more images. My Images have some regular and some non-regular shapes. regular shapes include perfect circle and distorted at the borders. non regular shape are toching to the regular shapes.
>>
>>

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

채택된 답변

Image Analyst
Image Analyst 2015년 12월 28일
poonam, did you see the example in the help for the watershed function? This is exactly the help demo - two overlapping circles, separating and labeling them. Just follow the code in the help example.
  댓글 수: 3
poonam
poonam 2016년 1월 3일
Yes sir, I learned about that function. and it worked very well for all my images. And I think my revision of question was unnecessary. Thank you.

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

추가 답변 (1개)

harjeet singh
harjeet singh 2015년 12월 28일
hello poonam do use this code
clear all
close all
clc
img=imread('rgbCattach.png');
img=rgb2gray(img);
figure(1)
imshow(img)
drawnow
img=logical(img);
[centers, radii, metric] = imfindcircles(img,[30 100]);
img_labeled(1:size(img,1),1:size(img,2))=0;
for i=1:size(centers,1)
for j=1:size(img,1)
for k=1:size(img,2)
d=sqrt( (j-centers(i,2)).^2 + (k-centers(i,1)).^2);
if(d<=radii(i))
img_labeled(j,k)=i;
end
end
end
end
figure(2)
imshow(img_labeled)
drawnow
  댓글 수: 6
harjeet singh
harjeet singh 2016년 1월 1일
hello poonam as @image analyst told you to use watersed function, that's the best in your case use this code
clear all
close all
warning off
clc
img=imread('s4.png');
img=logical(img(:,:,1));
figure(1)
imshow(img)
drawnow
D = bwdist(~img);
D = -D;
D(~D) = -Inf;
figure(2)
imshow(D,[],'InitialMagnification','fit')
title('Distance transform of ~bw')
L = double(watershed(D));
rgb = label2rgb(L,'jet',[.5 .5 .5]);
figure(3)
imshow(rgb,'InitialMagnification','fit')
title('Watershed transform of D')
L(L==1)=0;
figure(4)
subplot(1,2,1)
imshow(L)
title('bw labeled image')
subplot(1,2,2)
imshow(rgb)
title('jet image')
poonam
poonam 2016년 1월 3일
Thank you harjeet, 'watershed' function suggested by @Image Analysis worked perfectly well in my problem. Now I can extract these object individual.

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

Community Treasure Hunt

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

Start Hunting!

Translated by