Home > other >  Matlab using sift Mosaic algorithm of fis function shows undefined function, fis is what, how to rep
Matlab using sift Mosaic algorithm of fis function shows undefined function, fis is what, how to rep

Time:10-03

The
reference
clear
Close all
F='a';
Ext='JPG';
Img1=imread ([f '1' ext]);
Img2=imread ([f '2.' ext]);
Img3 %=imread (' b3. JPG);

Img0=imMosaic (img2 img1, 1);
% img0=imMosaic (img1, img0, 1);
Fis (img0)
Imwrite (img0, [' mosaic_ 'f'. 'ext], ext)

reference
function [imgout]=imMosaic (img1, img2 adjColor, img1file, img2file)
% [imgout]=imMosaic (img1, img2 adjColor)
% img1 and img2 can (both) be RGB or gray, a double or uint8.
% If you have more to do than 2 images Mosaic, call this function several
% times.
% If you set adjColor to 1, imMosaic will try to try to adjust the
% color (RGB) for the or grayscale (for gray image) of img1 linearly, so the 2
% images can join more naturally.
% Yan Ke @ THUEE, 20110123

% use SIFT to find corresponding points
[matchLoc1 matchLoc2]=siftMatch (img1file img2file);

% use RANSAC to find homography matrix
CorrPtIdx [H]=findHomography (matchLoc2 ', matchLoc1 ');
H % # ok
Tform=maketform (' projective 'H');
Img21=imtransform (img2 tform); % reproject img2
Fis (img1)
Fis (img21)

% adjust color or grayscale linearly, using corresponding infomation
[M1 N1 dim]=size (img1);
[M2 N2 ~]=size (img2);
If exist (' adjColor ', 'var') & amp; & AdjColor==1
The radius=2;
X1ctrl=matchLoc1 (corrPtIdx, 1);
Y1ctrl=matchLoc1 (corrPtIdx, 2);
X2ctrl=matchLoc2 (corrPtIdx, 1);
Y2ctrl=matchLoc2 (corrPtIdx, 2);
CtrlLen=length (corrPtIdx);
S1=zeros (1, ctrlLen);
S2=zeros (1, ctrlLen);
For color=1: dim
For p=1: ctrlLen
Left=round (Max (1, x1ctrl (p) - the radius));
Right=round (min (N1, left radius, + + 1));
The up=round (Max (1, y1ctrl (p) - the radius));
The down=round (min (radius, M1, the up + + 1));
S1 (p)=sum (the sum (img1 (up, down, left, right, color)));
End
For p=1: ctrlLen
Left=round (Max (1, x2ctrl (p) - the radius));
Right=round (min (radius, N2, left + + 1));
The up=round (Max (1, y2ctrl (p) - the radius));
The down=round (min (radius, M2, up + + 1));
S2 (p)=sum (the sum (img2 (up, down, left, right, color)));
End
Sc=(radius * 2 + 1) ^ 2 * ctrlLen;
Adjcoef=polyfit (s1/sc, s2/sc, 1);
Img1 (:, :, color)=img1 (:, :, color) * adjcoef adjcoef (1) + (2);
End
End

% do the Mosaic
Pt=zeros (3, 4);
Pt (:, 1)=H * [1, 1, 1);
Pt (:, 2)=H * [N2, 1, 1);
Pt (:, 3)=H * [N2, M2, 1];
Pt (:, 4)=H * [1, M2, 1];
X2=pt (1, :)./pt (3, :);
Y2=pt (2, :)./pt (3, :);

The up=round (min (y2));
Yoffset=0;
If the up & lt;=0
Yoffset=- up + 1;
The up=1;
End

Left=round (min (x2));
Xoffset=0;
If left<=0
Xoffset=left + 1;
Left=1;
End

[M3 N3 ~]=size (img21);
Imgout (up: the up + M3-1, left, left + N3-1, :)=img21;
% img1 is above img21
Imgout (Yoffset + 1: Yoffset + M1, Xoffset + 1: Xoffset + N1, :)=img1;

End


The complete code and code source: http://www.pudn.com/Download/item/id/2557125.html

CodePudding user response:

The top GGGG
  • Related