Convolve changes bits per pixel

View: New views
2 Messages — Rating Filter:   Alert me  

Convolve changes bits per pixel

by jai-interest-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a number of tiff images of documents, some black & white, some color, that I apply a blur to, using a 'convolve' operation.

My images start out as either 1 bit per pixel or 8 bits per pixel but after the 'convolve' they are all 24 bits per pixel. The subsequent tiff images are significantly larger than the ones I started with.

Here is the code that applies the blur:

public static RenderedImage blur(RenderedImage image, int radius) {
        int klen = Math.max(radius, 2);
        int ksize = klen * klen;
        float f = 1f / ksize;
        float[] kern = new float[ksize];
        for (int i = 0; i < ksize; i++)
                kern[i] = f;
        KernelJAI blur = new KernelJAI(klen, klen, kern);
        ParameterBlockJAI param = new ParameterBlockJAI("Convolve");
        param.addSource(image);
        param.setParameter("kernel", blur);
        return JAI.create("Convolve", param, null);
}

Any idea how to perform the blur without changing the bits per pixel?

Thanks.

David
[Message sent by forum member 'dpjones' (dpjones@...)]

http://forums.java.net/jive/thread.jspa?messageID=365156

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@...
For additional commands, e-mail: interest-help@...


Re: Convolve changes bits per pixel

by jai-interest-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

Not an answer (sorry) but a suggestion...

As I understand it, the convolve operation should honour the type of your input image. If the source image is byte image then the destination image should be too (with results of the convolution being rounded).

So I'd check the type of your image, via its SampleModel, after you first read the tiff.

Michael
[Message sent by forum member 'cafeanimal' (michael.bedward@...)]

http://forums.java.net/jive/thread.jspa?messageID=365987

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@...
For additional commands, e-mail: interest-help@...