필터 지우기
필터 지우기

Image registration not aligning images correctly

조회 수: 7 (최근 30일)
msij
msij 2017년 2월 12일
댓글: Vandana Rajan 2017년 2월 15일
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
msij
msij 2017년 2월 13일
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 2017년 2월 15일
Hi,
When you use the 'OutputView' parameter, it preserves the world limits and resolution of the fixed image when forming the transformed image.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by