6

Based on this question Calculate Y coordinates of an image from graph point of origin I tried to do the same in app designer GUI but it does not work. I attached an image that shows that the image does not start from graph point of origin and that I get a new figure due to the set command. Any idea how to fix/do it?

Code:

function ButtonPushed(app, event)
    url='https://icons.iconarchive.com/icons/thesquid.ink/free-flat-sample/512/owl-icon.png';

    I = imread(url);
    I = rgb2gray(I);
    I=flipud(I);
    
    imshow(I,'Parent', app.imageAxes); 
    set(gca,'YDir','normal')
end

enter image description here

AsiJapan
  • 313
  • 1
  • 10

2 Answers2

6

gca creates a new figure window and a new set of axes if there are none. In particular, the app designer window is not a figure window, and so a new one is created.

But you don’t need to use gca to get a reference to your axes, since you already have the reference in app.imageAxes. This will set your axes to have a normal orientation:

set(app.imageAxes, ,'YDir', 'normal')

This should be the same as

app.imageAxes.YDir = 'normal';
Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
1

you could try to import the image data as a 2-dimensional grid, and then flipping it.. could work not sure.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 26 '21 at 20:23