Detecting multiple object in an image

Hello,
I am working on a project where I have to detect photovoltaic modules using infrared images.
I am using a template image to detect the modules but I can only detect one. What should I do to detect all the modules?
I do not have a lot of experience in programming but I am really trying.

4 commentaires

Image Analyst
Image Analyst le 1 Avr 2019
How are you detecting the one? Are you thresholding and calling bwlabel() to do the counting? Attach your image and your "single detection" code.
Felipe Souza
Felipe Souza le 1 Avr 2019
Modifié(e) : Felipe Souza le 1 Avr 2019
Original Image
Felipe Souza
Felipe Souza le 1 Avr 2019
Modifié(e) : Felipe Souza le 1 Avr 2019
Template
clear all; close all; clc;
%% READING THE RGB IMAGE
A = imread('Teste.jpg');
imshow(A);
%% CONVERTING RGB IMAGE TO GRAYSCALE FORMAT
A_gray = rgb2gray(A);
imshow(A_gray);
%% CONVERTING IMAGE TO DOUBLE FORMAT
A_gray = im2double(A_gray);
imshow(A_gray);
%% CONVERTING THE GRAYSCALE IMAGE TO BINARY FORMAT
otsu_level = graythresh(A_gray);
A_otsu_thresh = im2bw(A_gray, otsu_level);
imshow(A_otsu_thresh);
%% DETECTING OBJECTS IN THE IMAGE
label=bwlabel(A_otsu_thresh);
max(max(label))
for j=1:max(max(label))
im1 = (label==j);
figure(2), subplot(6,6,j);imshow(im1); title(j);
j= j+1;
end
%% CORRELATION
[Ir Ic]=size(A_gray);
T1 = imread('Template.jpg'); %read template of the image
T = rgb2gray(T1);
imshow(T);
[Tr Tc]=size(T);
R=normxcorr2(T,A_gray); %find normalize cross correlation
R=imcrop(R,[Tc Tr Ic Ir]); %crop extra pixels
[row column value] = find(R==(max(max(R)))) %find the coordinates where maximum correlation exists
RGB=insertShape(A_gray,'rectangle',[column row Tc Tr], 'LineWidth',3); %create a box around maximum match
imshow(RGB);
% RIGHT HERE I WOULD LIKE TO COMPARE THE OBJECTS WITH A NORMAL MODULE
% IN ORDER TO FIND DEFECT MODULES AND LOCATE THEIR POSITIONS

Connectez-vous pour commenter.

Réponses (1)

Shunichi Kusano
Shunichi Kusano le 2 Avr 2019

0 votes

You select only one of highly correlated pixels, because you find the maximum correlation by "find(R==(max(max(R))))". In order to detect some of them, you need to select peaks. For that, the following link is useful.
By the way, you can use max(R(:)) instead of max(max(R)). In addition, j = j + 1 in the for loop is not needed here. In the for loop, the value of j is automatically incremented according to what you indicated as 1:max(label(:)).

1 commentaire

Felipe Souza
Felipe Souza le 2 Avr 2019
Thanks a lot!
I am going to give a look on the link you posted

Connectez-vous pour commenter.

Catégories

En savoir plus sur Convert Image Type dans Centre d'aide et File Exchange

Produits

Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by