Skip to main content

Re: [JAI-IMAGEIO] Rendered JPEG image not smooth

1 reply [Last post]
Anonymous

Yes this is an old topic and both Aarons and Brians suggestions refer to
what has been said before and AFIK correct.. But one thing I've not seen
discussed is:

Why is it that to get a 'properly' scaled down image we need to
operations in JAI? A low pass and scale.

I sorf of understand the philosophical issue, I guess, but one would
think that a single operation to do the scaling and averaging (low
passing) could be implemented to be much faster. Or is that not so?

On the face of it low pass (with large filter kernel) is rather slow
touching (a multiply and add) every pixel N times where N is the number
of kernetl elements..

Say you have a kernel 5 x 5 to low pass this every source pixels is the
average of neighbouring 25 pixels. Now you scale down by 5 leaving out 4
out of 5 pixels in both dimensions.
So why did we compute those left out pixels in the first place? A
smarter scale routine would just average those pixels that are actually
going to end up in the destination?.

Or I'm totally off the map here? What am I missing? IIRC I've read the
leptonica page but do remember that it would explain this...or maybe
I've just forgotten.

Would not be the first time ;-)

cheers Kusti

Kustaa Nyholm
Research Manager, Software
Research and Technology Division
PLANMECA OY
Asentajankatu 6
00880 HELSINKI
FINLAND

Please note our new telephone and fax numbers!
Tel: +358 20 7795 572 (direct)
Fax: +358 20 7795 676
GSM: +358 40 580 5193
e-mail: kustaa.nyholm@planmeca.com

This e-mail may contain confidential or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden. We will not be liable for direct,
indirect, special or consequential damages arising from alteration of
the contents of this message by a third party or as a result of any
virus being passed for viruses.

>>> Brian.Burkhalter@Sun.COM 29.6.2006 21:10 >>>

Aaron's suggestions are accurate. You are probably getting aliasing due
to not
having applied a low pass filter prior to scaling. I suggest also
reading the
following message

http://archives.java.sun.com/cgi-bin/wa?A2=ind0311&L=jai-interest&F=&S=&...

and the leptonica page to which it refers.

Brian

On Thu, 29 Jun 2006, Aaron Bruegl wrote:

> What if you use Interpolation.INTERP_BICUBIC or try
>
http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja...

> if you are scaling down greater than 50%.
>
> -Aaron
>
>
> jai-imageio@javadesktop.org wrote:
>> Hi,
>>
>> I am trying to convert a TIFF Image to JPEG.
>> Till cropping everything goes fine, but on scaling the image is not

>> rendered smooth! Edges and curves in the image look pixilated and
are not
>> smooth!
>>
>> Any piece of help or advice is greatly appreciated!
>> Thanks in advance
>>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail:
interest-help@jai-imageio.dev.java.net
>
>

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail:
interest-help@jai-imageio.dev.java.net

[att1.html]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Brian Burkhalter

Please refer to the operations "SubsampleAverage" and "FilteredSubsample".

Also, some users might like to have fine grained control over the two
separately.

Brian

On Thu, 29 Jun 2006, Kustaa Nyholm wrote:

> Yes this is an old topic and both Aarons and Brians suggestions refer to
> what has been said before and AFIK correct.. But one thing I've not seen
> discussed is:
>
> Why is it that to get a 'properly' scaled down image we need to
> operations in JAI? A low pass and scale.
>
> I sorf of understand the philosophical issue, I guess, but one would
> think that a single operation to do the scaling and averaging (low
> passing) could be implemented to be much faster. Or is that not so?
>
> On the face of it low pass (with large filter kernel) is rather slow
> touching (a multiply and add) every pixel N times where N is the number
> of kernetl elements..
>
> Say you have a kernel 5 x 5 to low pass this every source pixels is the
> average of neighbouring 25 pixels. Now you scale down by 5 leaving out 4
> out of 5 pixels in both dimensions.
> So why did we compute those left out pixels in the first place? A
> smarter scale routine would just average those pixels that are actually
> going to end up in the destination?.
>
> Or I'm totally off the map here? What am I missing? IIRC I've read the
> leptonica page but do remember that it would explain this...or maybe
> I've just forgotten.
>
> Would not be the first time ;-)
>
> cheers Kusti
>
>
> Kustaa Nyholm
> Research Manager, Software
> Research and Technology Division
> PLANMECA OY
> Asentajankatu 6
> 00880 HELSINKI
> FINLAND
>
> Please note our new telephone and fax numbers!
> Tel: +358 20 7795 572 (direct)
> Fax: +358 20 7795 676
> GSM: +358 40 580 5193
> e-mail: kustaa.nyholm@planmeca.com
>
> This e-mail may contain confidential or privileged information. If you
> are not the intended recipient (or have received this e-mail in error)
> please notify the sender immediately and destroy this e-mail. Any
> unauthorized copying, disclosure or distribution of the material in this
> e-mail is strictly forbidden. We will not be liable for direct,
> indirect, special or consequential damages arising from alteration of
> the contents of this message by a third party or as a result of any
> virus being passed for viruses.
>
>
>
>>>> Brian.Burkhalter@Sun.COM 29.6.2006 21:10 >>>
>
> Aaron's suggestions are accurate. You are probably getting aliasing due
> to not
> having applied a low pass filter prior to scaling. I suggest also
> reading the
> following message
>
> http://archives.java.sun.com/cgi-bin/wa?A2=ind0311&L=jai-interest&F=&S=&...
>
> and the leptonica page to which it refers.
>
> Brian
>
> On Thu, 29 Jun 2006, Aaron Bruegl wrote:
>
>> What if you use Interpolation.INTERP_BICUBIC or try
>>
> http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja...
>
>> if you are scaling down greater than 50%.
>>
>> -Aaron
>>
>>
>> jai-imageio@javadesktop.org wrote:
>>> Hi,
>>>
>>> I am trying to convert a TIFF Image to JPEG.
>>> Till cropping everything goes fine, but on scaling the image is not
>
>>> rendered smooth! Edges and curves in the image look pixilated and
> are not
>>> smooth!
>>>
>>> Any piece of help or advice is greatly appreciated!
>>> Thanks in advance
>>>
>>
>>
> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
> interest-unsubscribe@jai-imageio.dev.java.net
>> For additional commands, e-mail:
> interest-help@jai-imageio.dev.java.net
>>
>>
>
> ----------------
> Brian Burkhalter
> Java Media, Imaging, and Graphics
> Sun Microsystems, Inc.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> This email message is for the sole use of the intended recipient(s)
> and may contain confidential and privileged information. Any
> unauthorized review, use, disclosure or distribution is prohibited.
> If you are not the intended recipient, please contact the sender by
> reply email and destroy all copies of the original message.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
> For additional commands, e-mail:
> interest-help@jai-imageio.dev.java.net
>
>
>

----------------
Brian Burkhalter
Java Media, Imaging, and Graphics
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net