Hi, All,
I had the same segment fault problem. But I found after did
the following it worked:
==================================
At the bottom of the file, in function void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { },
REMOVE this line:
pTranslate = (double *)mxGetPr(prhs[2]);
We ONLY have 2 input parameters. prhs is the array of pointers to the input mxArrays. The above line read the
third parameter and caused segment faults.
After remove the line, I compiled with Open Watcom 1.9
in Matlab Version 7.8.0.347(R2009a) 32-bit edition.
It worked nicely.
My way to fix this code:
1. when input image size<256, error occurs...
you can change 256 in the for loops to nX or nY
2. when image size is too small, registration accuracy gets worse..
when image size is too small. the 256-bin histogram gets less samples. We can use less intensity bins, say, change from uint8 (0-255) to(0-80).
Running Xp 32bit the mex files in the zip does not work (Segmentation violation detected) !
I tried to compile again the .cpp with "mex mi_hpv_2d.cpp" but it seems that lcc compiler is not able to compile it. Does someone already encountered this problem ? Is there any solution, installing visual c++ compiler ? other solutions ?
In the mi_hpv function. It seems like P_A and P_B should both be created with a size of 256. I was testing some small images and would keep getting seg faults since the second to last for loop would write past the bounds of the array when the image height or width is less than 256.
In mexFunction, the following line is unnecessary and caused exceptions when I was debugging in Visual Studio 2008 since there are only 2 input parameters:
pTranslate = (double *)mxGetPr(prhs[2]);
Also, for the problems noted by Yang Shuo above, replace the first line with the code that comes after the comment, and replace the second line with:
Float = imrotate(Ref, 30, 'bilinear', 'crop');