Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Subpixel image shift

I want to perform a subpixel image shift. What I would like is a version of IMAQ Shift where the x and y offsets can take non-integer values, the new pixel values being calculated by interpolation. Any thoughts?
 
Thanks
0 Kudos
Message 1 of 39
(7,531 Views)
Hi Stephen,

Why do you want to move the image by non integer values? There is no function for sub pixel image shifting as if the resulting image was the same resolution it would be distorted. If you want to move it by a smaller amount than 1 pixel you could resample the image so 1 pixel represents a smaller distance.

Regards

Jon B
Applications Engineer
NIUK
0 Kudos
Message 2 of 39
(7,506 Views)

You could do a sub-pixel shift with a phase shifting FIR filter, but I can't see why you would want to.  It wouldn't improve the quality of the image, and you wouldn't really gain anything.

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 3 of 39
(7,502 Views)

I image the same field of view onto each of the four quadrants of a CCD simultaneously and wish to match them up, i.e. perform image registration, with subpixel accuracy before, for example, subtracting one image quadrant from another.

The process of interpolating to give new pixel values is clearly possible within Labview since it is used for IMAQ Rotate and IMAQ Resample, but unfortunately not in IMAQ Shift.

0 Kudos
Message 4 of 39
(7,497 Views)

Okay, I have attached a vi that will generate a filter for a +/- 1 fractional pixel shift.  You will have to generate a separate filter for your x and y shifts.  It will be faster if you apply them one at a time using IMAQ convolution.

You can combine this with IMAQ shift to do what you want.

Bruce
Bruce Ammons
Ammons Engineering
Message 5 of 39
(7,491 Views)

Hi Bruce and others -

 

I want to revisit this topic.  In other discussion forum topics, subpixel pattern matching and the use of the centroid function for subpixel accuracy have been discussed.  The lack of floating point input for IMAQ Shift function has also been discussed.

 

Since the centroid function outputs shifts with 2-decimal point accuracy, I also want to use the outputs of the centroid function applied to two images (one being a reference image) to shift one of the images so that it aligns with the reference image.  Using whole pixel values as required by the IMAQ Shift function results in problems.  I know I need the subpixel accuracy.

 

Is there a way to effectively accomplish this using Vision given that the IMAQ Shift function only has integer shift inputs?

 

For now, I am using NINT fx to get me as close as I can.

 

centroid-alignment.JPG

 

Sincerely,

 

Don

0 Kudos
Message 6 of 39
(6,650 Views)

Don,

 

Same answer as before.  Use the subpixel shift filter program I posted earlier - that will take care of the decimal portion of the shift.  Then use IMAQ Shift to do the integer part.  (or reverse the order - doesn't really matter).

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 7 of 39
(6,648 Views)

The block diagram was locked (at least when I tried to open in LabVIEW 2010).

 

Can you share the code?

 

Sincerely,

 

Don

0 Kudos
Message 8 of 39
(6,646 Views)

Bruce - also, it is not clear to me what to do with the filter output which is a 1-d array.

 

IMAQ Convolute expects a 2-d array for the Kernel.

 

Can you clarify further?

 

Sincerely,

 

Don

0 Kudos
Message 9 of 39
(6,644 Views)

Don,

 

It took a bit of engineering to come up with the contents of the filter generator, so I don't intend to share it at this time.  For now, just use it and enjoy it.

 

The output of the filter vi is a 1D array.  Make it a 2D array using Build Array.  If it is the vertical shift, use Transpose Array.  Use IMAQ Convolute to shift the image.  Repeat for the other axis.

 

You could do it in one step by generating the X and Y shift arrays, then using cross product to generate a 2D array.  It might take a little experimenting to get the right 2D array.  The convolution might be a little slower, too.

 

Experiment with different values and compare the before and after.  You should be able to figure out what direction it moves for a given sign.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 10 of 39
(6,635 Views)