Shifting pixel colums in an image

I have an image having pixel values in rows: 350-1000, and columns: 100-250
I want to shift these pixel values from columns 100-250 to 130-280.
which command should I use?
Thanks!

 Accepted Answer

shifted = zeros(size(original));
shifted(:, 130:280,:) = original(:,100:250,:);

3 Comments

Sorry I forgot to mention that the image is grayscale. how should I do it then? Thanks
Get rid of the final ",:" (comma colon).
Hamza Ahmed
Hamza Ahmed on 9 Sep 2014
Edited: Hamza Ahmed on 9 Sep 2014
I ended up using this: I = circshift(I, [30 30]);
Both methods do the same thing I guess. Problem solved. Thanks!

Sign in to comment.

More Answers (0)

Asked:

on 8 Sep 2014

Edited:

on 9 Sep 2014

Community Treasure Hunt

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

Start Hunting!