listing masked point in an image after image segmentation
조회 수: 1 (최근 30일)
이전 댓글 표시
hi, I'm searching for a method to list a number of points/circles in an image after using the image segmentation app in matlab. So I attached 2 images to make clear what I mean. First picture shows an example of the resutls from the segmentation and second picture shows how I want to detect the several circles. I have for example 6 circles detected with the image segmentation and now I want to give every circle somekind of identity like a specific colour for every individual circle. Later I'll have multiple images like picture 1 where i want to track the positions of the individual circles. The circles will change their positions slighty in every picture.
Maybe someone can help me a bit. Thanks a lot!
댓글 수: 0
답변 (3개)
Ben Drebing
2018년 5월 11일
You can use some of the image processing functions like "bwconncomp" or "regionprops" to do this! Try out this code:
im = imread('picture 1.png');
BW = rgb2gray(im);
%Find each connected component in the image
cc = bwconncomp(BW);
% Calculate the centroid of each circle
s = regionprops('table',cc,'Centroid')
%Display the centroid of each component/circle
imshow(BW)
centroids = cat(1, s.Centroid);
hold on
plot(centroids(:,1),centroids(:,2), 'b*')
hold off
The examples on this doc page seem pretty similar to what you are describing:
댓글 수: 0
Image Analyst
2018년 5월 11일
Tracking is not easy but not too bad as long as your regions don't move much and none enter or leave the field of view. There are functions in the Computer Vision System Toolbox to help you if you want.
To assign colors to your binary image, call bwlabel, and then use label2rgb(). Here's a snippet from my Image Segmentation Tutorial. Adapt as needed:
% Identify individual blobs by seeing which pixels are connected to each other.
% Each group of connected pixels will be given a label, a number, to identify it and distinguish it from the other blobs.
% Do connected components labeling with either bwlabel() or bwconncomp().
labeledImage = bwlabel(binaryImage, 8); % Label each blob so we can make measurements of it
% labeledImage is an integer-valued image where all pixels in the blobs have values of 1, or 2, or 3, or ... etc.
subplot(3, 3, 4);
imshow(labeledImage, []); % Show the gray scale image.
title('Labeled Image, from bwlabel()', 'FontSize', 15);
% Let's assign each blob a different color to visually show the user the distinct blobs.
coloredLabels = label2rgb (labeledImage, 'hsv', 'k', 'shuffle'); % pseudo random color labels
% coloredLabels is an RGB image. We could have applied a colormap instead (but only with R2014b and later)
subplot(3, 3, 5);
imshow(coloredLabels);
axis image; % Make sure image is not artificially stretched because of screen's aspect ratio.
caption = sprintf('Pseudo colored labels, from label2rgb().\nBlobs are numbered from top to bottom, then from left to right.');
title(caption, 'FontSize', 15);
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!