Problem with image registration on images with simple patterns
20 ビュー (過去 30 日間)
古いコメントを表示
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)

0 件のコメント
採用された回答
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)
[A2_reg,A2_reg_ref] = imwarp(A2,tform);
figure
imshowpair(A2_reg, A2_reg_ref, A0, imref2d(size(A0)))
3 件のコメント
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.
その他の回答 (1 件)
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:
- Threshold the image
- call regionprops asking for centroids.
- fit a line with polyfit through the centroids to determine the angle
- Call imrotate
- threshold again and call regionprops
- call imtranslate to align with other, reference image.
or:
- Threshold the image
- call bwconvhull(mask, 'union')
- call regionprops asking for orientation
- call imrotate
- threshold again and call regionprops
- call imtranslate
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Computer Vision with Simulink についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!