How do you align two images?

조회 수: 4 (최근 30일)
Ilana Mannine
Ilana Mannine 2013년 3월 1일
I've never used Matlab before so I am incredibly confused. For my assignment we are supposed to take three pictures, each representing the R, G, B color channels and align them to form the colored picture. This is what I have so far:
% name of the input file
imname = 'part1_1.jpg';
% read in the image
fullim = imread(imname);
% convert to double matrix (might want to do this later on to same memory)
fullim = im2double(fullim);
% compute the height of each part (just 1/3 of total)
height = floor(size(fullim,1)/3);
% separate color channels
B = fullim(1:height,:);
G = fullim(height+1:height*2,:);
R = fullim(height*2+1:height*3,:);
% Align the images
% Functions that might be useful to you for aligning the images include:
% "circshift", "sum", and "imresize" (for multiscale)
% imshow(R)
% imshow(G)
% imshow(G)
% aR = align(R,B);
% aG = align(G,B);
RGB = cat(3, R, G, B);
imshow(RGB)
% ssd = sum(sum((R -G) .^2));
% display(ssd);
% open figure
%%figure(1);
% create a color image (3D array)
% ... use the "cat" command
% show the resulting image
% ... use the "imshow" command
% save result image
%%imwrite(colorim,['result-' imname]);
This produces a colored image, but the pictures are not aligned properly. We are supposed to create an align function that aligns the two images, but I have no idea how to do that. He says we have to use a displacement vector, but again I'm not sure what that means. Any advice please? Don't direct me to a link, I really need direct help.

답변 (1개)

Image Analyst
Image Analyst 2013년 3월 1일
Are you allowed to use the imregister() function? If so, just extract the three color channels and align all of them to the red channel. Of course we can't comment on how good your code does the job because you didn't upload your image.
  댓글 수: 2
Ilana Mannine
Ilana Mannine 2013년 3월 1일
Can you give an example? He said I'm supposed to align using a displacement vector. Can you tell me what that means please?
Image Analyst
Image Analyst 2013년 3월 2일
imregister has examples in the help. A displacement vector would probably be something like
displacementVector = [10, 20]; % row displacement, column displacement
out = in(displacementVector(1):end, displacementVector(2):end);

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

카테고리

Help CenterFile Exchange에서 Modify Image Colors에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by