Help with Sift Flow Algorithm - debugging the demo

2 vues (au cours des 30 derniers jours)
Steven Rudolph
Steven Rudolph le 15 Jan 2022
Commenté : Walter Roberson le 17 Jan 2022
Hello I'm trying to run the demo for this SIFT Flow code you can find here:
It takes two similar images, finds their similarities, and combines them into one essentially...
I'm getting this error when running demo.m:
Here's the full demo.m code:
im1=imread('Mars-1.jpg');
im2=imread('Mars-2.jpg');
im1=imresize(imfilter(im1,fspecial('gaussian',7,1.),'same','replicate'),0.5,'bicubic');
im2=imresize(imfilter(im2,fspecial('gaussian',7,1.),'same','replicate'),0.5,'bicubic');
im1=im2double(im1);
im2=im2double(im2);
%figure;imshow(im1);figure;imshow(im2);
cellsize=3;
gridspacing=1;
addpath(fullfile(pwd,'mexDenseSIFT'));
addpath(fullfile(pwd,'mexDiscreteFlow'));
sift1 = mexDenseSIFT(im1,cellsize,gridspacing);
sift2 = mexDenseSIFT(im2,cellsize,gridspacing);
SIFTflowpara.alpha=2*255;
SIFTflowpara.d=40*255;
SIFTflowpara.gamma=0.005*255;
SIFTflowpara.nlevels=4;
SIFTflowpara.wsize=2;
SIFTflowpara.topwsize=10;
SIFTflowpara.nTopIterations = 60;
SIFTflowpara.nIterations= 30;
tic;[vx,vy,energylist]=SIFTflowc2f(sift1,sift2,SIFTflowpara);toc
warpI2=warpImage(im2,vx,vy);
figure;imshow(im1);figure;imshow(warpI2);
% display flow
clear flow;
flow(:,:,1)=vx;
flow(:,:,2)=vy;
figure;imshow(flowToColor(flow));
return;
% this is the code doing the brute force matching
tic;[flow2,energylist2]=mexDiscreteFlow(Sift1,Sift2,[alpha,alpha*20,60,30]);toc
figure;imshow(flowToColor(flow2));
Anyway I'm assuming this is probably an easy fix, I just don't generally use MATLAB, any help or guidance much appreciated...
  5 commentaires
Steven Rudolph
Steven Rudolph le 17 Jan 2022
Thanks Walter as always for even trying to debug the issue.... I definitely understand how tedious it could be... I do understand the original code itself is over 10 years old so I know there could a lot of bugs there... Would be interested to know more about any modifications you made to fix this, and thanks again!
Walter Roberson
Walter Roberson le 17 Jan 2022
I got a clean compile for both sides, except:
  • one of the two has no mexFunction() routine and so cannot be called from MATLAB, which is a problem
  • there are functions to save and load binary images that are coded in terms of using int to hold sizes, which is not compatible with MATLAB (only supports 31 bits, whereas MATLAB supports 48 bits). I changed everything else to be compatible with MATLAB sizes, but not those routines yet, as I do not know whether compatibility with external formats is needed.

Connectez-vous pour commenter.

Réponses (2)

Steven Rudolph
Steven Rudolph le 16 Jan 2022
Just to update:
I was able to run the code in an older 2016 version of MATLAB without issue compiling the mex file... for some reason my 2021 MATLAB version wouldn't allow me to compile the C++ code leading to an error...
I suspect that my Xcode compiler isn't up to date which is causing the error in the newer version... but I'm happy with using an older version of MATLAB to get this done for now.

yanqi liu
yanqi liu le 17 Jan 2022
yes,sir,may be use vlfeat toolbox,and vl_sift to get sift points and discripters

Community Treasure Hunt

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

Start Hunting!

Translated by