Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Subpixel image shift

Bruce -

 

I can send you the test image stack that I am playing with via file transfer this weekend.  You can extract any size subset that you want.

 

No, the IMAQ Unwrap routine is working fine.  The image set aligned either using ImageJ RegStack RigidBody and the Python script from my NASA peer gives great results when fed into the IMAQ Unwrap routine.  Just a few discontinuities (discrete bands) might be seen. Take a look at that thread I referenced earlier where I think I showed some results from ImageJ.  (I am essentially duplicating his Python code now except 1) he uses centroid function instead of circle edge detection to define his centers and 2) he has a canned python subpixel spline interpolation routine to do the shifts which I expect is the equivalent of our integer shift + filter shift.  I think my shift calculations from the circle edge detection come out very similarly to those from his centroid routine - so I think the circle edge detection routine is doing a great job).

 

The images I have displayed are single layers.  There might be, for example, 30 of those unwrapped layers going from exterior to interior separated by the CT voxel dimension.

 

I don't know what you mean by a strip, do you mean one horizontal line or one vertical line in an image?  I did a vertical line profile before I left and of course you see a lot of discontinuity because of the bands.  I did not do a horizontal line profile but I think you will see some oscillation or half-oscillation.

 

Let me know if you do want the test stack, I am happy to send it to you.....Don

0 Kudos
Message 21 of 39
(2,850 Views)

Don,

 

Yes, I would like the test image stack.  How do you want to transfer it?

 

Perhaps you could post a single image so I can play with it a little bit.

 

Looking at the image again, it looks like the horizontal rows are going to be sinusoidal in intensity.  I would think that indicates that your centers are a little bit off.

 

Does imageJ just do shifting, or does it do scaling as well?

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 22 of 39
(2,849 Views)

Don,

 

Looking at your image again, I think I know what it is.  It looks like the shift in one direction is correct, and the shift in the other direction is reversed.  My guess would be the Y direction is reversed.  You said you tried reversing both directions, but did you try reversing one direction at a time or just both simultaneously?

 

Bruce

 

 

Bruce Ammons
Ammons Engineering
0 Kudos
Message 23 of 39
(2,847 Views)
I thought about trying that, reversing x shift but not y shift, and vise-versa, but I ran out of time today. Definitely will try next. I was also going to plot the edge detection shift calculation vs. Computed shift from the curve fit to make sure I didn't screw that up.
0 Kudos
Message 24 of 39
(2,844 Views)
Ps. I am not 100% sure the actual steps on rigid body method - not sure it does any scaling.

If we need to do a stack transfer, I will get it to you via lft service we have at NASA. For a single image, see the thread I previously referred to in an earlier post. There are a few images from the test stack in that post.

But before you worry about this, let me try those other things first.
0 Kudos
Message 25 of 39
(2,843 Views)

Here are some interesting unwrapped results.  I did have my shift calculation from model-based curve fit slightly incorrect (attached wrong wire and thus offset (b from Y = mx + b) was incorrectly calculated).  I corrected it and then ran my tests again.

 

Shifts.JPG

 

 

First, here are some baseline results:

 

 

no-shift-unwrap.JPG

 

Here is the unwrapped result when aligning the slice stack directly from the Python script which shows the improvement from the original unwrapped result.

 

python-script-alignment.JPG

 

Here are the results of my attempt to duplicate the Python script in LabVIEW/Vision except using the circular edge detection routine to determine circle centers instead of python centroid routine.  The circular edge detection routine should actually give better results because it provides sub-pixel resolution whereas the python centroid routine does not.

 

 

 

 

results.JPG

 

 

 

So you can see that in any way shape or form, applying the shift corrections using my LabVIEW/Vision code results in banding and makes the image quality worse.

 

Bruce - for your weekend pleasure, I am sending you the test stack and python script via large file transfer.

 

Don

 

 

 

 

 

0 Kudos
Message 26 of 39
(2,836 Views)

One thing I forgot to mention.  I have not tried changing the search direction on the circle edge detection routine.  I do the edge search from outside to inside.  I probably should try changing from inside to outside just to see what happens.  The outside-to-inside search results gave monotonic results that appeared very good as you can see from the shift results (see my earlier plots of Shift vs. image number).

 

Also, the python script accounts for translation only which for these CT scan results is all we need to be concerned about; we observe only tilt and not rotation or scale changes.

 

Don

0 Kudos
Message 27 of 39
(2,833 Views)

Don,

 

Perhaps I wasn't clear enough.  Your integer shift is working fine, and is getting within one pixel of the desired position.  The problem is the sub-pixel part of the shift.  Your Y shift is in the wrong direction, doubling the Y sub-pixel offset instead of eliminating it.  It could the the X direction that is wrong.  One of them is correct, because you have a strip down the middle that looks correct.

 

If you aren't sure, locate the position of the centroid before doing the integer shift, then locate it before and after the sub-pixel shift.  I am pretty sure it will confirm my diagnosis.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 28 of 39
(2,828 Views)

Here are results with just fractional shift.  The default of no reversal image or reversing both sub-pixel shifts provides best results but we are still not there.  Reversing edge search direction did not help either.

 

results-just-fractional-changes.JPG

 

I am now thinking it is time to go back to using the centroid calculation rather than edge detection.

 

Don

0 Kudos
Message 29 of 39
(2,822 Views)

Don,

 

This should work fine.  I can't tell what is wrong without looking at your code.  This should not be this difficult.  For some reason you are not finding the true center of the circle.

 

Did you try finding the center before and after the sub-pixel shift?  That might shed some light on the problem.

 

I could create a program that would find the sub-pixel center of each circle and unwrap a strip from the edge of the circle.  It would be able to measure any offsets from true center and iterate until the offsets are less than a desired delta.  The only problem is it would take me time.  I can't afford to spend that much time on a program and give it away for free.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 30 of 39
(2,822 Views)