Image registration not aligning images correctly

10 Ansichten (letzte 30 Tage)
msij
msij am 12 Feb. 2017
Kommentiert: Vandana Rajan am 15 Feb. 2017
I am trying to align two images to be able to extract data from them and compare before and after.
I have tried intensity-based image registration and control point image registration but it doesn't seem to be aligning them up correctly.
I have attached the images and the code is below. When I use:
imshowpair(fixed_filtered,movingRegistered,'Scaling','joint');
They are not aligned up. Not sure what I'm doing wrong, I've tried playing around with the settings but it doesn't appear to make much of a difference, just makes the computing time longer.
Intensity code:
fixed = imread('Fixed.JPG');
fixed = imcrop(fixed,[1700 1200 2000 1500]);
fixed_gray = rgb2gray(fixed);
thresh1 = graythresh (fixed_gray);
fixed_bw = im2bw(fixed_gray, thresh);
fixed_filtered = bwareafilt(fixed_bw,[10 500]);
fixed_filtered = double(fixed_filtered);
moving = imread('Moving.JPG');
moving = imcrop(moving,[1700 1200 2000 1500]);
moving_gray = rgb2gray(moving);
thresh2 = graythresh (moving_gray);
moving_bw = im2bw(moving_gray, thresh);
moving_filtered = bwareafilt(moving_bw,[10 500]);
moving_filtered = double(moving_filtered);
imshowpair(fixed,moving,'Scaling','joint');
[optimizer, metric] = imregconfig('monomodal');
optimizer.MaximumIterations = 1000;
optimizer.MaximumStepLength = 0.001
movingRegistered = imregister(moving_filtered, fixed_filtered, 'rigid', optimizer, metric);
figure(1);
imshowpair(fixed_filtered,moving_filtered,'Scaling','joint');
figure(2);
imshowpair(fixed_filtered,movingRegistered,'Scaling','joint');
For control point, I use this instead of the optimizer metric part of the code:
cpselect(moving,fixed);
mytform = fitgeotrans(movingPoints, fixedPoints, 'similarity');
movingRegistered = imwarp(moving, mytform);
All help is greatly appreciated. Thank you!!
  2 Kommentare
msij
msij am 13 Feb. 2017
Ok so I've kind of found a solution for this.
By changing modifying the code from:
movingRegistered = imwarp(moving, mytform);
to:
movingRegistered = imwarp(moving, mytform,'OutputView', imref2d(size(fixed)));
the image actually aligns up. I am not sure why, so if someone could explain that I'd be grateful.
However, I would still like to figure out a way to have this done automatically so any ideas on how to fix the intensity-based image registration?
Thanks!
Vandana Rajan
Vandana Rajan am 15 Feb. 2017
Hi,
When you use the 'OutputView' parameter, it preserves the world limits and resolution of the fixed image when forming the transformed image.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Geometric Transformation and Image Registration finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by