image correlation, multiple occurance pattern

10 visualizzazioni (ultimi 30 giorni)
Mateusz Fijak
Mateusz Fijak il 26 Apr 2019
Modificato: Image Analyst il 27 Apr 2019
Hi there,
i was trying to detect multiple occurrence of pattern in ma image, but i keep on getting error:
"Error using horzcatDimensions of arrays being concatenated are not consistent."
Here is the code:
imagePath = 'C:\Users\Mateusz\Desktop\Systemy wizyjne\labolatoria\matlab\Database\Patterns\multi.png';
patternPath1 = 'C:\Users\Mateusz\Desktop\Systemy wizyjne\labolatoria\matlab\Database\Patterns\multi_P1.png';
img = imread(imagePath);
imgGs = rgb2gray(img);
pattern1 = imread(patternPath1);
patternGs1 = rgb2gray(pattern1);
subplot(1, 4, 1)
imshow(imgGs)
subplot(3, 4, 6)
imshow(patternGs1)
corelation1 = normxcorr2(patternGs1, imgGs);
subplot(3, 4, 7)
surf(corelation1)
shading flat
subplot(1, 4, 4)
imshow(imgGs);
dvals = sort(corelation1(:), 'descend'); % 5 ekstrme
for i = 1 : 5
[ypeak, xpeak] = find(corelation1 == max(corelation1(:)));
yOffset = ypeak-size(patternGs1, 1);
xOffset = xpeak-size(patternGs1, 2);
hold on
imrect(gca, [xOffset+1, yOffset+1, size(patternGs1, 2), size(patternGs1, 1)]);
end
  2 Commenti
Mateusz Fijak
Mateusz Fijak il 26 Apr 2019
error occurs inside the for loop in imrect method
Image Analyst
Image Analyst il 27 Apr 2019
Modificato: Image Analyst il 27 Apr 2019
What are the values in this array:
[xOffset+1, yOffset+1, size(patternGs1, 2), size(patternGs1, 1)]
? And attach your two images (you forgot to in your original post).

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by