Clear Filters
Clear Filters

How to center an image

2 views (last 30 days)
david
david on 18 Aug 2013
hi
im new in the matlab world ..And I have a problem regarding image processing..
I have a image(matrix size: mXn)that in IJ coordinate system (origin at the upper left) and i want to center the image (that the origin will be at the center of the image - XY coordinate system)...
How can I do this? There is a matrix which I can multiply the image and the result is a centered image?
thanks
  1 Comment
dpb
dpb on 18 Aug 2013
If you're talking simply of the numbering of the pixels' location in the image, that's simply a translation of round([m|n]/2) in addressing.
Matlab stores everything in 1-based arrays so you can't actually change the addressing directly to be -m/2...0...+m/2 instead of 1...m You could write a helper function that hides the addressing manipulation, of course.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 18 Aug 2013
Use circshift() to translate the image. You need to know the number of rows and columns in the "canvass" and the number of rows and columns in the portion you want to shift, then calculate the shift amounts (in rows and columns) and then call circshift() to do the translation.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!