>Date: Tue, 4 Jan 2000 18:09:05 -0800
>From: Austin Chinn <[EMAIL PROTECTED]>
>Subject: [JAVA2D] ConvolveOp to reduce image size
>To: [EMAIL PROTECTED]
>
>I am creating an image processing program which loads in an image and writes
out different quality versions of the same image. The ultimate goal is to
reduce the image file size at the expense of some quality. Does anyone know how
to use the ConvolveOp and Kernel to accomplish this? More specifically, what is
the best Kernel config? I would use the codec JPEGEncoder.setQuality(), but I
am also writing out GIFs and my GIFEncoder does not allow me to modify the
quality. Any ideas/suggestions would be greatly appreciated.
>
Hi Austin:
GIF is a lossless format, so you can't vary quality in the way you
can with a lossy format like Jpeg. However, if your GIFEncoder
supports it, you might be able to reduce the file size by changing
the color quantization to use a smaller pallette, say a 32 color palette
instead of a 256 color palette.
I'm not sure that blurring the image will have too big an effect on
GIF file size. It would have to increase run-lengths significantly
to help much. But if you want to try it, start with a small kernel,
like 3x3. Its easiest to think about the values in one dimension
and then extend it to two dimensions.
You might start with:
float[] kdata1D = {0.1F, 0.8F, 0.1F};
float[] kdata2D = new float[3*3];
for (int y=0; y<3; y++) {
for (int x=0; x<3; x++) {
kdata2D[y*3+x] = kdata1D[x] * kdata1D[y];
}
}
Kernel kernel = new Kernel(3, 3, kdata2D);
You can vary the elements of kdata until you get the desired blurring
effect. You lower the central value to get more smoothing. The sum
of the values in the 1D kernel must be 1.0 and the two outer elements
should be equal.
[Shameless Plug]
BTW, you might also want to check out the Java Advanced Imaging API at
http://java.sun.com/products/java-media/jai
This has a PNG encoder, which might be useful to you.
Regards,
Link Perry
JAI Team
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".