File Exchange

image thumbnail

image mosaic using SIFT

version (254 KB) by Ke Yan
Automatic image mosaic using SIFT, RANSAC and homography.


Updated 24 Mar 2011

View License

SIFT is derived from a downloaded binary code 'siftDemoV4.rar'.

Comments and Ratings (39)

Lenny Bai

Cary Zhang

Nice work!

Wenjun Yi

Hima B V S

Sift 32 bit file is not running in my windows 10 ,its showing invalid keypoint file begining at line 53

Xiuwei Zhao

JinYi Wen

I´m a newbie in matlab, to run this function, what should I do? It´s not enough to create a script like this:


What am I doing wrong on the input of the image?(the sript and the function are in the same folder)
The error is this:

Error using imread>parse_inputs (line 457)
The file name or URL argument must be a string.
Error in imread (line 316)
[filename, fmt_s, extraArgs] = parse_inputs(varargin{:});
Error in sift (line 22)
image = imread(imageFile);
Error in testsift (line 2)

Thank you!

function ISRGB has been removed.

Yiyi Deng

Function ISRGB has been removed......


lucile De

I am trying your library to estimate the motion between 2 images. But I want the fundamental matrix and I suppose that it is H in your code. But the rank of the fundamental matrix should be 2 but here it it doesn't work. Maybe I didn't udnerstand how you library works but let me now.

chan mark

can not run."Function ISRGB has been removed."

somebody plz help:
when i run these files, i get an error "not enough arguments"

can anyone tell the reason for this and way to correct it.

sana khan

somebody know which method he had use in immosaic function specifically in this part
% 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,:);

up = round(min(y2));
Yoffset = 0;
if up <= 0
Yoffset = -up+1;
up = 1;

left = round(min(x2));
Xoffset = 0;
if left<=0
Xoffset = -left+1;
left = 1;

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

is there anyother way of doing this warping part...

sana khan

you should run the mosaic test function.

which file do i run first???

what is the main main use of the SIFTMATCH function in this program of execution ?


can this code be modified for hessian detector and harris corner?


Maybe someone has matlab code to eliminate camera distortion? This code doesn't do that :(

jacky chen

it's really cool,man,just replace the function isrgb when you are using a new matlab version(R 8.0+)

jacky chen


Nice work!

Any idea how to get a fully cropped image? Without the black surroundings? Would be really helpful. Thank you


nice wrk. I want detailed explainatiön of code. Any one?


Please give me a detail construction.



Hi Kyle,

replace "if isrgb(img)" with "if size(img,3)==3" in shift.m


Hi Kyle,

replace "if isrgb(img)" with "if size(img,3)==3" in shift.m


If anyone has the m code (or in any other other form) implementation of siftWin32.exe (the SIFT algo), pls upload or email me at

Thanks a lot!


function im = appendimages(image1, image2)
i want to know what im is ? A matrix or a image?


thank you very much.
but how to generate a mosaic image. i nt getting. plz help


i found it very helpful, thank for sharing :)


thank your for sharing your code.
it proved very helpful to me :)


Awesome !!! Thank you


??? Error: File: imMosaic.m Line: 78 Column: 9
Unbalanced or unexpected parenthesis or bracket.
should be written as for Matlab 2009
[M3, N3, ~] = size(img21);
[M2, N2, ~] = size(img21);


Warning: isrgb is obsolete and may be removed in the future.
See product release notes for more information.
> In isrgb at 29
In sift at 22
In siftMatch at 18
In imMosaic at 12
In mosaicTest at 12
'siftWin32' is not recognized as an internal or external command,
operable program or batch file.
??? Error using ==> sift at 53
Invalid keypoint file beginning.

Error in ==> siftMatch at 18
[des1, loc1] = sift(img1);

Error in ==> imMosaic at 12
[matchLoc1 matchLoc2] = siftMatch(img1, img2);

Error in ==> mosaicTest at 12
img0 = imMosaic(img2,img1,1);

Any1 know what is wrong?

Yong Zhao

May this file is just an apply of sift. the true sift alg may the siftwin32.exe with no source can learn.

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux