Finding an Object with multiple labels in another image
3 次查看(过去 30 天)
显示 更早的评论
Hello let's say that I have the following image
And I want to take the Solidity, Circularity and Eccentricity of the trash-man sign so I can use the pattern based on this properties to find this object in other image.
The problem is that the sign has 20 little objects inside (this number is given by the bwlabel function). With the following values, in order the Solidity, Circularity and Eccentricity of the sign.
How can I use this values to find this object (using cruzed correlation) in the following image, per example
To binarize the image im using the following code:
img = imread("image1.png");
hsvImg = rgb2hsv(img);
bw = autobin(hsvImg(:,:,3));
function img_binaria = autobin(img)
% Aplicar uma expansão
expansao_img = imadjust(img);
% Obter a mascara
mask_binaria = graythresh(expansao_img);
% Tranformar em imagem binário
img_binaria = imbinarize(expansao_img, mask_binaria);
% Contar o número de píxeis brancos e pretos
pixeis_brancos = sum(img_binaria(:) == 1);
pixeis_pretos = sum(img_binaria(:) == 0);
% Se houver mais pixeis brancos do que pretos temos de inverter a imagem
if(pixeis_brancos > pixeis_pretos)
% Função que inverte matrizes binárias
img_binaria = imcomplement(img_binaria);
disp('Image got inverted because number of white pixels is greather then black pixels')
end
end
0 个评论
回答(1 个)
Image Analyst
2023-4-29
What do you know about that trashman? Do you know it's always in the lower left?
What do you know about the other images? Will trashman be the same size and orientation in those other images?
It's a generic, general purpose demo of how to threshold an image to find blobs, and then measure things about the blobs, and extract certain blobs based on their areas or diameters.
You might look at normalized cross correlation, like in the attached demo.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!