Problem with image registration on images with simple patterns

3 views (last 30 days)
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)

Answers (1)

Image Analyst
Image Analyst on 19 Aug 2020
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 Comments
cr
cr on 19 Aug 2020
Edited: cr on 19 Aug 2020
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?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!