Image registration not aligning images correctly
Mostrar comentarios más antiguos
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 comentarios
msij
el 13 de Feb. de 2017
Vandana Rajan
el 15 de Feb. de 2017
Hi,
When you use the 'OutputView' parameter, it preserves the world limits and resolution of the fixed image when forming the transformed image.
Respuestas (0)
Categorías
Más información sobre Image Processing and Computer Vision en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!