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:
fit image to screen

Subject: fit image to screen

From: Jessica

Date: 18 Jun, 2010 19:00:22

Message: 1 of 7

I am using the code:

image(A);
set(gcf,'Position',get(0,'Screensize'))%enlarge image to full screen

to have a picture appear. I want the picture to expand to the full size of the screen but also want the original dimensions of the picture to remain true to the original. When I use this script, the picture expands but it is stretched out. Thanks!

Subject: fit image to screen

From: Walter Roberson

Date: 18 Jun, 2010 19:05:11

Message: 2 of 7

Jessica wrote:
> I am using the code:
> image(A);
> set(gcf,'Position',get(0,'Screensize'))%enlarge image to full screen
>
> to have a picture appear. I want the picture to expand to the full size
> of the screen but also want the original dimensions of the picture to
> remain true to the original. When I use this script, the picture expands
> but it is stretched out. Thanks!

axis equal

Subject: fit image to screen

From: us

Date: 18 Jun, 2010 19:10:06

Message: 3 of 7

"Jessica" <jyorzinski@ucdavis.edu> wrote in message <hvgfo6$p48$1@fred.mathworks.com>...
> I am using the code:
>
> image(A);
> set(gcf,'Position',get(0,'Screensize'))%enlarge image to full screen
>
> to have a picture appear. I want the picture to expand to the full size of the screen but also want the original dimensions of the picture to remain true to the original. When I use this script, the picture expands but it is stretched out. Thanks!

one of the solutions

% set the axis's pos/size...
     imagesc(rand(10,30));
     axis image;
     set(gca,'position',[0,0,1,1],'xtick',[],'ytick',[]);
% now, set the figure's pos/size...

us

Subject: fit image to screen

From: Jessica

Date: 18 Jun, 2010 19:20:21

Message: 4 of 7

"us " <us@neurol.unizh.ch> wrote in message <hvggad$1u9$1@fred.mathworks.com>...
> "Jessica" <jyorzinski@ucdavis.edu> wrote in message <hvgfo6$p48$1@fred.mathworks.com>...
> > I am using the code:
> >
> > image(A);
> > set(gcf,'Position',get(0,'Screensize'))%enlarge image to full screen
> >
> > to have a picture appear. I want the picture to expand to the full size of the screen but also want the original dimensions of the picture to remain true to the original. When I use this script, the picture expands but it is stretched out. Thanks!
>
> one of the solutions
>
> % set the axis's pos/size...
> imagesc(rand(10,30));
> axis image;
> set(gca,'position',[0,0,1,1],'xtick',[],'ytick',[]);
> % now, set the figure's pos/size...
>
> us

Thanks for this quick response! I would like to be able to transfer the script to different computer screens without needing to adjust the code each time. So, is there a way to do this?

Subject: fit image to screen

From: us

Date: 18 Jun, 2010 19:30:05

Message: 5 of 7

"Jessica" <jyorzinski@ucdavis.edu> wrote in message <hvggtl$9tl$1@fred.mathworks.com>...
> "us " <us@neurol.unizh.ch> wrote in message <hvggad$1u9$1@fred.mathworks.com>...
> > "Jessica" <jyorzinski@ucdavis.edu> wrote in message <hvgfo6$p48$1@fred.mathworks.com>...
> > > I am using the code:
> > >
> > > image(A);
> > > set(gcf,'Position',get(0,'Screensize'))%enlarge image to full screen
> > >
> > > to have a picture appear. I want the picture to expand to the full size of the screen but also want the original dimensions of the picture to remain true to the original. When I use this script, the picture expands but it is stretched out. Thanks!
> >
> > one of the solutions
> >
> > % set the axis's pos/size...
> > imagesc(rand(10,30));
> > axis image;
> > set(gca,'position',[0,0,1,1],'xtick',[],'ytick',[]);
> > % now, set the figure's pos/size...
> >
> > us
>
> Thanks for this quick response! I would like to be able to transfer the script to different computer screens without needing to adjust the code each time. So, is there a way to do this?

well... this solution works for any screen - as long as your GCA's units are NORMALIZED, otherwise SET them...

     set(gca,'units','normalized','position',[0,0,1,1],'xtick',[],'ytick',[]);

us

Subject: fit image to screen

From: ImageAnalyst

Date: 18 Jun, 2010 20:37:06

Message: 6 of 7

On Jun 18, 3:00 pm, "Jessica" <jyorzin...@ucdavis.edu> wrote:
> I am using the code:  
>
> image(A);
> set(gcf,'Position',get(0,'Screensize'))%enlarge image to full screen
>
> to have a picture appear. I want the picture to expand to the full size of the screen but also want the original dimensions of the picture to remain true to the original. When I use this script, the picture expands but it is stretched out. Thanks!

--------------------------------------------------------------------------------------
On my screen, the image stretches (shrinks or zooms) but always by the
same amount in the x and y direction so that the aspect ratio of the
image is the same as the original, so that it doesn't looked
"stretched" in only one direction. imshow has an
'InitialMagnification' option. Try setting that to prevent any
zooming and show the image "image pixel" to "screen pixel." It sounds
like you had unequal magnification in the x and y direction - I'm not
sure why (since it doesn't happen for me) but maybe setting
'InitialMagnification' to 100 would fix your problem.

By the way, if your screen resolution is not the same as on some other
computer, (for example one computer was 1920 by 1200 and the other was
1600 by 1200) the image may look stretched in one direction as
compared to that other computer.

Subject: fit image to screen

From: Jessica

Date: 19 Jun, 2010 03:49:05

Message: 7 of 7

Thanks for all these tips-- they were really helpful!

Tags for 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