Thread Subject: Origin in the center of an image, +y at the top!

Subject: Origin in the center of an image, +y at the top!

From: David Doria

Date: 2 Oct, 2007 21:18:09

Message: 1 of 6

I figured out how to move the origin, using this command:

imshow(InputImage, 'XData', [-size(InputImage,2)/2
size(InputImage,2)/2], 'YData', [size(InputImage,1)/2
-size(InputImage,1)/2])

however, that FLIPS my image!! Is there a convenient way to
have (0,0) at the center of my image and have +y going up
and +x going to the right?

Thanks,

David

Subject: Origin in the center of an image, +y at the top!

From: Steven Lord

Date: 3 Oct, 2007 02:41:12

Message: 2 of 6


"David Doria" <daviddoria@gmail.com> wrote in message
news:fducih$nku$1@fred.mathworks.com...
>I figured out how to move the origin, using this command:
>
> imshow(InputImage, 'XData', [-size(InputImage,2)/2
> size(InputImage,2)/2], 'YData', [size(InputImage,1)/2
> -size(InputImage,1)/2])
>
> however, that FLIPS my image!! Is there a convenient way to
> have (0,0) at the center of my image and have +y going up
> and +x going to the right?

Set the YDir property of your axes.

http://www.mathworks.com/support/solutions/data/1-16MFFQ.html?solution=1-16MFFQ

--
Steve Lord
slord@mathworks.com


Subject: Origin in the center of an image, +y at the top!

From: David Doria

Date: 3 Oct, 2007 12:58:42

Message: 3 of 6

Hmm kind of...

If I do this:

image(InputImage, 'XData', [-size(InputImage,2)/2
size(InputImage,2)/2], 'YData', [size(InputImage,1)/2
-size(InputImage,1)/2])

set(gca, 'Ydir', 'normal');

It appears correctly (with axes labeled how i want them),
but I cant click on the image to get the coordinates, it
snaps the cursor to the top/bottom edge of the image.

If i do this (note the sign change):

image(InputImage, 'XData', [-size(InputImage,2)/2
size(InputImage,2)/2],'YData', [-size(InputImage,1)/2
size(InputImage,1)/2])

set(gca, 'Ydir', 'reverse');

the picture is the right orientation, but the y labels are
upside down from what i want, but i CAN click on the image.

Surely I am being silly... but i think i've tried all
combinations of these signs and directions and it wont seem
to workout.

Thanks

David

"Steven Lord" <slord@mathworks.com> wrote in message
<fduvg8$mmt$1@fred.mathworks.com>...
>
> "David Doria" <daviddoria@gmail.com> wrote in message
> news:fducih$nku$1@fred.mathworks.com...
> >I figured out how to move the origin, using this command:
> >
> > imshow(InputImage, 'XData', [-size(InputImage,2)/2
> > size(InputImage,2)/2], 'YData', [size(InputImage,1)/2
> > -size(InputImage,1)/2])
> >
> > however, that FLIPS my image!! Is there a convenient way to
> > have (0,0) at the center of my image and have +y going up
> > and +x going to the right?
>
> Set the YDir property of your axes.
>
>
http://www.mathworks.com/support/solutions/data/1-16MFFQ.html?solution=1-16MFFQ
>
> --
> Steve Lord
> slord@mathworks.com
>
>

Subject: Origin in the center of an image, +y at the top!

From: Dietrich Lueerssen

Date: 3 Oct, 2007 14:57:29

Message: 4 of 6

Dear David,

I think the simplest solution to your issue is the use of
the command "axis xy".

You use the command imshow to display the image, and this
sets the coordinate system in the conventional way for image
applications ("axis ij"). The origin is then in the upper
left corner.

If you add "axis on" to your code, you can see that the
coordinate system is the way you would like it to be (I assume).

Best regards,
Dietrich

"David Doria" <daviddoria@gmail.com> wrote in message
<fducih$nku$1@fred.mathworks.com>...
> I figured out how to move the origin, using this command:
>
> imshow(InputImage, 'XData', [-size(InputImage,2)/2
> size(InputImage,2)/2], 'YData', [size(InputImage,1)/2
> -size(InputImage,1)/2])
>
> however, that FLIPS my image!! Is there a convenient way to
> have (0,0) at the center of my image and have +y going up
> and +x going to the right?

Subject: Origin in the center of an image, +y at the top!

From: David Doria

Date: 3 Oct, 2007 16:39:13

Message: 5 of 6

I see, thanks! However, With:

imshow(InputImage, 'XData', [-size(InputImage,2)/2
size(InputImage,2)/2], 'YData', [size(InputImage,1)/2
-size(InputImage,1)/2])
axis xy
axis on

I still cannot click on points, it still snaps the cursor to
the top or bottom edge!! Any thoughts?

Thanks

David

"Dietrich Lueerssen" <dietrich.lueerssen@nospam.ogt.co.uk>
wrote in message <fe0akp$3nn$1@fred.mathworks.com>...
> Dear David,
>
> I think the simplest solution to your issue is the use of
> the command "axis xy".
>
> You use the command imshow to display the image, and this
> sets the coordinate system in the conventional way for image
> applications ("axis ij"). The origin is then in the upper
> left corner.
>
> If you add "axis on" to your code, you can see that the
> coordinate system is the way you would like it to be (I
assume).
>
> Best regards,
> Dietrich
>
> "David Doria" <daviddoria@gmail.com> wrote in message
> <fducih$nku$1@fred.mathworks.com>...
> > I figured out how to move the origin, using this command:
> >
> > imshow(InputImage, 'XData', [-size(InputImage,2)/2
> > size(InputImage,2)/2], 'YData', [size(InputImage,1)/2
> > -size(InputImage,1)/2])
> >
> > however, that FLIPS my image!! Is there a convenient way to
> > have (0,0) at the center of my image and have +y going up
> > and +x going to the right?
>

Subject: Origin in the center of an image, +y at the top!

From: David Doria

Date: 5 Oct, 2007 23:42:33

Message: 6 of 6

Surely someone else has had to center an image at (0,0)? !!

I'm actually quite surprised matlab makes it so annoying to
do this, maybe i am just not getting it :)

"David Doria" <daviddoria@gmail.com> wrote in message
<fe0gjh$dk9$1@fred.mathworks.com>...
> I see, thanks! However, With:
>
> imshow(InputImage, 'XData', [-size(InputImage,2)/2
> size(InputImage,2)/2], 'YData', [size(InputImage,1)/2
> -size(InputImage,1)/2])
> axis xy
> axis on
>
> I still cannot click on points, it still snaps the cursor to
> the top or bottom edge!! Any thoughts?
>
> Thanks
>
> David
>
> "Dietrich Lueerssen" <dietrich.lueerssen@nospam.ogt.co.uk>
> wrote in message <fe0akp$3nn$1@fred.mathworks.com>...
> > Dear David,
> >
> > I think the simplest solution to your issue is the use of
> > the command "axis xy".
> >
> > You use the command imshow to display the image, and this
> > sets the coordinate system in the conventional way for image
> > applications ("axis ij"). The origin is then in the upper
> > left corner.
> >
> > If you add "axis on" to your code, you can see that the
> > coordinate system is the way you would like it to be (I
> assume).
> >
> > Best regards,
> > Dietrich
> >
> > "David Doria" <daviddoria@gmail.com> wrote in message
> > <fducih$nku$1@fred.mathworks.com>...
> > > I figured out how to move the origin, using this command:
> > >
> > > imshow(InputImage, 'XData', [-size(InputImage,2)/2
> > > size(InputImage,2)/2], 'YData', [size(InputImage,1)/2
> > > -size(InputImage,1)/2])
> > >
> > > however, that FLIPS my image!! Is there a convenient
way to
> > > have (0,0) at the center of my image and have +y going up
> > > and +x going to the right?
> >
>

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
image display Dietrich Lueerssen 3 Oct, 2007 11:00:24
axis xy Dietrich Lueerssen 3 Oct, 2007 11:00:24
axis ij Dietrich Lueerssen 3 Oct, 2007 11:00:24
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com