why the coordinates start from 800. want it to start from 0 . and the origin point in the left down like usual.

this the code i use
%load the image called test1
rgbImage = imread('test1.JPG');
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows, columns, numberOfColorBands] = size(rgbImage);
% Display the original color image.
subplot(2, 2, 1);
imshow(rgbImage);
axis on; grid on
title('Original Color Image');

 Réponse acceptée

The funtion imshow() flips the y axis. To make the y-axis normal again.
ax = gca;
ax.YDir = 'normal';
However, your image will also flip its y direction.

6 commentaires

is there any way to keep the cordinate normal like you answer me and keep the image like it without fliping?
dpb
dpb le 11 Mar 2019
Modifié(e) : dpb le 11 Mar 2019
"without fliping?", no, not if you use imshow to display the image,
Well, there is a way to make it appear that the coordinates are from the LLH corner, but it is simply one of writing the desired coordinate value as the tick label, ignoring what the tick value itself is. When it comes time to actually do anything with the coordinates as display vis a vis what the real data coordinates are, that's going to get even more confusing methinks if you actually try to do so.
I think the he's trying to flip the y axis without flipping the image which is what your solution does, @dpb.
For example,
% original orientation
figure(1)
corn_gray = imread('corn.tif',3); %built-in matlab example
imshow(corn_gray)
axis on
% y-ax flipped but image not flipped
figure(2)
imshow(flipud(corn_gray))
axis on
ax = gca;
ax.YDir = 'normal';
Yes, I know what he wants...but sometimes we can't always have what we want and this is one of those times.
As said, you could fake it by simply writing the tick labels as the reverse or
hAx=gca;
ytk=hAx.YTick;
hAx.YTickLabel=max(ytk)-ytk;

Connectez-vous pour commenter.

Plus de réponses (1)

dpb
dpb le 11 Mar 2019
Modifié(e) : dpb le 11 Mar 2019
imshow by default uses size() of the image x- and y- dimensions +/-0.5 as the axis x- and y-limits. The data are plotted on the axes from 1:Nx and 1:Ny so If you actually make the limits to be 0, you'll have a little background area outside the actual image data.
And, it always shows images with origin at top left. You can flip the axes, but unless you also flip() the image data in the y-direction, the image will be displayed upside down.
imshow(flipud(rgbImage)) % show the image in reversed y-direction
hAx=gca; % the parent axes handle
hAx.YDir='normal'; % invert the axis to go from bottom up so is displayed right side up

2 commentaires

imshow(flipupdn(rgbImage))
should be
imshow(flipud(rgbImage))
dpb
dpb le 11 Mar 2019
Modifié(e) : dpb le 11 Mar 2019
good catch....I'll fixup the answer. I knew it "looked funny" but couldn't see just what...

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by