Thread Subject: Binary images and EPS?

Subject: Binary images and EPS?

From: Christopher Hummersone

Date: 13 Jun, 2009 21:03:01

Message: 1 of 10

Hi,

I have some binary images/plots (black and white) that I wish to print to eps files for use in LaTeX. The problem is that the rendering engines (Painters and OpenGL) interpolate to greyscale, which is not desirable. The zbuffer renderer produces binary images but then the fonts also become quantised and hence look horrible! Does anyone know of an alternative method?

Thanks,

Chris

Subject: Binary images and EPS?

From: Oliver Woodford

Date: 14 Jun, 2009 21:22:01

Message: 2 of 10

"Christopher Hummersone" <wheely_chairs@hotmail.com> wrote in message <h11465$kis$1@fred.mathworks.com>...
> Hi,
>
> I have some binary images/plots (black and white) that I wish to print to eps files for use in LaTeX. The problem is that the rendering engines (Painters and OpenGL) interpolate to greyscale, which is not desirable. The zbuffer renderer produces binary images but then the fonts also become quantised and hence look horrible! Does anyone know of an alternative method?
>
> Thanks,
>
> Chris

How are you generating the plots? If they're images, make sure you use image and not pcolor.

Subject: Binary images and EPS?

From: Christopher Hummersone

Date: 14 Jun, 2009 22:25:02

Message: 3 of 10

Thanks for your reply Oliver. I am using imagesc and not pcolor to plot 2-D [logical] matrices...

Subject: Binary images and EPS?

From: Oliver Woodford

Date: 15 Jun, 2009 10:25:18

Message: 4 of 10

"Christopher Hummersone" <wheely_chairs@hotmail.com> wrote in message <h13tbu$pr6$1@fred.mathworks.com>...
> Thanks for your reply Oliver. I am using imagesc and not pcolor to plot 2-D [logical] matrices...

I can't replicate the interpolation you're seeing. Can you post a test script to generate a figure in which you see this?

Oliver

Subject: Binary images and EPS?

From: Christopher Hummersone

Date: 16 Jun, 2009 08:17:01

Message: 5 of 10

Here is an example of the code I'm using:

z = rand(10);
z(z<0.5) = 0;
z(z>=0.5) = 1;

figure;
imagesc(z)
colormap([1 1 1; 0 0 0]);
colorbar
print('-f1','-deps2','Interpolated.eps')
print('-f1','-deps2','-zbuffer','Quantised.eps')

Note that the images I'm working with are much bigger. In the interpolated version the interpolation should be quite obvious - on the colorbar and in the figure. The text looks as you would expect. In the quantized version the fonts are heavily quantized and when I load the file onto my windows machine I get aliasing problems too.

Many thanks,

Chris

Subject: Binary images and EPS?

From: Christopher Hummersone

Date: 16 Jun, 2009 08:17:01

Message: 6 of 10

Here is an example of the code I'm using:

z = rand(10);
z(z<0.5) = 0;
z(z>=0.5) = 1;

figure;
imagesc(z)
colormap([1 1 1; 0 0 0]);
colorbar
print('-f1','-deps2','Interpolated.eps')
print('-f1','-deps2','-zbuffer','Quantised.eps')

Note that the images I'm working with are much bigger. In the interpolated version the interpolation should be quite obvious - on the colorbar and in the figure. The text looks as you would expect. In the quantized version the fonts are heavily quantized and when I load the file onto my windows machine I get aliasing problems too.

Many thanks,

Chris

Subject: Binary images and EPS?

From: Oliver Woodford

Date: 16 Jun, 2009 08:44:02

Message: 7 of 10

"Christopher Hummersone" <wheely_chairs@hotmail.com> wrote in message <h17kdt$olf$1@fred.mathworks.com>...
> Here is an example of the code I'm using:
>
> z = rand(10);
> z(z<0.5) = 0;
> z(z>=0.5) = 1;
>
> figure;
> imagesc(z)
> colormap([1 1 1; 0 0 0]);
> colorbar
> print('-f1','-deps2','Interpolated.eps')
> print('-f1','-deps2','-zbuffer','Quantised.eps')
>
> Note that the images I'm working with are much bigger. In the interpolated version the interpolation should be quite obvious - on the colorbar and in the figure. The text looks as you would expect. In the quantized version the fonts are heavily quantized and when I load the file onto my windows machine I get aliasing problems too.
>
> Many thanks,
>
> Chris

Chris, on my machine using MATLAB R2007B the Interpolated.eps looks fine, with no interpolation at all, so I'm stumped. I would take a screenshot of your eps file and send it to technical support, along with the code.

Sorry I couldn't help more.
Oliver

Subject: Binary images and EPS?

From: Christopher Hummersone

Date: 16 Jun, 2009 09:04:02

Message: 8 of 10

How strange! I've tried it on two Intel MacBooks (one running R2008B on OS X 10.4 and the other running R2007A on OS X 10.5) and they both do the same thing. Thanks a lot for your time Oliver - much appreciated!

Subject: Binary images and EPS?

From: Oliver Woodford

Date: 16 Jun, 2009 11:45:03

Message: 9 of 10

"Christopher Hummersone" <wheely_chairs@hotmail.com> wrote in message <h17n62$ls9$1@fred.mathworks.com>...
> How strange! I've tried it on two Intel MacBooks (one running R2008B on OS X 10.4 and the other running R2007A on OS X 10.5) and they both do the same thing. Thanks a lot for your time Oliver - much appreciated!

I should add I'm using Windows. Perhaps it's an OS thing.
Oliver

Subject: Binary images and EPS?

From: Christopher Hummersone

Date: 18 Jun, 2009 10:41:01

Message: 10 of 10

I thought I would just post my findings for future reference. I was probably being a but dim but it turns out the interpolation is an artefact of OS X Preview - I also saw it in LaTeX through the TeXShop client because the preview is based on OS X Preview. I opened the file in Adobe Illustrator and converted to PDF and found there was no interpolation in Illustrator or Acrobat Reader. Interestingly, when I print the page though TeXShop the interpolation is gone and looks as it does in Acrobat. Another weird thing is that Matlab seems to invert the colours when exporting to EPS (although I didn't check any other formats), but only in the plot and the colour bar (i.e. not the text).

Why are the simple things never straight forward :-)

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
binary images Sprinceana 18 Jun, 2009 08:27:41
eps Sprinceana 18 Jun, 2009 08:27:41
rssFeed for this Thread

Contact us at files@mathworks.com