detecting and labeling an object from an image
16 ビュー (過去 30 日間)
古いコメントを表示
I am trying to detect and label some objects of interest from image sequences using feature matching, tried SURF, BRISK, MSER etc. until now but mostly either there are no matched features or I get only 1 or 2 matches with which I can't label the object (mean label all the pixels of that object). Can someone suggest something. Here is code for MSER features and sample images.
Ib=imread('ball.png'); %object image
Is=imread('image_000002.jpg'); % scene image
Ib=rgb2gray(Ib);
Is=rgb2gray(Is);
regionsb = detectMSERFeatures(Ib);
regionss = detectMSERFeatures(Is);
[featuresb, validPtsObjb] = extractFeatures(Ib, regionsb);
[featuress, validPtsObjs] = extractFeatures(Is, regionss);
bPairs = matchFeatures(featuresb, featuress);
matchedBPoints = regionsb(bPairs(:, 1), :);
matchedSPoints = regionss(bPairs(:, 2), :);
figure;
showMatchedFeatures(Ib, Is, matchedBPoints, matchedSPoints, 'montage');
title('Putatively Matched Points (Including Outliers)');
[tform, inlierBPoints, inlierSPoints] = estimateGeometricTransform(matchedBPoints, matchedSPoints, 'affine');
figure;
showMatchedFeatures(Ib, Is, inlierBPoints, inlierSPoints, 'montage');
title('Matched Points (Inliers Only)');
bPolygon = [1, 1;... % top-left
size(Ib, 2), 1;... % top-right
size(Ib, 2), size(Ib, 1);... % bottom-right
1, size(Ib, 1);... % bottom-left
1, 1];
newBPolygon = transformPointsForward(tform, bPolygon);
figure;
imshow(Is);
hold on;
line(newBPolygon(:, 1), newBPolygon(:, 2), 'Color', 'y');
title('Detected Box');
0 件のコメント
回答 (2 件)
Image Analyst
2016 年 3 月 10 日
If the ball is a contrasting color from the rest of the photo, you could use color segmentation. I have a few tutorials for that in my File Exchange http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 Or you could use the Color Thresholder on the Apps tab on the tool ribbon.
Otherwise if you're looking for moving things, you can use Optical Flow in the Computer Vision System Toolbox.
Another alternative is to look for that template in the main image. You can use normxcorr2(), like the attached demo, if the thing in the scene does not differ too much from your example template.
0 件のコメント
athome may
2019 年 4 月 26 日
HI, this is organ detection image that i get.
Dark Blue object in the image suppose to be label with " Liver", with the text colour of dark blue.
For other object, they have to be label with text that have similar colour to the object colour too. I couldnt figure out how to do it, can anyone have any idea? Thank in advance!
2 件のコメント
Image Analyst
2019 年 4 月 26 日
Get the centroid or bounding box from regionprops. Then in a loop, get the color from the colormap and call text at the location of the centroid plus some delta x, or the location of the top or left of the bounding box. For example if you used hsv(256) in your call to label2rgb(), use hsv. Here's a start.
labeledImage = bwlabel(binaryImage);
props = regionprops(labeledImage, 'BoundingBox, 'Centroid');
rgbImage = label2rgb(labeledImage, hsv(256), ..........................etc.
for k = 1 : numberOfRegions
thisColor = hsv(k);
x = ..........whatever
y = .........whatever
caption = sprintf('Blob #%d', k); % Whatever you want to say about this blob.
text(x, y, caption);
end
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!