jeff
jeff

Reputation: 13673

MATLAB image() is rotated after hold on

I'm printing an image like this :

img = imread('path/to/image.jpg');
image(img);

this is fine, but when I do

img = imread('path/to/image.jpg');
hold on;
image(img);

image is rotated 180 degrees. Any ideas why, and how to fix this ?

Why am I doing hold on ? Because I'm trying to draw something else on the picture.

Thanks for any help!

The Exact Problem

Image was rotated 180 degrees around center point, and then another 180 degrees around y axis.

The Answer :

Thanks to @lennon310, I have updated my code to this :

img = imread(filename);
img = flipdim(img,1);
do_vlfeat_things(img);
hold on;
image(img);

Now it works correctly.

Upvotes: 0

Views: 359

Answers (2)

CookieMobster
CookieMobster

Reputation: 1

Display the image first, then use hold:

image(img);
hold on;

Upvotes: 0

lennon310
lennon310

Reputation: 12699

The rows of an image are stored from top to bottom, you may use

hold on,image([1 size(img,1)],[size(img,2) 1],img)

to reverse the image along y-axis.

To reverse the loaded matrix at the beginning, use (row reverse)

img1 = flipdim(img,1);

Upvotes: 1

Related Questions