How do you align two images?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (1)
Image Analyst
le 1 Mar 2013
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 commentaires
Image Analyst
le 2 Mar 2013
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);
Voir également
Catégories
En savoir plus sur Modify Image Colors dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!