MATLAB Answers

Introducing a border/outline to objects in an image.

조회 수: 63(최근 30일)
Sid
Sid 27 Jan 2012
Hi everyone,
I have a question about how to introduce an outline to a mask. Please check the original source image at: http://i39.tinypic.com/ap78s9.jpg. I would like the borders of the various objects in the mask to be outlined and each object identified as shown in: http://i39.tinypic.com/e839yt.jpg, both with an outline and an index number (so that the index number could be used to identify, and cross-refer the results generated by regionprops). This specific example was generated using ImageJ.
Any help would be much appreciated.
Thanks and have a good weekend.

  댓글 수: 0

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

채택된 답변

Chandra Kurniawan
Chandra Kurniawan 27 Jan 2012
Irgb = imread('ap78s9.jpg');
Igray = rgb2gray(Irgb);
Ibw = im2bw(Igray,graythresh(Igray));
Ifill = imfill(Ibw,'holes');
B = bwboundaries(Ifill);
stat = regionprops(Ifill,'Centroid');
imshow(~Ibw); hold on
for k = 1 : length(B)
b = B{k};
c = stat(k).Centroid;
plot(b(:,2),b(:,1),'g','linewidth',2);
text(c(1),c(2),num2str(k),'backgroundcolor','g');
end

  댓글 수: 0

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

추가 답변(1개)

Sean de Wolski
Sean de Wolski 27 Jan 2012
I would guess one of these will be your friend:
doc bwperim
doc bwboundaries
doc bwtraceboundary

  댓글 수: 0

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

Community Treasure Hunt

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

Start Hunting!

Translated by