You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Steve Maher <st...@gmail.com> on 2011/12/14 15:01:55 UTC

Rendering quality (subsampling)

Hi,

I'm looking for a high-quality SVG renderer.  Batik's rasterizer seems to
be the best out of the three I've tried, but I need it to do better.  I've
tried all the image-rendering, shape-rendering, color-rendering hints
without much (any?) change.  I've searched the source - mainly to try to
increase any subsampling quantities - but had no luck.

I'm dealing with small circles that need to be rendered "correctly" for a
custom projector in our lab at work.

For example, for a circle of radius .5 pixels (no stroke), and centered in
the middle of a pixel (in other words, a circle touching the edges of a
pixel), the rendered pixel intensity should be roughly PI/4 times the
intensity of the circle (because the ratio of circle area to square area is
PI/4).

Also, if I rotate the circle by 45 degrees (rotation centered on corner of
pixel), there will be a 4 pixel square used to render the circle, with most
intensity split between two adjacent pixels and much less intensity split
between the other two adjacent pixels.

Batik comes close, but the intensity is high in the first case and in the
second case, the intensity is not symmetric between the adjacent pixels
(like the rotation wasn't exactly 45 degrees).

One option I am exploring is to artificially enlarge the scene, render by 1
pixel circle across, oh, 100 pixels, and then shrink the image.
 Effectively increasing the subsampling of the circle to determine pixel
intensity.  I was hoping to be able to do that natively in the Batik source
- or use some other SVG renderer.

Any tips are appreciated -

Regards,
Steve

Re: Rendering quality (subsampling)

Posted by Steve Maher <st...@gmail.com>.
Thanks for the comments Martin (and Jeremias).

I ended up going with the oversized rendering and scaling down the
resulting image.  Interestingly, that too had surprising, unwanted effects
- I was using Java 2d.  Even testing on Gimp, using high quality scaling,
the circle that overlaps four pixels evenly, when scaled down from 400 x
400 (or 100 x 100) pixels to 4 x 4 ends up with uneven intensities.  I
didn't investigate deeply but there must be some degenerate case with the
interpolation when you get down to just a few pixels.

So I wrote my own scaling software.  It considers my 400 x 400 image to be
made of 4 "superpixels" that are 100 x 100.  Then I get a single value for
each of my superpixel (taking average intensity) and get a correct 4 x 4.
 Basic supersampling.  Works well.

Steve

On Thu, Dec 22, 2011 at 4:42 AM, Martin J <ja...@gmail.com> wrote:

> FWIW, my experience is that regrettably, the HW/OS combo is key to the
> image rendering quality; I had a servlet app I developed on Mac OS X
> that produced SVG images on demand that had to be returned to the Web
> client as PNG. On the Mac, the rendering was extremely good, but when
> run on a PC/Linux server, it produced unacceptable images. In our
> case, this issue was mostly that of poor text rendering at small type
> sizes, due to bad anti-aliasing. After a lot of testing, we decided to
> get a Mac dedicated to image rendering!   YMMV.
> best
> Martin
>
> On 14 December 2011 16:01, Steve Maher <st...@gmail.com> wrote:
> > Hi,
> >
> > I'm looking for a high-quality SVG renderer.  Batik's rasterizer seems
> to be
> > the best out of the three I've tried, but I need it to do better.  I've
> > tried all the image-rendering, shape-rendering, color-rendering hints
> > without much (any?) change.  I've searched the source - mainly to try to
> > increase any subsampling quantities - but had no luck.
> >
> > I'm dealing with small circles that need to be rendered "correctly" for a
> > custom projector in our lab at work.
> >
> > For example, for a circle of radius .5 pixels (no stroke), and centered
> in
> > the middle of a pixel (in other words, a circle touching the edges of a
> > pixel), the rendered pixel intensity should be roughly PI/4 times the
> > intensity of the circle (because the ratio of circle area to square area
> is
> > PI/4).
> >
> > Also, if I rotate the circle by 45 degrees (rotation centered on corner
> of
> > pixel), there will be a 4 pixel square used to render the circle, with
> most
> > intensity split between two adjacent pixels and much less intensity split
> > between the other two adjacent pixels.
> >
> > Batik comes close, but the intensity is high in the first case and in the
> > second case, the intensity is not symmetric between the adjacent pixels
> > (like the rotation wasn't exactly 45 degrees).
> >
> > One option I am exploring is to artificially enlarge the scene, render
> by 1
> > pixel circle across, oh, 100 pixels, and then shrink the image.
>  Effectively
> > increasing the subsampling of the circle to determine pixel intensity.  I
> > was hoping to be able to do that natively in the Batik source - or use
> some
> > other SVG renderer.
> >
> > Any tips are appreciated -
> >
> > Regards,
> > Steve
> >
> >
>
>
>
> --
> From my MacBook Pro
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>

Re: Rendering quality (subsampling)

Posted by Martin J <ja...@gmail.com>.
FWIW, my experience is that regrettably, the HW/OS combo is key to the
image rendering quality; I had a servlet app I developed on Mac OS X
that produced SVG images on demand that had to be returned to the Web
client as PNG. On the Mac, the rendering was extremely good, but when
run on a PC/Linux server, it produced unacceptable images. In our
case, this issue was mostly that of poor text rendering at small type
sizes, due to bad anti-aliasing. After a lot of testing, we decided to
get a Mac dedicated to image rendering!   YMMV.
best
Martin

On 14 December 2011 16:01, Steve Maher <st...@gmail.com> wrote:
> Hi,
>
> I'm looking for a high-quality SVG renderer.  Batik's rasterizer seems to be
> the best out of the three I've tried, but I need it to do better.  I've
> tried all the image-rendering, shape-rendering, color-rendering hints
> without much (any?) change.  I've searched the source - mainly to try to
> increase any subsampling quantities - but had no luck.
>
> I'm dealing with small circles that need to be rendered "correctly" for a
> custom projector in our lab at work.
>
> For example, for a circle of radius .5 pixels (no stroke), and centered in
> the middle of a pixel (in other words, a circle touching the edges of a
> pixel), the rendered pixel intensity should be roughly PI/4 times the
> intensity of the circle (because the ratio of circle area to square area is
> PI/4).
>
> Also, if I rotate the circle by 45 degrees (rotation centered on corner of
> pixel), there will be a 4 pixel square used to render the circle, with most
> intensity split between two adjacent pixels and much less intensity split
> between the other two adjacent pixels.
>
> Batik comes close, but the intensity is high in the first case and in the
> second case, the intensity is not symmetric between the adjacent pixels
> (like the rotation wasn't exactly 45 degrees).
>
> One option I am exploring is to artificially enlarge the scene, render by 1
> pixel circle across, oh, 100 pixels, and then shrink the image.  Effectively
> increasing the subsampling of the circle to determine pixel intensity.  I
> was hoping to be able to do that natively in the Batik source - or use some
> other SVG renderer.
>
> Any tips are appreciated -
>
> Regards,
> Steve
>
>



-- 
>From my MacBook Pro

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Rendering quality (subsampling)

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
I'm not a specialist on these matters, but AFAIK Batik basically uses
the Java2D/Graphics2D infrastructure from Java which may have limitations
in this regard at least on some platforms (probably even depending on
the OS backend). Enlarging the canvas for painting and then downscaling
the resulting bitmap might actually not be the worst idea in this case.
But maybe I'm missing something.

On 14.12.2011 15:01:55 Steve Maher wrote:
> Hi,
> 
> I'm looking for a high-quality SVG renderer.  Batik's rasterizer seems to
> be the best out of the three I've tried, but I need it to do better.  I've
> tried all the image-rendering, shape-rendering, color-rendering hints
> without much (any?) change.  I've searched the source - mainly to try to
> increase any subsampling quantities - but had no luck.
> 
> I'm dealing with small circles that need to be rendered "correctly" for a
> custom projector in our lab at work.
> 
> For example, for a circle of radius .5 pixels (no stroke), and centered in
> the middle of a pixel (in other words, a circle touching the edges of a
> pixel), the rendered pixel intensity should be roughly PI/4 times the
> intensity of the circle (because the ratio of circle area to square area is
> PI/4).
> 
> Also, if I rotate the circle by 45 degrees (rotation centered on corner of
> pixel), there will be a 4 pixel square used to render the circle, with most
> intensity split between two adjacent pixels and much less intensity split
> between the other two adjacent pixels.
> 
> Batik comes close, but the intensity is high in the first case and in the
> second case, the intensity is not symmetric between the adjacent pixels
> (like the rotation wasn't exactly 45 degrees).
> 
> One option I am exploring is to artificially enlarge the scene, render by 1
> pixel circle across, oh, 100 pixels, and then shrink the image.
>  Effectively increasing the subsampling of the circle to determine pixel
> intensity.  I was hoping to be able to do that natively in the Batik source
> - or use some other SVG renderer.
> 
> Any tips are appreciated -
> 
> Regards,
> Steve




Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org