image correlation, multiple occurance pattern

조회 수: 9 (최근 30일)
Mateusz Fijak
Mateusz Fijak 2019년 4월 26일
편집: Image Analyst 2019년 4월 27일
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
Mateusz Fijak
Mateusz Fijak 2019년 4월 26일
error occurs inside the for loop in imrect method
Image Analyst
Image Analyst 2019년 4월 27일
편집: Image Analyst 2019년 4월 27일
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).

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by