How to combine two images based off matched features?

24 visualizzazioni (ultimi 30 giorni)
Hi, I am trying to combine these 2 images based off their similarities? I am using matched features and would like to sort of blend them together such that they appear as a single image. The only thing I'm not sure how to do is "merging" them together using said matched features. Any help is greatly appreciated, thank you!
Here is the image produced showing the matchedfeatures
currentfolder = 'C:\Users\owen\Google Drive\Programming\Matlab\New folder'
pandaDir = fullfile(currentfolder);
pandaImg = imageSet(pandaDir);
montage(pandaImg.ImageLocation);
I = read(pandaImg,1); %assign the first image to variable I;
B = read(pandaImg,2);
I1 = rgb2gray(I);
B1 = rgb2gray(B);
points1 = detectHarrisFeatures(I1); %finds the corners
points2 = detectHarrisFeatures(B1);
[features1, valid_points1] = extractFeatures(I1,points1);
[features2 valid_points2] = extractFeatures(B1,points2);
indexPairs = matchFeatures(features1,features2);
matchedPoints1 = valid_points1(indexPairs(:,1),:);
matchedPoints2 = valid_points2(indexPairs(:,2),:);
figure; showMatchedFeatures(I1,B1,matchedPoints1,matchedPoints2);
blender = vision.AlphaBlender('Operation', 'Binary mask', ...
'MaskSource', 'Input port');

Risposte (2)

Ahmet Cecen
Ahmet Cecen il 9 Mag 2016
Seems like you have the indices of the matched features in both images. If you are certain no rotation is required, then you can simply do something like:
CompositeImage=[Image2(:,YCOORDINATEOFAMATCHEDFEATUREORPIXELinIMAGE2) Image1(:,YCOORDINATEOFTHESAMEMATCHEDFEATUREORPIXELinINAGE1:end) ]
  2 Commenti
Owen Chak
Owen Chak il 9 Mag 2016
Modificato: Owen Chak il 9 Mag 2016
hi, thank you for your answer! The issue I'm having is that I have absolutely no idea how to specify only the y coordinates for my matchedfeatures points. Also, why wouldn't we take in consideration x coordinates in this code?
Ahmet Cecen
Ahmet Cecen il 9 Mag 2016
Modificato: Ahmet Cecen il 9 Mag 2016
Haha my bad, this ij and xy inversion for images gets me sometimes. It is indeed the x coordinate, or j.
I haven't used this toolbox myself, but from the documentation, it looks like matchedPoints1 stores the corner points on Image1 and matchedPoints2 store the corresponding corner points on Image2. So:
matchedPoints1.Location(pointnumber,1)
will give the x location of a point in Image1, then:
matchedPoints2.Location(pointnumber,1)
will give the same point on the other. There may be some rounding issues. Keep in mind though you access and image array as:
Image(y,x)

Accedi per commentare.


Image Analyst
Image Analyst il 9 Mag 2016
  1 Commento
Owen Chak
Owen Chak il 9 Mag 2016
Modificato: Owen Chak il 9 Mag 2016
I was working based off that panorama guide actually! And thank you so much for that first link, it seems to be exactly what I need

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by