画像とテンプレート間の類似度を計算する
Match = MatchTemplate(SourceImage, TemplateImage, Method);
2次元の行列で、型は uint8である
2次元の行列で、型は uint8である。行と列の数はSourceImageにおける行と列の数を超えられない
定数で、型はuint8で、以下の値は可能である:
MATCH_LEAST_SQUARES: SourceImageとTemplateImage間のグレー値の差の2乗の合計
MATCH_CORRELATION: SourceImageとTemplateImage間の相関
MATCH_LEAST_SQUARES_NORM: SourceImageとTemplateImage間のグレー値の差の2乗の正規化された合計
MATCH_CORRELATION_NORM: SourceImageとTemplateImage間のの正規化された相関
2次元の行列で、型は doubleである
この関数は、ソース画像とテンプレート画像間の類似度を計算する。 結果は行列である。この行列はソース画像より小さい。
global MATCH_CORRELATION_NORM; global IPD_PATH; SourceColorImage = ReadImage(IPD_PATH + 'demos\teaset.png'); SourceImage = RGB2Gray(SourceColorImage); TemplateColorImage = ReadImage(IPD_PATH + 'demos\cropped_image.png'); TemplateImage = RGB2Gray(TemplateColorImage); Match = MatchTemplate(SourceImage, TemplateImage, MATCH_CORRELATION_NORM); MatchList = FindBestMatches(Match, size(TemplateImage), MATCH_CORRELATION_NORM); SquareList = list(); for n = 1 : size(MatchList, 1) SquareList($ + 1) = struct('BoundingBox', cat(2, MatchList(n, :) - [1 1], [3 3])'); end; SourceHandle = figure(); ShowColorImage(SourceColorImage, 'Image with Marked Match Positions'); DrawBoundingBoxes(SquareList, [0 1 0], SourceHandle); TemplateHandle = figure(); ShowColorImage(TemplateColorImage, 'Template Image'); | ![]() | ![]() |