I'm working on image denoising problem and I have develop an optimization algorithm in Matlab for this prupose. The images are in a 256 grey level scale so mathematically what I have is a map from the unit square into the reals. In order to numerically solve this problem I have divided the unit square into $n^{2}$ pixels and assume the grey value (the value of the function) to be constant in each pixel.

This isn't what we all known as an image, that roughly speaking is the projection of the grpahic of this map giving distinct grey values for distinct values of the function, we can name this to be the $\textit{real image}$.

And here comes the problem

I'm testing the algorithm with a few simple examples that I would like to present to a non necessarily expert audience so I would like to show them the graphic of my function and the real image, both together.

What I have done so far is draw the function using a mesh, that is, I have a vector $x\in \mathbb{R}^{n^{2}}$ containing the values of the pixels ordered by columns from bottom left to top right, and I do the following


Wich leads me to the following graphics (this is just an example)

This are original, noised and two distinct recovered images

The axes are not equal but that has an easy solution that doesn't matter now.

But as I said, I want to show the image that this graphics represent, and for that I used


And what I got was this

enter image description here

As you can see, this both images doesn't match, it seems like imshow is 'looking' at my image from below, because just the 'U' is flipped.

It isn't just rotated because the reversed 'U' stills in the left.

How can I force imshow to show the image like 'looking' from above? Or are there any other Matlab command that will perform better for this?

Thanks in advance.


I leave you the code used to generate the original image just in case you want to prove something.



x= z(:);
  • $\begingroup$ You could use flipud inside your imshow call. // Unrelated: consider forcing all the 3D plots to have the same vertical scale. $\endgroup$ – Rahul Apr 10 '15 at 13:57
  • $\begingroup$ Thanks for your comment, but that doesn't work, it turns the 'U' in the right position but then it goes to the right and also turns the 'C'. I have mentioned that about the scale, this is just my little tests, so it doesn't matter because I can fix it. I will now edit the question leaving how to create the image (is really simple) just in case someone wants to give a try. $\endgroup$ – Carlos Laguillo Apr 10 '15 at 14:20
  • $\begingroup$ axis xy will set the axes to display the typical coordinate system. $\endgroup$ – AnonSubmitter85 Apr 16 '15 at 15:04

Image coordinates in MATLAB use the following convention: the center of top-left pixel is at (1,1), y-axis points down, x-axis points to the right. This is why your image looks upside down. flipud is what you need. It reflects the image vertically. Since it filps the whole image, naturally it will flip both U and C.

By the way, this question would fit better on StackOverflow proper. It is more about MATLAB programming than mathematics.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.