Azzera filtri
Azzera filtri

Finding an Object with multiple labels in another image

1 visualizzazione (ultimi 30 giorni)
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

Risposte (1)

Image Analyst
Image Analyst il 29 Apr 2023
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.
  1 Commento
Chapz82
Chapz82 il 30 Apr 2023
Thank you very much for the answer. I will check out the links.
About your questions:
I don't know nothing about the location/size /scale of the object (in this case the trashman).
The ideia is not using another image as a template to find the object in another image (as in your example with cross correlation) but using the object properties to try and find the same object but in a diferent random image ( that's why I show the Solidity, Circularity and Eccentricity)
Hope this helps you (and others) to understand better my question.
If you could give me more guides to how I should procced I would appreciate it very much :)

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by