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:
Saving images in high resolution...

Subject: Saving images in high resolution...

From: Neville

Date: 14 Mar, 2009 23:48:11

Message: 1 of 7

Hello all,

I had a problem with saving figures in high resolution. 'img_path.jpg' is a very large image 5633 x 8111.

X = imread('img_path.jpg');
X2 = imagesc(X);

Now, when we see X2 its a very 'zoomed' out version. Now, when i try to save this image using:-

f=getframe(gcf); imwrite(f.cdata,'j:\filename.tif','Resolution',600);

It saves the zoomed out version 'lower resolution' which is just 840x455 in dimensions..Is there anyway i can save the whole image (which is approx 5500 x 8000) back to disk?

thanks
Neville

PS:- After the line X2 = imagesc(X); i do some post processing which overlays other images on X2, that code is not relevant here.

Subject: Saving images in high resolution...

From: Chaos

Date: 15 Mar, 2009 15:26:02

Message: 2 of 7

"Neville " <ndesk1900@gmail.com> wrote in message <gphfnr$7k0$1@fred.mathworks.com>...
> Hello all,
>
> I had a problem with saving figures in high resolution. 'img_path.jpg' is a very large image 5633 x 8111.
>
> X = imread('img_path.jpg');
> X2 = imagesc(X);
>
> Now, when we see X2 its a very 'zoomed' out version. Now, when i try to save this image using:-
>
> f=getframe(gcf); imwrite(f.cdata,'j:\filename.tif','Resolution',600);
>
> It saves the zoomed out version 'lower resolution' which is just 840x455 in dimensions..Is there anyway i can save the whole image (which is approx 5500 x 8000) back to disk?
>
> thanks
> Neville
>
> PS:- After the line X2 = imagesc(X); i do some post processing which overlays other images on X2, that code is not relevant here.

you need to properly set the clims depending upon the colorspace when using imagesc.

grep imshow

Subject: Saving images in high resolution...

From: Neville

Date: 15 Mar, 2009 23:40:02

Message: 3 of 7

Hi Chaos,

I tried scaling the RGB data between [ 0 and 255 ] using clims, but yet the same result.

X = imread('img_path.jpg');
X2 = imagesc(X, [ 0 255]);
f=getframe(gcf); imwrite(f.cdata,'j:\filename.tif','Resolution',600);

I yet end up storing a smaller dimension image.

Thanks
Neville

"Chaos" <rothko.fan@gmail.com> wrote in message <gpj6m9$94d$1@fred.mathworks.com>...
> "Neville " <ndesk1900@gmail.com> wrote in message <gphfnr$7k0$1@fred.mathworks.com>...
> > Hello all,
> >
> > I had a problem with saving figures in high resolution. 'img_path.jpg' is a very large image 5633 x 8111.
> >
> > X = imread('img_path.jpg');
> > X2 = imagesc(X);
> >
> > Now, when we see X2 its a very 'zoomed' out version. Now, when i try to save this image using:-
> >
> > f=getframe(gcf); imwrite(f.cdata,'j:\filename.tif','Resolution',600);
> >
> > It saves the zoomed out version 'lower resolution' which is just 840x455 in dimensions..Is there anyway i can save the whole image (which is approx 5500 x 8000) back to disk?
> >
> > thanks
> > Neville
> >
> > PS:- After the line X2 = imagesc(X); i do some post processing which overlays other images on X2, that code is not relevant here.
>
> you need to properly set the clims depending upon the colorspace when using imagesc.
>
> grep imshow

Subject: Saving images in high resolution...

From: Peter Boettcher

Date: 16 Mar, 2009 13:52:08

Message: 4 of 7

"Neville " <ndesk1900@gmail.com> writes:

> Hello all,
>
> I had a problem with saving figures in high resolution. 'img_path.jpg'
> is a very large image 5633 x 8111.
>
> X = imread('img_path.jpg');
> X2 = imagesc(X);
>
> Now, when we see X2 its a very 'zoomed' out version. Now, when i try to save this image using:-
>
> f=getframe(gcf); imwrite(f.cdata,'j:\filename.tif','Resolution',600);
>
> It saves the zoomed out version 'lower resolution' which is just
> 840x455 in dimensions..Is there anyway i can save the whole image
> (which is approx 5500 x 8000) back to disk?
>
> thanks
> Neville
>
> PS:- After the line X2 = imagesc(X); i do some post processing which
> overlays other images on X2, that code is not relevant here.

getframe actually captures the figure data from the video card, like a
screenshot. This is one of the perennial complaints about MATLAB
graphics... off-screen graphics don't work. Annotations must be
screen-captured, etc.

If you want the same 5633 x 8111 size, you're better off figuring out
how to do the processing without needing handle graphics. For instance,
when you overlay another image, "alpha-blend" the two matrices
yourself.

out = 0.8 * image1 + 0.2 * image2;

Instead of imagesc (which scales the intensities only for display), use
imadjust or again, do it by hand.

high = max(image1(:));
low = min(image1(:));
scaled_image = (image1 - low) / (high - low)


-Peter

Subject: Saving images in high resolution...

From: Chaos

Date: 16 Mar, 2009 16:10:15

Message: 5 of 7

"Neville " <ndesk1900@gmail.com> wrote in message <gpk3ki$579$1@fred.mathworks.com>...
> Hi Chaos,
>
> I tried scaling the RGB data between [ 0 and 255 ] using clims, but yet the same result.
>
> X = imread('img_path.jpg');
> X2 = imagesc(X, [ 0 255]);
> f=getframe(gcf); imwrite(f.cdata,'j:\filename.tif','Resolution',600);
>
> I yet end up storing a smaller dimension image.
>
> Thanks
> Neville
>
> "Chaos" <rothko.fan@gmail.com> wrote in message <gpj6m9$94d$1@fred.mathworks.com>...
> > "Neville " <ndesk1900@gmail.com> wrote in message <gphfnr$7k0$1@fred.mathworks.com>...
> > > Hello all,
> > >
> > > I had a problem with saving figures in high resolution. 'img_path.jpg' is a very large image 5633 x 8111.
> > >
> > > X = imread('img_path.jpg');
> > > X2 = imagesc(X);
> > >
> > > Now, when we see X2 its a very 'zoomed' out version. Now, when i try to save this image using:-
> > >
> > > f=getframe(gcf); imwrite(f.cdata,'j:\filename.tif','Resolution',600);
> > >
> > > It saves the zoomed out version 'lower resolution' which is just 840x455 in dimensions..Is there anyway i can save the whole image (which is approx 5500 x 8000) back to disk?
> > >
> > > thanks
> > > Neville
> > >
> > > PS:- After the line X2 = imagesc(X); i do some post processing which overlays other images on X2, that code is not relevant here.
> >
> > you need to properly set the clims depending upon the colorspace when using imagesc.
> >
> > grep imshow

make sure you know what kind of data you have, uint8, uint16, use imfinfo or load it in photoshop
don't use getframe EVER, never display graphics if you don't need
NEVER use graphics, turn the 'Visibility' 'off' in the low level
NEVER use the handles

there are serious matlab bugs with java/opengl and rendering in general

write directly to file

Subject: Saving images in high resolution...

From: Yair Altman

Date: 16 Mar, 2009 17:10:14

Message: 6 of 7

"Chaos" <rothko.fan@gmail.com> wrote in message

> don't use getframe EVER, never display graphics if you don't need
> NEVER use graphics, turn the 'Visibility' 'off' in the low level
> NEVER use the handles
> there are serious matlab bugs with java/opengl and rendering in general


Care to elaborate? that's a pretty conclusive and generic statement - I'm sure many people will be interested to know details...

Yair

Subject: Saving images in high resolution...

From: ImageAnalyst

Date: 16 Mar, 2009 17:22:26

Message: 7 of 7

Yes it is a perennial complaint, ok well maybe it's actually more like
a weekly complaint. About every week someone asks the same question
and there aren't really any perfect answers. It's about time MATLAB
gave us what we've been wanting for so long. I think there may be
some file exchange submissions that take a stab at it.

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