version 1.11.0.0 (6.84 MB) by
Dirk-Jan Kroon

non-rigid 2D and 3D image registration with demon (fluid) algorithm, extended with modality transf.

This function will perform demon registration which is an type of fast non-rigid fluid like registration between two 2D or 3D images. Registration between different (MRI) modalities is also supported, through a function which transform one image modality so it looks likes the modality of the second image.

The demon registration is described by the paper of Thirion 1998 and extended by Cachier 1999 and He Wang 2005.

Basic algorithm: On each pixel a velocity (movement) is defined with use of the intensity differences and gradient information. This velocity field is smoothed by an Gaussian, and iteratively used to transform the moving image, and register on to the static image. (Easy to understand code example in file basic_demon_example.m)

Instead of using the basic equations for the "demonregistration" function, we have rewritten it to be used by an limit memory BFGS optimizer in an iterative and multi-resolution way, with also support of diffusion regularization. (see also Tom Vercauteren et al. "Non-parametric Diffeomorphic Image..." )

Transforming one modality into the fake modality of the other image is done with use of 2D mutual histograms between regions of both images, and choosing the grey values which have the highest correlation. D. Kroon et al. "MRI Modality Transformation in Demon Registration" (MutualTransform.m)

See the screenshot for an example result.

Usage:

The functions register_images.m and register_volumes.m are easy to use, and will fit most applications.

First compile the c-code : compile_c_files.m.

Notes:

- All the mex-code is multi-threaded and is tested on both Windows and Linux.

- Please leave comments and report bugs

Dirk-Jan Kroon (2021). multimodality non-rigid demon algorithm image registration (https://www.mathworks.com/matlabcentral/fileexchange/21451-multimodality-non-rigid-demon-algorithm-image-registration), MATLAB Central File Exchange. Retrieved .

Created with
R2008a

Compatible with any release

**Inspired:**
Implicit Contour Morphing Framework

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

Start Hunting!Create scripts with code, output, and formatted text in a single executable document.

Michael WerthmannHi Dirk,

I want to use your code to register lung volumes (e.g. 512x512x200). However the functions takes a lot of time. Do you have a suggestion of how to make it applicable for my case?

Lanka Ravan@Jarmo How you solved the maximum size array error? How you modified the compile_c_files.m to include the option: '-compatibleArrayDims' where the mex compiler is called? Thank you in anticipation.

Jarmo TeuhoI also recieved a similar error e.g. "Error using squared_difference_double Requested 4294967297x6474759937 (17179869184.0GB) array exceeds maximum array size".

I was able to solve it by modifying the compile_c_files.m to include the option: '-compatibleArrayDims' where the mex compiler is called. This was tested on MATLAB2017a running on Linux using GCC 7.5.0. That also cleared out any errors during compiling.

Hopefully this helps anyone who has a similar problem.

Yhao Whitei don't know how others make the function "register_images.m" success, but i got really big error, noting"44146176.0GB is needed. Requested array exceeds maximum array size "

Jake CumberI had great success with 2D registration, but the 3D approach is challenging me. I can't find an example for it and I see other people mentioning that too. Can anyone shed some light onto the correct format for the 3D data? I have it available in .stl and also .ply and have tried using 'stlread' and 'pcread' respectively, but I get error message saying "Scale factors must be either 1D or 3D". Can anyone help?

JAEHONG HWANGdisi linvery helpful

Bart BolsterleeI also get the "Requested array exceeds maximum array size" error. I think it has something to do with my compilation. I run 64-bit Windows 7. Does anyone have suggestions on how to solve this problem?

Adrien ChauvetIt seems that Tx and Ty are swapped...

Same issue was raised by K K in 2008 (see below).

Yangeng Zhaogood

Spencer ManwellI am interested in registering 3D PET and CT images. The image size are (128,128,47) and (512,512,47) for PET and CT, respectively. While performing rigid registrations of these volume the execution hangs after the second iteration of fminlbgfs(...) [line 173 of register_volumes.m] when I treat the CT volume as static and the PET image at moving. Moreover, only a single iteration is executed by the fminlbfgs function. Treating the CT volume as moving ans the PET image as static, however, appears to execute without issue.

Has any experienced a similar issue using multi-modality registration?

XenHi. Thanks for sharing this. I compiled the files successfully, but when running the example in register_images.m, I get the error below... What is the reason? Thanks

Error using squared_difference_double

Requested 4294967297x6474759937 (17179869184.0GB) array exceeds maximum array size

preference. Creation of arrays greater than this limit may take a long time and

cause MATLAB to become unresponsive. See array size limit or preference panel for

more information.

Error in image_difference>registration_error_squared_differences (line 162)

t=squared_difference_double(double(V),double(U));

Error in image_difference (line 60)

t=registration_error_squared_differences(V,U,Mask,MaskNum);

Error in affine_registration_error>affine_registration_error_2d (line 120)

e = image_difference(I3,I2,type);

Error in affine_registration_error (line 95)

e=affine_registration_error_2d(par,I1,I2,type,mode);

Error in

register_images>@(x)affine_registration_error(x,scale,ISmoving,ISstatic,type_affine)

Error in fminlbfgs>gradient_function (line 755)

fval=funfcn(reshape(x,data.xsizes));

Error in fminlbfgs (line 160)

[data,fval,grad]=gradient_function(data.xInitial,funfcn, data, optim);

Error in register_images (line 216)

x=fminlbfgs(@(x)affine_registration_error(x,scale,ISmoving,ISstatic,type_affine),x,optim);

Kwan Long WongWhat is the reason for compiling the c files? Can't I just run the example with the .m files?

pig00Margaret von EbersHi, Matlab is displaying a segmentation fault and crashing when I try to use register_images on two example images. I have compiled the c files with no errors - confused on why this is happening.

Laurène DonatiHarvey HuThank U for providing the codes!

I've met a problem when registering two 3-d CT data, I don't know how to mend this line to fit my data:

% Velocity field smoothing kernel

Hsmooth=fspecial('gaussian',[60 60],10);

for the original code registered 2-d images, not 3-d.

Can anyone help with that? Thank U~~~

Manuel MoralesRiaz AliWhen I run this code in MATLAB, I get the following errors (although I have all the directories with default names):

Error using cd

Cannot CD to functions_nonrigid (Name is nonexistent or not a directory).

Error in compile_c_files (line 2)

cd('functions_nonrigid');

Error in basic_demon_example (line 7)

compile_c_files

Could anyone please tell the reason and solution.

Thanks.

Cong Bo Phanchenjiao jiangSANJUKTA CHATTERJEEI am trying to register 2 images, even when I am increasing the values of the regularization parameters, such as SigmaFluid and SigmaDiff, the registered image is not getting blurred. Please help

Haris JeelaniJust wanted to say thanks for making the code available online.

NitinTirtadwipa ManunggalFaiza Bukenyait is so slow. I waited for the result for 2 hours and gave up. I successfully run mex files and read in the two images. Iam using hdr images of different sizes. does the number of iterations have an effect on the result?.

Vedpal SinghHi Dirk,

After the registration, I got the registered data in N by 3 size. Actually, I want to save this N by 3 size data as a point cloud for further processing. Please let me know, how it can be possible?

Thanking You

marjan sswhat is the difference between the output of "basic_demon_example.m" and the output of "register_images.m". I get two different registered images for the same pair of input. The registered image (Ireg) which is the output of "register_images.m" makes more sense to me. Can you please explain about the output of the "basic_demon_examples.m". Thanks

gang liuWhen I ran command " manually_warp_images", I got the follow error messages:

Error using manually_warp_images>manually_warp_images_OpeningFcn (line 60)

no images set

Error in gui_mainfcn (line 221)

feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure),

varargin{:});

Error in manually_warp_images (line 38)

gui_mainfcn(gui_State, varargin{:});

How can I deal with that?

Thanks

alaa megawerplease can anyone help with this error

i'm using same modality and the size 512*512*148

Scaling resizepercentageentage : 1

Out of memory. Type HELP MEMORY for your options.

Error in fminlbfgs (line 142)

data.deltaX=zeros(data.numberOfVariables,optim.StoreN);

Error in register_volumes (line 275)

B=fminlbfgs(@(x)demons_energy(M,F,M_TF,F_TF,x,sizes,options),B,optim);

JoubinI am using your function for image registration Could you please let me know if anyone reports any error estimation and Robustness of this algorithm for image registration.

LennartVery nice functions, thanks. I was wondering how I could best register (multimodal) a single slice to a 3D volume. I have a good estimate of the affine transformation because of how the images were acquired, but the subject moved between the two acquisitions.

MichaelProblem below solved:

It turns out the problem was that I had first downloaded the packages on a Mac and then copied them onto the Windows machine. Somewhere along the line, hidden files (with the prefix ._) with the .c extension were added to the folders by the Mac, and the windows compiler was trying unsuccessfully to read them. When I redownloaded the packages on the windows machine, everything was good.

MichaelHi I am having trouble running the compile c files on a Windows 7 computers.

The error I get is the following

compiling : ._bspline_error_2d_double.c -> Default options filename found in C:\Users\Orger\AppData\Roaming\MathWorks\MATLAB\R2012a ---------------------------------------------------------------- -> Options file = C:\Users\Orger\AppData\Roaming\MathWorks\MATLAB\R2012a\mexopts.bat MATLAB = C:\Program Files\MATLAB\R2012a -> COMPILER = cl -> Compiler flags: COMPFLAGS = /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD OPTIMFLAGS = /O2 /Oy- /DNDEBUG DEBUGFLAGS = /Z7 arguments = Name switch = /Fo -> Pre-linking commands = -> LINKER = link -> Link directives: LINKFLAGS = /dll /export:mexFunction /LIBPATH:"C:\Program Files\MATLAB\R2012a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /manifest /incremental:NO /implib:"C:\Users\Orger\AppData\Local\Temp\mex_1feKKo\templib.x" /MAP:"_bspline_error_2d_double.mexw64.map" LINKDEBUGFLAGS = /debug /PDB:"_bspline_error_2d_double.mexw64.pdb" LINKFLAGSPOST = Name directive = /out:"_bspline_error_2d_double.mexw64" File link directive = Lib. link directive = Rsp file indicator = @ -> Resource Compiler = rc /fo "mexversion.res" -> Resource Linker = ----------------------------------------------------------------

--> cl /c /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /FoC:\Users\Orger\AppData\Local\Temp\mex_1feKKo\.obj -I"C:\Program Files\MATLAB\R2012a\extern\include" /O2 /Oy- /DNDEBUG -DMX_COMPAT_32 ._bspline_error_2d_double.c

._bspline_error_2d_double.c ._bspline_error_2d_double.c : warning C4821: Unable to determine Unicode encoding type, please save the file with signature (BOM) ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x5' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x16' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x7' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x2' ._bspline_error_2d_double.c(1) : error C2061: syntax error : identifier 'OS' ._bspline_error_2d_double.c(1) : error C2059: syntax error : ';' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x2' ._bspline_error_2d_double.c(1) : error C2143: syntax error : missing '{' before 'constant' ._bspline_error_2d_double.c(1) : error C2059: syntax error : '<Unknown>' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0xe' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x2' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0xe' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1e' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0xe' ._bspline_error_2d_double.c(1) : error C2061: syntax error : identifier 'É~9' ._bspline_error_2d_double.c(1) : error C2059: syntax error : ';' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x15' ._bspline_error_2d_double.c(1) : error C2061: syntax error : identifier 'com' ._bspline_error_2d_double.c(1) : error C2059: syntax error : ';' ._bspline_error_2d_double.c(1) : error C2059: syntax error : '.' ._bspline_error_2d_double.c(1) : error C2021: expected exponent value, not 'b' ._bspline_error_2d_double.c(1) : error C2059: syntax error : 'bad suffix on number' ._bspline_error_2d_double.c(1) : error C2059: syntax error : 'constant' ._bspline_error_2d_double.c(1) : error C2143: syntax error : missing '{' before '-' ._bspline_error_2d_double.c(1) : error C2059: syntax error : '-' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1e' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1e' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1c' ._bspline_error_2d_double.c(1) : error C2018: unknown character '0x1e'

C:\PROGRA~1\MATLAB\R2012A\BIN\MEX.PL: Error: Compile of '._bspline_error_2d_double.c' failed.

I have tried using Matlab R2012A with Microsoft SDK as the compiler, and I also tried on another computer R2010A using Visual C++ 2010 Express and got the same error. I also tried adding a BOM to the file bspline_error_2d_double.c which didn't seem to fix the problem (maybe it is another file that needs a BOM?).

Thank you to anyone who can help. This is quite frustrating, and I have not been able to find anyone with a similar problem by googling.

Andy AThanks, generally works well but there seems to be a problem with the shear components. I made the change suggested by Ryan Wu in my copy of register_images.m and this seems to fix it.

(M=make_transformation_matrix(x(1:2),x(3),x(4:5),x(6:7));

PDraperThe 3D registration doesn't work for me with sample 250x250x200 images... any reason why? This would be a fantastic aid otherwise.

henry wangTo clarify, got this working for 2D, but for 3D modifying affine_error_3d_double.c but it doesn't work for 3D case.

I have 2 images, IM1, IM2. IM2 is a filled with value of 70s over a ROI and 0s elsewhere. I want to register IM1 with IM2 such that the MSE is minimized over the region where IM2 has value of 70s. Using rigid transformation.

Is this possible to do? This is not a direct image registration problem because IM1 and IM2 are not really same image. I want to find transformation such that sum(IM2(T*x)-IM1(x))^2 is minimized where IM2(T*x)=70. I tried to modify squared_difference_double.c:

if (I2[i]!=0) { // added if statement

ierror+=(I1[i]-I2[i])*(I1[i]-I2[i]);

}

this doesn't seem to work. Please advise.

henry wangI have 2 images, IM1, IM2. IM2 is a filled with value of 70s over a ROI and 0s elsewhere. I want to register IM1 with IM2 such that the MSE is minimized over the region where IM2 has value of 70s. Using rigid transformation.

Is this possible to do? This is not a direct image registration problem because IM1 and IM2 are not really same image. I want to find transformation such that sum(IM2(T*x)-IM1(x))^2 is minimized where IM2(T*x)=70. I tried to modify squared_difference_double.c:

if (I2[i]!=0) { // added if statement

ierror+=(I1[i]-I2[i])*(I1[i]-I2[i]);

}

this doesn't seem to work. Please advise.

henry wangGreat work!

Question: is there any way to display how much an image was say rotated or shifted for a rigid transformation? Say I rotate an image by 15 degrees, imregister will output Ireg but how do I output this 15 degrees? Bx,By,Fx,Fy seems not to give this information. Thanks so much.

Ryan WuI found a possible bug in register_images.m

In following line which makes the transformation matrix of Affine:

M=make_transformation_matrix(x(1:2),x(3),x(4:5));

The shearing operation was not passed to the function. The correct one should be:

M=make_transformation_matrix(x(1:2),x(3),x(4:5),x(6:7));

Ryan WuThe error "Undefined function or method 'movepixels' for input arguments of type 'double'." was originated from the path settings.

I added the following three lines to after 'compile_c_files' in basic_demon_example.m and the problem is solved.

addpath([pwd '\functions']);

addpath([pwd '\functions_affine']);

addpath([pwd '\functions_nonrigid']);

Michele Noccioli de SouzawenfeiHello!Problem:when mexxing,there is an error:

C:\PROGRA~1\MATLAB\R2009B\BIN\MEX.PL: Error: Link of 'movepixels_2d_double.mexw32' failed.

??? Error using ==> mex at 221

Unable to complete successfully.

Error in ==> compile_c_files at 8

mex(filename,'image_interpolation.c');

I need your help!Thanks very much!

David FosterGreat routines, but to avoid instability with some images, is it possible to extend Options.Registration to include (1) only Translation and (2) only Translation and Resize (in x and y directions)?

Shan ChenProblem: when running the basic_demon_example, there is an error:

??? Index exceeds matrix dimensions.

Error in ==> movepixels at 27

I3=movepixels_2d_double(double(I1),double(T(:,:,1)),double(T(:,:,2)),double(mode));

Error in ==> basic_demon_example at 51

M=movepixels(I1,Tx,Ty);

Solution:

the 51th line in basic_demon_example.m:

M=movepixels(I1,Tx,Ty);

should be changed as follows:

T(:,:,1)=Tx;

T(:,:,2)=Ty;

M=movepixels(I1,T);

since the imput parameters didn't match properly.

Anafan,

How do you managed the 'out of memory' problem? I tried to run the program in a 64byte OS, memory 3G , the size of Moving image and Static Image are both 512*512*56 and the Matlab is 64bits.

Thank you in advance.

SylvainThanks for your really good job!

I completed the test at line 161 of register_image.m, because I had 2 images 102x254 and 101x255 that need the resize step :

if(sum(abs(size(Istatic)-size(Imoving)))~=0)

instead of

if(sum(size(Istatic)-size(Imoving))~=0)

HengHi. I'm using your program to register MRI T1 and T2 images. I used [Ireg,Bx,By] = register_images(Imoving,Istatic);

it ran well at first, then it gave me "Undefined function or variable "resizepercentage".

Error in register_images (line 323)

if(resizepercentage~=1)"

this error.

Could you tell me what is wrong?

Thanks.

yang liuSorry,it's my fault. With the step of "Set Path", the program run normally.

Thank you for excellent job.

yang liu??? Undefined function or method 'movepixels' for input arguments of type 'double'.

Error in ==> basic_demon_example at 50

M=movepixels(I1,Tx,Ty);

Error in ==> run at 57

evalin('caller', [s ';']);

After compling, above error was presented. Did I make some mistake?

LucafanThank you!

so it must use a 1920M continuous memory space to create a huge array, I think ihis is the reason of "out of memory".

I tested you 3D Affine registration, but the registered Image(Ireg) is just identical to the Imoving image, and the deformation field Fx,Fy,Fz is all zeros. is there any mistake in your program?

Dirk-Jan Kroon*fan,

When you optimize with the quasi newton method, you need memory space for 10 x the amount of unknowns.

In your case 256 * 256 * 128 * 3 (x y z) *10 = 251 658 240 values in the Estimated Hessian, and to store the transformation fields of x,y,z and both images 256 * 256 * 128 * 5 = 41 943 040 values.

In total you store 293 601 280 values, if all those values are in double we have to store 8x this amount in bytes, is 2.2GB ...

Thus be sure to also use Matlab 64bit ..

fanI tried to do 3D nonrigid registration use this program, but I found that it use very large of memory. I tried to run the program in a 64byte OS, memory is 3G , the size of Moving image and Static Image are both 256*256*128. but it run to "out of memory". I found that there a very large of memory not released, I don't know how much memory it should use,so you should do much more in memory management.

fanso, I think that it can be use less memory if you break the large arry into many little arrays.

arghavanHi Dirk

i have 3d( face ) laser scan database .

by registration i want to establish correspondenc for all points of the face, in order to after

bringing them into correspondence linear combinations of scans,are again faces. Could you please make good examples for 3D nonrigid registration which demonstrate how to set parameters for registration? thanks, arghavan.

Cheng LuWhat a perfect work~~~ I try it and foud that the gradient of the image is calculated as [My,Mx]=gradient(M); But why you want to inverse the x and y? Since normally we use [Mx,My]=gradient(M); Maybe it is related to your 'Movepixels' function?

Your implemntation is based on the additive Demons, do you have any idea to add a compositive Demons? How do we calculate the composition of fields in Matlab? Thanks.

sajanhi Dirk,

Ive been using demon's off late. Had a question on the forward and backward transformation functions and its use in conjuction with movepixels.m . Here is what I have: A deformation map (D) derived by registering a moving object (M) to a static object (S). I would now like to use D^-1 and M and solve for S.

Ive tried using movepixels.m and the bacward2forward.m, but as I see it, movepixels.m only considers static images as its inputs, which is not what I desire. Your comments and suggestions on this would be highly appreciated.

Thanks

Dirk-Jan Kroon*emilie

The functionmovepixels.m is present in the sub-folder functions_nonrigid. To make 3D work, you have to run compile_c_files ..., or compile the c-code with the mex function.

emilieThe file ''movepixels.m'' does not exist in the zipped folder that I downloaded. So, I searched it in the net but the version that I found does not fit to the existing 3D image registration :(

Can you please tell me where I can find the 3D version of the file ''movepixels.m''.

Thanks.

yang xiaomeigood job.thanks.

I want to try the example in the demons energy,but there is an erro message for the fminsd,I can not find the information of fminsd. look forward to receiving your reply.thanks

xiaomei

Dirk-Jan Kroon*Vijay

Denoising the data before registration is not really needed, but when done with an edge preserving filter, it will slightly improve the final results.

VijayThis is an excellent algorithm... I have a quick question. Is this algorithm affected by noise in the image? Will it make sense to denoise image before doing image registration?

Thanks,

VIjay

ToniJust a quick question please!

So the pixel value from the moving image is transformed into the deformed moving one and the new position is e.g. x + Tx(x) , y + Ty(y), right? Does this mean that the old image is just updated with these values? what happens to the old pixel values where the pixel was transformed from and is the 'transformed to' pixel value the new value + the old one which was there already? And where does the interpolation take place?

Too much confusion....

LI guangsorry i made a mistake .The result in multi-registration is also good

LI guangI ran the example of multi-registration.but the result is not correct.The pixels of floating image turned to be choas when I ran that multi-registration.So is there something wrong about the multi-registration codes?

Yin YangHello, I know it may be a stupid, but I would like to find a function which could compute a pixel say, (x1, y1) in the moving image 's location in the static image, say (x2, y2). It seems to me that the (x1, y1) and (x2, y2) are related through the so-called transformation . Could you explain the detailed relationship among them and what exactly the direction of x, y and z in your code? (from left to right, up to down and top tp buttom?) Thanks

Rob Campbelloops, two ratings. But I do like the program!

Rob CampbellRob CampbellDirk-Jan Kroon*gx,

The equation "bins=round(numel(V)^(1/ndims(V)));" is not from literature. You can also use a fix bin size of 255, or so.

- Mutual information only works if there are overlaps in the histogram bins.

- More histogram bins will give better registration accuracy.

Thus this equation gives a good trade-off based on the number of available pixels ...

gxI meant how the equation "bins=round(numel(V)^(1/ndims(V)));" is obtained? Is it based on some existing publication?

gxGood work. Thank you.

One question: When you determine the bin size in function "registration_error_mutual_info", you use:

bins=round(numel(V)^(1/ndims(V)));

May I know what this formulation is obtained?

AdeolaHi Sir, your work is very good & relevant. Im still a beginner in Matlab environment. Im working on a project that is related to your work. I tried running the codes but for the basic_demon_example, it gave me an error message at line 50, that is, [M=movepixels(I1,Tx,Ty);]. Can you pls help me? Hoping to hear from you soonest.

jichao zhaoHi, Sir, your codes are definitely good. When I use your 3D example in register_volumes, the results shown by showcs3

looks weird. Also the values range from -0.2 to 0.3 for example.

Can you explain why it. On the other hand, when I used Ireg2=movepixels(Istatic,Fx,Fy,Fz); showcs3(Ireg2);

Ireg2, however, turns out to be surprising good. thanks.

jichao zhaoCould you please make good examples for 3D rigid and nonrigid registration which demonstrate how to set parameters for registration? thanks, jichao

GeoffCheng Lugood job!

Alper YamanCan you add single thread codes of the latest version. I am using linux and it gives error.

In addition, as using in linux, compilation of mex files gives error just because of the comment lines. You can avoid such errors by replacing "//" with "/*" and of course add "*/" at the end of the line.

nor kiworks pretty fine!

Dirk-Jan Kroon*yichen fan

I have never seen this error.

Please have a look at the help of Mex : http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/mex.htm

Maybee Mex or the LCC compiler is not installed with Matlab.

You can also trie the single threaded c-code files...

yichen fanHaving an error when compile the program:

??? Error using ==> mex

Unable to complete successfully

Error in ==> compile_c_files at 4

mex(files(i).name,'-v');

Error in ==> basic_demon_example at 7

compile_c_files

Is that a common error?

I am using Matlab ver 7.1.0.246(R14) SP3

Dirk-Jan Kroon*Michel Kocher...

After this weekend i will add a (previous) single threaded version, which works with the Mac computer.

Michel KocherHello, I am using Matlab from a Mac and the files system.h and process.h do not seem to be available. How can I compile movepixels_2d_double.c

Dirk-Jan KroonPlease upgrade to version 10b if you experience Matlab crashes with affine transformation in version 10.

Assaf cohenWill this be good to register a degraded image due to Atmospheric Turbulence to a reference frame (avarage of say 10 degraded images) and this how to improve the quality of the video?

Dirk-Jan Kroon*K K,

Thanks for your comments. The method uses backward warping. Today, I will look at my code if I accidentally swapped Tx and Ty. This week or the next I will upload a new version, which can be used with any Matlab optimizer.

* Franz Rudolf

This transformation algorithm is called: non-parametric, iconic feature based, using point features.

K KIt seems that the Tx and Ty are indeed swapped???

I have tried the code on a very simple line registration, the "registered image" is correct, however, Tx and Ty seem being swapped...

K KI test the code by adding the following:

% Register image 1 to image 2

[I3,Tx,Ty]=demonregistration(I1,I2,[],true);

[h,w] = size(Tx) ;

Ty = zeros(h,w) ;

Tx = 5*ones(h,w) ;

I3=movepixels(I1,Tx,Ty);

but the result is not what I expected.

The image is shifted up instead of left~~~

Indeed what is Tx,Ty doing? is it a deformation field? forward or backward warping?

Franz RudolfI am a student and want to learn something about nonrigid registration techniques. Can anybody tell me which transformation model it uses (is the Thin Plate Transformation the same as the B Spline?)

K Kthanks a lot. I know what you mean. But what I mean is change the Idiff as something like this:

Idiff_color=M_color-S_color;

Idiff = Idiff_color(:,1)+Idiff_color(:,2)+Idiff_color(:,3) ; Idiff = Idiff/3 ;

where M_color is color version of M previous obtained.

Dirk-Jan Kroon* K K,

Color image registration example:

C1=im2double(imread('lena1.jpg'));

C2=im2double(imread('lena2.jpg'));

[I3,Tx,Ty]=demonregistration(rgb2gray(C1),rgb2gray(C2),[],false);

C3 = zeros(size(C1));

C3(:,:,1)=movepixels(C1(:,:,1),Tx,Ty);

C3(:,:,2)=movepixels(C1(:,:,2),Tx,Ty);

C3(:,:,3)=movepixels(C1(:,:,3),Tx,Ty);

imshow(C3,[]); title('Registered image');

K KI try to complie it with other machine, thanks. Would like to know if you have version for color image~ Thanks~

K KHi, seems it is good. But I cannot complie it..is it due to the Matlab version? I have R2006a and Matlab 6.5. both cannot complie. Thanks a lot!

Dirk-Jan KroonThere is a small bug that images with odd valued dimensions now gives an error. Will be updated tomorrow...