Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
subpixel image translation

Subject: subpixel image translation

From: Rajesh

Date: 22 Feb, 2010 09:43:06

Message: 1 of 6

Hi,
I have a set of radiographic images of an object taken at different angles. 180images to be precise (2 deg step). I know that the center of rotation did not match with the cg of the specimen accurately and therefore i want to shift each of the images with certain pixel value which is not essentially integer but a real number. I also want the image size retained . something like circshift but it doesn't operate on real numbers :(

The Shift between image at 0 deg (image1) and that at 180 deg (image91) is 13 pixels. thus, I need a shift of 6.3 pixel for image at 0 deg(image-1),6.16 for image at 2 deg (image2) etc upto 0.14 pixel for the image at 90 deg (image 45) in one direction (say right) then same in reverse direction for image 46 to image 91. then a similar cycle for the rest 90 images.

My questions:
Is the above approach the most efficient to do what i desire?

Is there a method to shift the images by real number pixel (may be with help of linear interpolation)?

what is the use of fftshift function is it relevant in this case?

thanks.

Subject: subpixel image translation

From: ImageAnalyst

Date: 22 Feb, 2010 11:19:43

Message: 2 of 6

Try interp2().

I don't think fftshift() applies here since you're not taking the
fft. fftshift() basically puts the origin at the center of the array
instead of at the first (corner) pixel, which makes it more intuitive
for viewing the spectrum.

Subject: subpixel image translation

From: Rajesh

Date: 22 Feb, 2010 11:57:05

Message: 3 of 6

Thanks.

interp2 gives me the interpolated values but i need to shift the image which is the main problem here.

i found fftshift on 'See Also' for Circshift function thats why i queried about it.
Can the image be effectively shifted in the frequency domain?

Also, let me put this example here:
shifted_image=circshift(image1,[0,-6]);
above line is fine for me only problem is i need to shift by 6.32 pixels instead of 6. which the function doesnt allow. any other method for this?

Subject: subpixel image translation

From: ImageAnalyst

Date: 22 Feb, 2010 13:14:43

Message: 4 of 6

And can you explain why you don't think interp2 can do shifting?

Think about it some, and I think you'll come around to my way of
thinking where I know it can shift an image by fractional pixel
distances.

Subject: subpixel image translation

From: Rajesh

Date: 25 Feb, 2010 06:14:05

Message: 5 of 6

Ok i was thinking too deep to get the simple thing with this interp2 and got the answer from shalin mehta's post.
http://www.mathworks.com/matlabcentral/newsreader/view_thread/261037#720879

but again let me repeat my concerns that i have put there (excuse for beating around).

The image needs a uniform background and interp2 is disturbing it for the shifted region.
tried the conv2 as suggested by Mat in the same post but that too, a) works only for frations below 1 & b) leaves the shifted columns disturbed.

also need a faster working function since it has to handle many images in a loop.

am i asking for too much... guess not. Not sure.
thanks.

Subject: subpixel image translation

From: Matt J

Date: 25 Feb, 2010 07:02:04

Message: 6 of 6

"Rajesh " <rv_acharya@rediffmail.com> wrote in message <hm54fd$57r$1@fred.mathworks.com>...
> Ok i was thinking too deep to get the simple thing with this interp2 and got the answer from shalin mehta's post.
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/261037#720879
>
> but again let me repeat my concerns that i have put there (excuse for beating around).
>
> The image needs a uniform background and interp2 is disturbing it for the shifted region.
> tried the conv2 as suggested by Mat in the same post but that too, a) works only for frations below 1 & b) leaves the shifted columns disturbed.
=====================

As I've mentioned in the thread you've referenced, the "disruption" is probably because you are not passing an EXTRAPVAL argument to interp2().

Also, I've described how the conv2 method can be extended to shifts >1.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us