Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Image Registration / Alignment

Hi Folks -

 

I am using ImageJ to register or align a series of X-ray Computed Tomography Images.  There is an ImageJ plugin called StackReg that does a pretty great job with several different algorithm choices to align the circular images for the cylindrical part we are doing CT on.

 

The question is, can I do the same thing in Vision.  I am currently investigating the geometric pattern matching methods but so far, even if I find a way to do something promising (right now Vision Assistant 2010 sp1 is [repeatedly] locking up when I click on 'Finish' of the template editor), it is not clear to me how I would use the 'position' info in the match cluster to perform the alignment.  It may be a simple translation in both the X and Y directions.  Plus, I need to be able to restrict the angle that the template and image can be rotated with respect to each other, and I don't see how to restrict that with either 'IMAQ Setup Learn Geometric Pattern' / IMAQ Setup Learn Geometric Pattern 2' or 'Imaq Learn Geometric Pattern' / 'Imaq Learn Geometric Pattern 2'. 

 

I put together a quick VI since I am having trouble with Vision Assistant, and I get a best match in one case with the match parameters showing an 180 deg angle.  I cannot allow that.  I am attaching this VI  (LabVIEW 2010 / Vision 2010) and also showing you here an example of two (of the 100s) of the images I need to align.

 

testimage1.png

 

 

testimage2.png

 

 

Bottom line.  Need a good way in LabVIEW / Vision to align images.  Any help is appreciated.

 

Thanks,

 

Don

0 Kudos
Message 1 of 17
(8,623 Views)

Hi Don --

 

Given that you're looking for circles, I wonder whether you've looked at the IMAQ Find Circular Edge routine? It seems to do pretty well at finding the center and radius with sub-pixel resolution. Also I can't quite see how you can have a rotation if the object is circular, so best not to even worry about that, though version 2 of this routine adds measurement of the roundness which may be useful - but I'm not sure what version of Vision that is part of.

 

Cheers ~ Greg

 

Message 2 of 17
(8,612 Views)

I use 'IMAQ Find Circles' in a later part of my software (after thresholding the image and then filling the circle using IMAQ FillHole) to help me calculate an annulus ROI.  It is possible that what you suggest may work because an output of 'IMAQ Find Circular Edge 3' is a fitted circle with center coordinates.   I will look at the best way to implement, test this, and see if it works.

 

We still need a general way in Vision to align images, since the above may work only for circles.

 

Sincerely,

 

Don

0 Kudos
Message 3 of 17
(8,601 Views)

I do have a related question.  After having found a circle, I want to programmatically draw a circular ROI on an Image (Vision Control, not external display window) by writing to the ROI property node of the Vision Control.  There are a number of 'Convert to ROI' fxs such 'IMAQ convert annulus to ROI' and 'IMAQ convert rectangle to ROI', but no convert circle to ROI.  How do I get the circles data output from either 'IMAQ Find Circles' or 'IMAQ Find Circular Edge' to the format that the ROI property node would like?

 

Thanks,

 

Don

0 Kudos
Message 4 of 17
(8,598 Views)

Until we find the missing IMAQ Vision VI 'Convert Circle to ROI' using the circles data output from the from either 'IMAQ Find Circles' or 'IMAQ Find Circular Edge' Smiley Wink,

 

I put together a workaround that goes like this:

 

1) open circle image

2) threshold image using IMAQ threshold to hilite edges (palette type should be made binary) or complete circle if it is a filled circle

3) Use IMAQ Particle Analysis to get Bounding Rect Left, Top, Right, Bottom

4) Use the bounding rectangle as inputs to the ROI Descriptor for bounding box and contours using bundle by name as below:

 

create-ROI-circle.PNG

 

And this image shows the circular ROI drawn in white on the thresholded circular image.

 

circle-ROI.PNG

0 Kudos
Message 5 of 17
(8,596 Views)

Lots of ways to align images, perhaps the most useful in general is cross-correlation.  However the CC implemented in the Vision routines is not normalized, so can't cope with variations in contrast.  I've written one for arrays which works properly, but it's going to be fairly slow for very large arrays/images.

 

Another approach might be something like mutual information, or identifying features and solving a system of equations.

0 Kudos
Message 6 of 17
(8,585 Views)

I have completed my image alignment tests using the IMAQ Shift process utilizing the change in circle center position as determined both from 'IMAQ Find Circles' (after thresholding and filling the circle) and IMAQ Find Circular Edge 2.  After doing the alignment, I perform an 'IMAQ unwrap' procedure to unwrap each cylinder between an annulus that surrounds the outer diameter of the cylinder detected by the 'Find Circular Edge 2' routine.  Then I reslice this data by extracting the rows of each image so that I can stack the rows and look at the X-ray CT cylinder data as flat unwrapped sheets from the outer diameter to the inner diameter.  Don't worry so much about understanding this but not only is it what I need to do ultimately, it provides a great test of the alignment procedure.  I have 414 images I need to align, and I set an annulus width of about 30 pixels (so that I would get 30 resliced images, or 'onion skins' of the cylinder, to view).  I also have resampled the images to make the height more realistic with respect to the width of these images.

 

Here is one of the resliced images with no alignment at all prior to unwrap / reslice:

 

Vision-no-alignment.PNG

 

In general, there will be large regional gray scale differences (see the dark area in lower right-hand corner) in the images with no alignment.  The image is otherwise pretty smooth.

 

Here is one of the resliced images with ImageJ Stackreg RigidBody alignment prior to unwrap / reslice:

 

ImageJ-alignment.PNG

 

The ImageJ Stackreg does a good job of eliminating the regional gray scale differences.

 

Here is one of the resliced images with the Vision shift alignment strategy I spoke of in the first paragraph:

 

 

 

Vision-alignment-using-shift-from-circle-center.PNG

 

The result of the Vision shift strategy for alignment seems to result in the horizontal striping, probably due to slight changes in the radius being calculated using the IMAQ Find Circular Edge routine.  Even 1 pixel changes can be catastrophic in this case.

 

 

I know all about the cross-correlation routine and I would be interested to test your normalized routine if you would like to share it.  I also think it might be worth me looking at the rigid-body and translation routines in the ImageJ Stackreg routine, and seeing if this can be done in LabVIEW.

 

 

 

Thanks,

 

Don

0 Kudos
Message 7 of 17
(8,570 Views)

 


@DonRoth wrote:

I know all about the cross-correlation routine and I would be interested to test your normalized routine if you would like to share it.  I also think it might be worth me looking at the rigid-body and translation routines in the ImageJ Stackreg routine, and seeing if this can be done in LabVIEW.


 

The link above should download the Normalized CC LLB directly.  Of course it will only give a translation, not a rotation or scaling.  The StackReg routine does look promising if you need more flexibility in your alignment.

 

I can't quite work out where your images you show are coming from, or exactly what you're trying to do, but it looks interesting!

0 Kudos
Message 8 of 17
(8,568 Views)

I would like to look at the cross-correlation, possibly today if I have time.  Can you provide me with some results of how/where you have used it and how well it has worked for you.  Does your routine output a pixel shift in either direction to accomplish best match?

 

Thanks,

 

Don

0 Kudos
Message 9 of 17
(8,556 Views)

 


@DonRoth wrote:

I would like to look at the cross-correlation, possibly today if I have time.  Can you provide me with some results of how/where you have used it and how well it has worked for you.  Does your routine output a pixel shift in either direction to accomplish best match?


 

It should output a pixel shift comparable with the built-in cross-correlation routine.  I've used it for registering multiple 2D images, much the same as you're wanting to do, and it appears to perform well!  I guess the answer is to try it and see.

0 Kudos
Message 10 of 17
(8,509 Views)