Problem with image registration on images with simple patterns

20 ビュー (過去 30 日間)
cr
cr 2020 年 8 月 19 日
コメント済み: cr 2025 年 10 月 20 日 5:37
I have trouble matching features on images with simple patterns like shown in two attached pictures. SURF, BRISK and other feature detection functions in CV toolbox work well with images rich in features but fail at these -see the attached result of automatic image registration. I tried every feature detection function the toolbox offers and tried changing various input parameters like thresholds, quality, contrast, octaves, filter sizes, etc without any luck. I also tried binarizing the images and separately HOG feature extractor. The script below that I used is straight from Matlab examples.
Can anyone (@Image Analyst @Walter Roberson) advise?
Thanks!
original = rgb2gray(imread('A0.png'));
ptsOriginal = detectSURFFeatures(original,'NumOctaves',1,'NumScaleLevels',5,'MetricThreshold',10);
[featuresOriginal,validPtsOriginal] = extractFeatures(original,ptsOriginal);
figure
distorted = rgb2gray(imread(sprintf('A2.png',k)));
subplot(121), imshowpair(original,distorted,'m'),
ptsDistorted = detectSURFFeatures(distorted,'NumOctaves',1,'NumScaleLevels',5,'MetricThreshold',5);
[featuresDistorted,validPtsDistorted] = extractFeatures(distorted,ptsDistorted);
indexPairs = matchFeatures(featuresOriginal,featuresDistorted);
matchedOriginal = validPtsOriginal(indexPairs(:,1));
matchedDistorted = validPtsDistorted(indexPairs(:,2));
[tform, inlierDistorted,inlierOriginal] = ...
estimateGeometricTransform(matchedDistorted,...
matchedOriginal,'similarity');
outputView = imref2d(size(original));
recovered = imwarp(distorted,tform,'OutputView',outputView);
subplot(122), imshowpair(original,recovered)

採用された回答

Steve Eddins
Steve Eddins 2025 年 10 月 16 日 19:16
As of R2024b, the function imregcorr uses a new algorithm called normalized gradient correlation. See my 16-Oct-2025 blog post for more information. That function can now register these images successfully.
A2 = imread("A2.png");
A0 = imread("A0.png");
tiledlayout(1,2)
nexttile
imshow(A2), title("A2")
nexttile
imshow(A0), title("A0")
tform = imregcorr(A2,A0)
tform =
simtform2d with properties: Dimensionality: 2 Scale: 1.0000 RotationAngle: -32.5015 Translation: [317.9212 1.4153e+03] R: [2×2 double] A: [1.0e+03 * 0.0008 0.0005 0.3179 -0.0005 0.0008 1.4153 0 0 0.0010]
[A2_reg,A2_reg_ref] = imwarp(A2,tform);
figure
imshowpair(A2_reg, A2_reg_ref, A0, imref2d(size(A0)))
  3 件のコメント
Steve Eddins
Steve Eddins 2025 年 10 月 18 日 14:41
Good questions. First, I want to clarify that these percentages are from memory. This is all from work that I did in late 2023 and early 2024, before retiring from MathWorks.
I did not mean to say that the old algorithm performed better in 5% of the cases. In about 4% of these cases, as I recall, the two algorithms performed equally as well.
In a very small number of cases, perhaps about a dozen cases out of 10,000, the old algorithm performed better on my metric, but the result was rather meaningless, because both algorithms gave answers that were grossly inaccurate and therefore useless. Typically, one or both images in these cases had almost no meaningful content. For example, there might have been just one edge in one image that could match multiple locations in the other image equally well.
The comparison metric was the average "transformation distance error," which was the pixel distance between the transformed point using the reference transformation and the transformed point using the estimated transformation. The average was taken over all points in the domain of one of the image pairs.
cr
cr 2025 年 10 月 20 日 5:37
Thanks.
Happy retirement.

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2020 年 8 月 19 日
I think the periodicity and enormous translations and rotations may be causing problem. You might try imregcorr().
Otherwise try segmenting out the rectangle using tradtional methods:
  1. Threshold the image
  2. call regionprops asking for centroids.
  3. fit a line with polyfit through the centroids to determine the angle
  4. Call imrotate
  5. threshold again and call regionprops
  6. call imtranslate to align with other, reference image.
or:
  1. Threshold the image
  2. call bwconvhull(mask, 'union')
  3. call regionprops asking for orientation
  4. call imrotate
  5. threshold again and call regionprops
  6. call imtranslate
  2 件のコメント
cr
cr 2020 年 8 月 19 日
編集済み: cr 2020 年 8 月 19 日
Hello, Thanks for responding. Will try further. The bigger picture is, that this is one of such troublesome pattern and the algorithm should be able to handle anything in general.
I tried specifying starting point of very close to the actual angle of rotation but it still doesn't work. Also tried binarizing. What's intriguing is, the same functions and formulation works very well with more features. Any idea why so?
Image Analyst
Image Analyst 2020 年 8 月 19 日
Maybe try Hu's moments.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeComputer Vision with Simulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by