Thread Subject: Accurate rendering of figures

Subject: Accurate rendering of figures

From: Chris

Date: 28 Jul, 2011 02:37:27

Message: 1 of 11

Hi all,

I have a question regarding accurate rendering of figures in MATLAB. I am not talking about Printing, but simply about screen Rendering.

I have 2 different figures:

1. One has some simple plots and is rendered (I suppose) automatically using the "Painters" RenderMode giving vector type fonts and lines (please download here to see what I mean: http://www.sendspace.com/file/a5bn8c)

2. On the other figure I have some 'pcolor' surface plots which are rendered (automatically) using some other than "Painters" RenderMode, since the last one cannot render figures that use RGB color for patch or surface objects, according to the relevant MATLAB documentation (http://www.mathworks.com/help/techdoc/creating_plots/f3-84337.html#f3-102410). This results in a smooth surface but jagged fonts. In fact I also have problems printing this figure in a non PS (ie. PCL) printer. Please take a look at this Figure here: http://www.sendspace.com/file/29uj46

Now, what I would like to have instead, is use of vector type graphics for the fonts, axes and labels, overlaid above a bitmap representation of the surface ('pcolor') plot.

Can this be made somehow?


Cheers,
Chris

Subject: Accurate rendering of figures

From: Image Analyst

Date: 28 Jul, 2011 11:03:13

Message: 2 of 11

I never got to them - web site didn't display them and I can't see them without a bunch of extra work. Can't you make it easy for us and just post screenshots to someplace like tinypic.com?

Subject: Accurate rendering of figures

From: Oliver Woodford

Date: 28 Jul, 2011 12:58:28

Message: 3 of 11

"Chris" wrote:
> Hi all,
>
> I have a question regarding accurate rendering of figures in MATLAB. I am not talking about Printing, but simply about screen Rendering.
>
> I have 2 different figures:
>
> 1. One has some simple plots and is rendered (I suppose) automatically using the "Painters" RenderMode giving vector type fonts and lines (please download here to see what I mean: http://www.sendspace.com/file/a5bn8c)
>
> 2. On the other figure I have some 'pcolor' surface plots which are rendered (automatically) using some other than "Painters" RenderMode, since the last one cannot render figures that use RGB color for patch or surface objects, according to the relevant MATLAB documentation (http://www.mathworks.com/help/techdoc/creating_plots/f3-84337.html#f3-102410). This results in a smooth surface but jagged fonts. In fact I also have problems printing this figure in a non PS (ie. PCL) printer. Please take a look at this Figure here: http://www.sendspace.com/file/29uj46
>
> Now, what I would like to have instead, is use of vector type graphics for the fonts, axes and labels, overlaid above a bitmap representation of the surface ('pcolor') plot.
>
> Can this be made somehow?
>
>
> Cheers,
> Chris

The problem is that pcolor generates patch objects. Images generate bitmap objects, which is what you really want.

I guess you're using pcolor because you render the data at different sample points to those actually given. However, another way to achieve this is to resample your data using interp2, then display it using imagesc. That way your vector plots will have the images as bitmaps and everything else as vectors, just the way you want it.

HTH,
Oliver

Subject: Accurate rendering of figures

From: Chris

Date: 29 Jul, 2011 01:52:14

Message: 4 of 11

Hi Image Analyst,

I uploaded two magnified (300%) Print Screen shots of the Figures:
http://i924.photobucket.com/albums/ad85/corinos/AntiAliasedFonts.jpg
http://i924.photobucket.com/albums/ad85/corinos/JaggedFonts.jpg

Hope this helps.

"Image Analyst" wrote in message <j0rflg$hur$1@newscl01ah.mathworks.com>...
> I never got to them - web site didn't display them and I can't see them without a bunch of extra work. Can't you make it easy for us and just post screenshots to someplace like tinypic.com?

Subject: Accurate rendering of figures

From: Chris

Date: 29 Jul, 2011 02:01:26

Message: 5 of 11

I use pcolor (or surface or mesh) instead of image/imagesc because I need my y-axis to be Log scale, which can't be done using image (only y-ticks are changed to log scale and not the actual data).

I am rendering data at the exact sampled points, but using the 'shading interp' command and a dense colormap (ie. colormap(jet(512))...) I get a smooth colour transition.

To return to my initial question, I am looking into keeping the RGB pcolor/surface/plots as bitmap plots AND overlay on top of that vector objects for the axes titles/labels/etc... Otherwise when I print to .pdf explicitly using the 'Painters' rendered, I get great fonts rendition but unacceptable (pixelated) RGB plots. When I swap to 'OpenGL', I get better RGB plots, but fonts without Anti-Aliasing processing, that are reminiscent of the '80s era dot printing technology... ;)

Any suggestions or ideas are welcome.

Chris

"Oliver Woodford" wrote in message <j0rmdk$54l$1@newscl01ah.mathworks.com>...
> The problem is that pcolor generates patch objects. Images generate bitmap objects, which is what you really want.
>
> I guess you're using pcolor because you render the data at different sample points to those actually given. However, another way to achieve this is to resample your data using interp2, then display it using imagesc. That way your vector plots will have the images as bitmaps and everything else as vectors, just the way you want it.
>
> HTH,
> Oliver

Subject: Accurate rendering of figures

From: matt dash

Date: 29 Jul, 2011 02:11:11

Message: 6 of 11

"Chris " <chris.orinos@nal.gov.au> wrote in message <j0t49m$57a$1@newscl01ah.mathworks.com>...
> I use pcolor (or surface or mesh) instead of image/imagesc because I need my y-axis to be Log scale, which can't be done using image (only y-ticks are changed to log scale and not the actual data).
>
> I am rendering data at the exact sampled points, but using the 'shading interp' command and a dense colormap (ie. colormap(jet(512))...) I get a smooth colour transition.
>
> To return to my initial question, I am looking into keeping the RGB pcolor/surface/plots as bitmap plots AND overlay on top of that vector objects for the axes titles/labels/etc... Otherwise when I print to .pdf explicitly using the 'Painters' rendered, I get great fonts rendition but unacceptable (pixelated) RGB plots. When I swap to 'OpenGL', I get better RGB plots, but fonts without Anti-Aliasing processing, that are reminiscent of the '80s era dot printing technology... ;)
>
> Any suggestions or ideas are welcome.
>
> Chris

So you ARE talking about printing. If I understand what you're asking, it can't be done. Why not just export to a high resolution png instead of using the default resolution. Or use a 3rd party program to add the text after your print.

Subject: Accurate rendering of figures

From: Chris

Date: 29 Jul, 2011 02:58:12

Message: 7 of 11

> So you ARE talking about printing. If I understand what you're asking, it can't be done.

Why not just export to a high resolution png instead of using the default resolution. Or use a 3rd party program to add the text after your print.

Well, at the end of the day it is about exporting the figures to .pdf files or directly printing them to paper. But my point is that things are messed up from the very plotting phase and not just during the printing phase. So, what I said about using the different printing renderers has actually the same effect as setting the 'RendererMode' property of the figure.

Exporting the figure and then adding fonts in Photoshop or elsewhere could be the final solution if nothing works perfectly on its own. I would first try to find however if there is an automated way for correct rendering of the plots in the first place.

Subject: Accurate rendering of figures

From: Oliver Woodford

Date: 29 Jul, 2011 14:03:14

Message: 8 of 11

"Chris" wrote:
> I use pcolor (or surface or mesh) instead of image/imagesc because I need my y-axis to be Log scale, which can't be done using image (only y-ticks are changed to log scale and not the actual data).
>
> I am rendering data at the exact sampled points, but using the 'shading interp' command and a dense colormap (ie. colormap(jet(512))...) I get a smooth colour transition.
>
> To return to my initial question, I am looking into keeping the RGB pcolor/surface/plots as bitmap plots AND overlay on top of that vector objects for the axes titles/labels/etc... Otherwise when I print to .pdf explicitly using the 'Painters' rendered, I get great fonts rendition but unacceptable (pixelated) RGB plots. When I swap to 'OpenGL', I get better RGB plots, but fonts without Anti-Aliasing processing, that are reminiscent of the '80s era dot printing technology... ;)
>
> Any suggestions or ideas are welcome.
>
> Chris

Chris

I understand why you use pcolor (I stated as much in my previous message). I detailed how you could do what you were and still are asking. It will work and do what you want. Why ask exactly the same thing again? Why don't you try what I suggested?: Resample the data (to give you an effective log scale), display as an image, plot using imagesc, rename the tick labels. Voila!

Alternatively, take a look at this file exchange function, which should render the pcolor plot as a bitmap, and the other stuff as vector graphics:
http://www.mathworks.com/matlabcentral/fileexchange/727
I've never tried it though, so can't vouch for it.

Oliver

PS If you want a truecolor colormap on image data use imsc:
http://www.mathworks.com/matlabcentral/fileexchange/16233-sc-powerful-image-rendering

Subject: Accurate rendering of figures

From: matt dash

Date: 29 Jul, 2011 14:05:29

Message: 9 of 11

"Chris " <chris.orinos@nal.gov.au> wrote in message <j0t7k4$btl$1@newscl01ah.mathworks.com>...
> > So you ARE talking about printing. If I understand what you're asking, it can't be done.
>
> Why not just export to a high resolution png instead of using the default resolution. Or use a 3rd party program to add the text after your print.
>
> Well, at the end of the day it is about exporting the figures to .pdf files or directly printing them to paper. But my point is that things are messed up from the very plotting phase and not just during the printing phase. So, what I said about using the different printing renderers has actually the same effect as setting the 'RendererMode' property of the figure.
>
> Exporting the figure and then adding fonts in Photoshop or elsewhere could be the final solution if nothing works perfectly on its own. I would first try to find however if there is an automated way for correct rendering of the plots in the first place.


I'm still not 100% clear on what you're trying to do (or maybe why you're trying to do it) but here's some hints:

painters is the only vector based renderer. if you want vector anything (ie text), you must use painters. If you export to a pdf without using painters, you'll just get a bitmap picture stored in a pdf file, not a "real" pdf.

Unfortunately, afaik you can't control the resolution of bitmap objects that get exported using painters. So if you have a high resolution image plotted in an axes, it'll get downsampled when you export it to a pdf.

If you're ok with the low resolution, you could create your pcolor plot in one figure with the zbuffer renderer, use getframe to get a screenshot of it, then display that screenshot in an axes of a new figure that uses painters renderer and overlays all of your text on the screen shot. I think this will accomplish what you want.

Some figures just don't work as pdfs.Yours might be one of them.

Subject: Accurate rendering of figures

From: Oliver Woodford

Date: 29 Jul, 2011 15:07:14

Message: 10 of 11

"matt dash" wrote:
> Unfortunately, afaik you can't control the resolution of bitmap objects that get exported using painters. So if you have a high resolution image plotted in an axes, it'll get downsampled when you export it to a pdf.

If you export to eps then the bitmaps in the figure are exported at their original resolution. If you then convert this to a pdf in external software (e.g. ghostscript) you can keep that resolution. You can even do this in MATLAB if you export to pdf using export_fig with the -q101 option, thus keeping the full resolution of bitmaps in a pdf. This won't help Chris though, as his pcolor objects are not bitmaps but patch-based objects, which is the whole problem.

Subject: Accurate rendering of figures

From: matt dash

Date: 29 Jul, 2011 16:49:29

Message: 11 of 11

"Oliver Woodford" wrote in message <j0uib2$k5s$1@newscl01ah.mathworks.com>...
> "matt dash" wrote:
> > Unfortunately, afaik you can't control the resolution of bitmap objects that get exported using painters. So if you have a high resolution image plotted in an axes, it'll get downsampled when you export it to a pdf.
>
> If you export to eps then the bitmaps in the figure are exported at their original resolution. If you then convert this to a pdf in external software (e.g. ghostscript) you can keep that resolution. You can even do this in MATLAB if you export to pdf using export_fig with the -q101 option, thus keeping the full resolution of bitmaps in a pdf. This won't help Chris though, as his pcolor objects are not bitmaps but patch-based objects, which is the whole problem.

I stand corrected. I was thinking of the case when you export a figure to eps with a non-painters renderer, so it converts it to a bitmap. I guess I havent actually tried exporting an image object using painters.

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
figure rendering Chris 27 Jul, 2011 22:39:14
vector Chris 27 Jul, 2011 22:39:14
bitmap Chris 27 Jul, 2011 22:39:14
rgb color patch... Chris 27 Jul, 2011 22:39:14
rssFeed for this Thread

Contact us at files@mathworks.com