image correlation, multiple occurance pattern

10 Ansichten (letzte 30 Tage)
Mateusz Fijak
Mateusz Fijak am 26 Apr. 2019
Bearbeitet: Image Analyst am 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 Kommentare
Mateusz Fijak
Mateusz Fijak am 26 Apr. 2019
error occurs inside the for loop in imrect method
Image Analyst
Image Analyst am 27 Apr. 2019
Bearbeitet: Image Analyst am 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).

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by