Question

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.

Was it helpful?

Solution

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);

OTHER TIPS

Display the image first, then use hold:

image(img);
hold on;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top