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 Center および File ExchangeLoops 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