Code covered by the BSD License  

Highlights from
Automatic Image Registration using (Normalized) Mutual Information for users of IP toolbox

4.13333

4.1 | 17 ratings Rate this file 91 Downloads (last 30 days) File Size: 3.63 KB File ID: #4145

Automatic Image Registration using (Normalized) Mutual Information for users of IP toolbox

by Kateryna Artyushkova

 

13 Nov 2003 (Updated 12 Jun 2006)

Rigid (translation and rotation) automatic registration of images using normalized mutual informati

| Watch this File

File Information
Description

Functions for aligning images by rotation and translation: image_registr_MI.m
MI2 - calculating Mutual information
joint_h - calculating Joint histogram

Mutual information is calculated using joint histogram calculation between two images.

For each angle of rotation all translation parameters are checked.

NOTE - the images must have correct relative sizes with respect to each other (no resizing is incorporated in this registration)

NOTE: image1 should be smaller that image2

Function allows to crop part of the image for registration to save computational time using IMCROP function.

For more help type:
help image_registr_MI.m

For users without IP toolbox download file im_reg_mi.zip without
% cropping option and with different rotation function

Please e-mail if you have problems!

Acknowledgements

This file inspired Image Registration (2 D) Using Mutual Information (Optimization Toolbox Needed) and Automatic 2d Rigid Body Image Registration.

Required Products Image Processing Toolbox
MATLAB release MATLAB 6.5 (R13)
Other requirements Might be slow for large images and precise registration. The memory in Matlab might be important.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (26)
18 Jan 2012 Amy

There is an error in joint_h. If the data class of the image is uint8, then a value higher than 255 for "image_1(i,j) + 1" is not possible. Cast both images to 'int16' before calculating the joint histogram.

12 Jan 2012 Ido  
20 Dec 2011 Rose

Shirley,

Make sure that image1 that you are entering is not larger than image2. Also, make sure you are entering monochrome images, not color.

19 Dec 2011 shirley

I faced this error when using the image_registr_MI code:

??? Undefined function or variable "h".

Error in ==> image_registr_MI at 115
[a, b] = max(h(:));% finding the max of MI and indecises

Error in ==> run at 74
evalin('caller',[script ';']);

What should i do? Thanks!

17 Oct 2009 Raymond Cheng

Thanks for your sharing, but a little bit slowly at some images.

24 Aug 2009 Yang

I used the mean function, then used those two images. I am getting errors like following:

??? Undefined function or variable "h".

Error in ==> image_registr_MI at 106
[a, b] = max(h(:));% finding the max of MI and
indecises

What's the problem here? Thank you in advance!

30 Jan 2009 2000forever dagdeviren

i need cmac(cerebellar model arithmetic computer) matlab code for fingerprint classification.can anyone help me?

11 Sep 2008 vira prakash  
12 Mar 2008 atousa torabi  
21 Dec 2007 tang bo  
21 Sep 2007 Lin Zhang

I would like to know if this image registration method can be used for template matching. The pattern template only contains an object in the input image and it is much smaller than the input image. The input image contains many other things in addition to the object contained in the template.

13 Mar 2007 Diego De Rosa

I found these functions very useful and efficient, provided that you have CPU and time!

I'm using them in "pyramidal" fashion, that is I search for the good match for increasingly bigger images, as I decrease the angle and translation step. The problem is I can select an angle range but not a shift range. I am currently trying to hack image_registr_MI.m to achieve that.

Thanks for your work - Diego

09 Jun 2006 Kelvin Wong

The mi2 function has 2 args while the calling function has 3 args. I didn't know this first time I tried with my mi2 equivalent until I swap in yours!
Maybe it's just the zip file that's outdated?

09 Jun 2006 Kelvin Wong

The crop flag is bugged. It crashed at this line:

im_matched=im_rot(I:(I+m-1),J:(J+n-1));

16 May 2006 K B

In the function MI2, the histogram is divided by its spatial size to normalize it. This does not make any sense. Note that this value is just a constant in this algorithm. The histogram should instead be divided by the total number of pixels in the image, not the number of bins in the histogram like is done by this algorithm.

20 Apr 2006 Bob Jan

Is it suitable for fingerprint Alignment problem?

12 Nov 2005 rishikesh khole

send me masseges related to cbir on my email

21 Jul 2005 Arun Prasad  
01 Sep 2004 Xiangsheng Zhu

When I registered two images(double),there were errors like this:
>> [h,im_matched, theta,I,J] = image_registr_MI(image1, image2, 0, 5, 1);
Warning: Integer operands are required for colon operator when used as index.
> In F:\Matlab\MATLAB´úÂë\ImageFusion\image_registr_MI\image_registr_MI.m at line 106
??? Index exceeds matrix dimensions.

Error in ==> F:\Matlab\MATLAB´úÂë\ImageFusion\image_registr_MI\image_registr_MI.m
On line 106 ==> im_matched=im_rot(I:(I+m-1),J:(J+n-1));

I don't know why.Please tell me about it!

15 Jul 2004 Hosang Jin

Sorry for too many explanation.
One more comment.

If you really want to register 16-bit images, you must change the image to a 8-bit image. And then you can just use the final parameters to obtain a registered image. (Using 16 bit images can give you an error, 'Out of memory.')

% example (For sure, the images are 'double' arrays.)

IM1_8bit=IM1_16bit/65535*255;
IM2_8bit=IM2_16bit/65535*255;

[h, im_matched, theta, I, J, m, n]=image_registr_MI(IM1_8bit, IM2_8bit, angle, step, crop);

IM_ROT= imrotate(IM2_16bit, theta,'bilinear');
IM2_MATCHED_16bit=IM_ROT(I:(I+m-1),J:(J+n-1));

15 Jul 2004 Hosang Jin

In order to use this code, the class of your images should be 'double'. If you use the value of 1 for your translation step, it will take to register your images forever! I recommend that you add more step as the following example. It will take within 1 min even if you have very big images. I guarantee it.

%%% example
[h, matched_image, theta, I, J, m, n]=image_registr_MI(image1, image2, [-6:3:6], 20, 0);
[h, matched_image, theta, I, J, m, n]=image_registr_MI(image1, image2, [theta-2:2:theta+2], 10, 0, I, J);
[h, matched_image, theta, I, J, m, n]=image_registr_MI(image1, image2, [theta-1:1:theta+1], 5, 0, I, J);
[h, matched_image, theta, I, J, m, n]=image_registr_MI(image1, image2, [theta-0.5:0.5:theta+0.5], 1, 0, I, J);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Of course, you have change the first line of the 'image_registr_MI.m' file to

function [h, im_matched, theta, I, J, m, n]=image_registr_MI(image1, image2, angle, step,crop);

If you wanna use 16-bit images, you must change the 12th line in the 'joint_h.m' file from 'N=256;' to 'N= 65536;' which is 2^16. I've never tried with a 16-bit image. Supposing that you try it with the correction, there might be an error. However, it is obvious that, if you know the reason why we have to change the line, you can easily correct the error.

If you have more questions or wanna get a faster code, just contact me via e-mail.

17 May 2004 Xiangsheng Zhu

Under Matlab6.1,Windows XP:

??? Error using ==> round
Function 'round' is not defined for values of class 'uint8'.

17 May 2004 Xiangsheng Zhu

It only process 8-bit images.
How can I process those 16-bit images using it?

10 Mar 2004 Nikos Apostolou

Dear Madam,I tried to register two medical images, a CT and MR slice same level, same patient but it was imposible. The registration results were not the desired. The images are both 512x512 resolution. Do I have to do something with the parameters?Any idea?

19 Feb 2004 Hosang Jin

There will be an error if you do not use 8-bit images. (There is 'N=256;' in joint_h.m) I modified the m-files and tried with uint16 (16-bit) images; but there was an error message saying 'out of memory'. Use the image files as small as possible. Overall, this is a good program to use.

18 Feb 2004 Ousmane TANIMOUNE

This program presents a very good vision of the imagery using the tools of information's theory, notably the mutual information.

Updates
19 Nov 2003

error on line 48 - tilte instead of title

18 Feb 2004

updated for users that do not have Image Processing Toolbox

25 Feb 2004

Created two separate routines - one for users with IP toolbox access and another without

01 Dec 2004

Updated for registering double, uint8 and uint16 format images;
Added an option of normalzed MI

07 Dec 2004

Updated for registering double, uint8 and uint16 format images;
Added an option of normalzed MI

12 Jun 2006

one of the files contained an error discovered by one of the users downloaded the file (see comments)

12 Jun 2006

An old file included in zip as was noticed by one of the users (see comments)

Contact us