Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
image using

Subject: image using

From: Owais

Date: 21 Apr, 2012 12:14:07

Message: 1 of 7

when i add background image to my program, everything gets inverted, like my ball stars to bounce with the cieling rather than to floor. what error i am doing ? i am doing it by imread and imshow function.
and also how can i set the size of image to that is required?

Thank You :)

Subject: image using

From: ImageAnalyst

Date: 21 Apr, 2012 15:52:16

Message: 2 of 7

On Apr 21, 8:14 am, "Owais " <owais.ash...@live.com> wrote:
> when i add background image to my program, everything gets inverted, like my ball stars to bounce with the cieling rather than to floor. what error i am doing ? i am doing it by imread and imshow function.
> and also how can i set the size of image to that is required?
>
> Thank You :)

-----------------------------------------------------------------------------------
Try calling "cla reset" before you call imshow. That should upright
everything. One wild guess, you don't have your camera upside down do
you? Does your video look normal in other apps which use video?

To set the size, you can use
set(handlesToAxes, 'Position', [x y width height]);

Subject: image using

From: Dave Robinson

Date: 22 Apr, 2012 14:43:06

Message: 3 of 7

"Owais " <owais.ashraf@live.com> wrote in message <jmu8af$4cc$1@newscl01ah.mathworks.com>...
> when i add background image to my program, everything gets inverted, like my ball stars to bounce with the cieling rather than to floor. what error i am doing ? i am doing it by imread and imshow function.
> and also how can i set the size of image to that is required?
>
> Thank You :)

You have remembered that images label the TOP left pixel as 1,1, whereas normal cartesian coordinates would label the BOTTOM left corner of a graph/plot as 1,1, and so generating a sort of pictorial inversion?

Regards

Dave Robinson

Subject: image using

From: Owais

Date: 22 Apr, 2012 17:13:06

Message: 4 of 7

"Dave Robinson" wrote in message <jn15dp$lmn$1@newscl01ah.mathworks.com>...
> "Owais " <owais.ashraf@live.com> wrote in message <jmu8af$4cc$1@newscl01ah.mathworks.com>...
> > when i add background image to my program, everything gets inverted, like my ball stars to bounce with the cieling rather than to floor. what error i am doing ? i am doing it by imread and imshow function.
> > and also how can i set the size of image to that is required?
> >
> > Thank You :)
>
> You have remembered that images label the TOP left pixel as 1,1, whereas normal cartesian coordinates would label the BOTTOM left corner of a graph/plot as 1,1, and so generating a sort of pictorial inversion?
>
> Regards
>
> Dave Robinson

No I didn't knew about this pixel thing :/

Subject: image using

From: ImageAnalyst

Date: 22 Apr, 2012 18:19:46

Message: 5 of 7

Yeah, but imshow() and other image display routines that that into
account seamlessly. I'm still betting on the camera being upside
down. With many machine vision cameras, they are just a rectangular
block so it's not obvious what is the top and what is the bottom.

Subject: image using

From: Steven_Lord

Date: 23 Apr, 2012 14:44:10

Message: 6 of 7



"ImageAnalyst" <imageanalyst@mailinator.com> wrote in message
news:4d2a43bf-b0f9-4655-a004-96efceb84488@2g2000yqp.googlegroups.com...
> Yeah, but imshow() and other image display routines that that into
> account seamlessly.

Yes, by changing the YDir property of the axes, which would cause the effect
the OP reported.

http://www.mathworks.com/help/techdoc/ref/axes_props.html#XDir

When called in its "high level" form, IMAGE does change the YDir property.

http://www.mathworks.com/help/techdoc/ref/image.html

figure; set(gca, 'YDir', 'normal'); hold on; image(rgb)
figure; set(gca, 'YDir', 'reverse'); hold on; image(rgb)
figure; image(rgb)

> I'm still betting on the camera being upside
> down. With many machine vision cameras, they are just a rectangular
> block so it's not obvious what is the top and what is the bottom.

If the camera were upside down, the ball the OP mentioned would still be
bouncing toward the floor, but the floor would be where the ceiling should
be and vice versa. I'm guessing the OP's trying to put a background image on
the figure created by the BALLODE demo to display the bouncing ball and
somehow the YDir property isn't being set as they expect.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: image using

From: ImageAnalyst

Date: 23 Apr, 2012 14:56:14

Message: 7 of 7

Owais, did you, for some reason, change the YDIR property of your
axes, and then call "hold on", which would counteract the normal
operation of image() and imshow() and prevent them from working as
expected?

So we can check, what do you get when you say this:

currentYDirection = get(gca, 'YDir')

Tags for this Thread

No tags are associated with this thread.

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.

Contact us