Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Image Registration / Alignment

Going to try to get to the crcor this week.  In the meantime, Here is an illustration of the unwrap/reslice process so you can understand it.  I have a series of slice images (think about using a knife to cut horizontally thru the body of a cylinder/tube with one of the open ends up so that you are actually cutting out circles) from X-ray computed tomography.  These slice images are used to form a volume rendering like so:

 

volume.PNG

 

Now I want to "unwrap" the volume in order to look at the whole volume in one view, and because the wall has a thickness to it, I want to look at essentially one-pixel sheets of the wall as I move from exterior diamter to interior diameter.  Here is one of those unwrapped sheets about mid-way thru the wall:

 

one unwrapped - reesliced interior sheet in the volume wall.PNG

 

You can see the circled flaws in both images, and you can see that unwrapping the image makes it easier to see everything at once (there are many more flaws as can be seen) vs. rotating the volume (which we also do - we create AVIs with rotations and zooming).

 

Don

 

0 Kudos
Message 11 of 17
(2,739 Views)

Greg -

 

I am sorry it took me so long to get back to you regarding the use of your normalized cross-correlation routine for this application.  I was tied up with other aspects of this project. 

 

Here is how I implented the code.  I believe I implemented it properly (please comment if I did not).  Don't worry about the data value references.  I am doing things in RAM so I created a data value reference for the stack of images.

 

normCrcor.PNG 

 

Here is the result of the cross-correlation routine:

 

normCrcorResult.PNG 

 

 

So we see that I get the horizontal striping with this routine as we do for the earlier shifting strategies that I tried.

 

I think the next step is to try to code up the Rigid Body Transformation from the Java code or other references.

 

NI - I would also love if you can get involved in this to create some options built into Vision for Image Registration / Alignment for image stacks.

 

Sincerely,

 

Don

 

 

0 Kudos
Message 12 of 17
(2,707 Views)

Folks - I had one unneeded portion of code in the snippet I showed in the last post so I am showing the corrected code here.  Basically, I had a subtraction from a reference point that was not needed, and really incorrect.  However, the end result using normalized cross-correlation for image registration/alignment still reveals the horizontal striping.

 

normCrcor.PNG

 

normCrcorResult.PNG

0 Kudos
Message 13 of 17
(2,701 Views)

For those of you viewing this thread, you would probably be interested in this thread as well:

 

http://forums.ni.com/t5/Machine-Vision/Subpixel-image-shift/td-p/273153/highlight/false

 

for a solution to image alignment where shift/tilt is the only issue.

 

 

Don

0 Kudos
Message 14 of 17
(2,603 Views)

Greg & All –

 

I have now successfully implemented three methods for image stack alignment with sub-pixel resolution.  For all methods, I perform a histogram matching pre-processing of the image stack. The circular edge detect method I first described gives great results for image stack from a computed tomography (CT) scan of a cylindrical object (the original object of this discussion) that might have some tilt to the image stack.  In this method, the shift is calculated by subtracting the source image circle center from the reference image circle center.

 

I then implemented the image centroid method for alignment for non-circular objects that might have some tilt to the image stack, (such as from an image stack from a computed tomography (CT) scan of an airfoil or turbine blade).  In this case, I spawn a thresholding window that allows the user to select a threshold to binarize the image, with the thresholding color outlining the object. 

 

Thresholding_window_spawned_for_centroid_alignment.PNG

 

Morphological operations are then used to fill the object so that the threshold-colored object sits within a black background.  In this method, the shift is calculated by subtracting the source image centroid from the reference image centroid. This gives great results and would work just fine on the cylindrical object as well.  Both the circular edge detect method and centroid method have front-end sub-pixel resolution (from the IMAQ functions themselves) as well as back-end sub-pixel resolution after linear fitting of the shifts and subsequent application of the fit value for each image in the stack.

 

Finally, I have implemented cross-correlation alignment method using the IMAQ Image Correlate function for an image stack that might have tilt plus some rotation in the stack.  In this case, I spawn a region extraction window to allow the user to correlate using region of an image in order to speed up the calculation.   


 Region_Selection_window_spawned_for_CrCor_alignment.PNG

 

Since my CT images can each be ~ 4000 x 4000 pixels, the regional correlation can result in orders of magnitude time saving.  I first correlate the selected region in the reference image with itself to get the reference correlation maximum and its location. 

 

code to get correlation maximum location for selected region in reference image.PNG

 

I then correlate the selected region from the reference image with the same region from each image in the stack, and subtract the maximum location from the maximum location found in the prior step.  

 

 

code to get shift between source and reference image using correlation.PNG

 

The correlation method has an input for a sub-region but when I tested this, the calculation did not seem to speed up much.  So I just used IMAQ Extract to extract the defined region from each image in the stack and correlate with the reference image defined region.

 

I have not tested a stack with rotation yet, but it worked very well on the cylinder CT stack with tilt.  I will artificially add some tilt into a CT stack at some point and test.  The IMAQ Correlate function does not provide sub-pixel resolution, but the linear fitting of the shifts and subsequent application of the fit value for each image in the stack gives very good results.  The IMAQ Correlate function has normalization built in so theoretically, one does not need to do the histogram matching of the images before doing the correlation.     I got identical results implementing histogram matching versus no histogram matching since the IMAQ Correlate function has built-in normalization.  However, I save the histogram-matched aligned stack so I still do the histogram matching. 

0 Kudos
Message 15 of 17
(2,565 Views)

...And here are examples of unwrapped/resliced images of the cylinder CT volume after aligning the CT slices with the centroid and cross-correlation methods You will note that the global striping and discontinuities shown in prior images of non-aligned or using non-sub-pixel-resolution are not apparent.

 

Using Centroid Alignment for CT slices:

unwrapped_after_centroid_alignment.PNG

 

 

Using CrCor Alignment for CT slices:

unwrapped_after_crcor_alignment.PNG

0 Kudos
Message 16 of 17
(2,559 Views)

Hey guys,

 

Im working on an Image Registration problem myself, and ran into a small problem. Admittedly I am relatively new to labview, and so my problem may be easy to solve, I may just be missing something. I am working on reconstructing ultrasound images. I know the position of each ultrasound image from the first half of my project. What I have done is converted this position into a change in position relative to the first image. I then use the IMAQ shift vi to move the subsequent images. The problem that I have been having is that the resulting images are the same resolution, and thus I am losing image data as I shift the images. It seems as though my image is essentially moving offscreen. What would be great is if I can resize the image so that all the pixels of the shifted image remain, with the new pixel values from the shift becoming zero. Does anyone know of a way to fix this problem? I hope I have explained myself correctly.

 

Thanks!

Paul

0 Kudos
Message 17 of 17
(2,491 Views)