How do I shift the alignment of one image over the other?

조회 수: 3 (최근 30일)
Samyukta Ramnath
Samyukta Ramnath 2013년 7월 12일
댓글: Stelios Fanourakis 2018년 5월 3일
I have two images (both are of crosses as in x. They were of different sizes and different colours, I converted both of them into binary images and brought the actual crosses (That is,the area of the cross, not the entire image wit whitespace and all) to the same scale. When I use imshowpair to subtract the two images, however, I get a very large answer because the two crosses are not aligned properly over each other. Reference : https://twitter.com/SamyuktaRamnath/status/355657777277968385/photo/1
So, I have two options. Either I just find their centres and align them, or I run an algorithm to find the difference between the two pictures and shift the alignment to the least difference, after shifting it.
But I don't know how to shift the second picture over the first. Any function, or any way that I can move it coordinate by coordinate?

채택된 답변

Image Analyst
Image Analyst 2013년 7월 12일
First figure out the overlap region, then place it on a new canvass:
% Create blank new canvass the same size as the reference image.
newCanvass = zeros(size(referenceImage), 'uint8');
% Place overlap image down at row, column
newCanvass(row:end, column:end) = overlapImage;
  댓글 수: 3
Image Analyst
Image Analyst 2013년 7월 12일
Like say when the images are overlapped perfectly, the upper left corner of image 2 lands at row = 143, and column = 73 (or whatever). Pixels inside the overlap rectangle overlap acceptably while those outside the overlap region exist in either one image or the other but not both.
Stelios Fanourakis
Stelios Fanourakis 2018년 5월 3일
@Image Analyst. I want to do something similar. I have 15 dicom images. They are slightly shifted. Need to properly align them to a reference 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