I have been using JAVA2D for a medical imaging application. When
displaying the image, I always remap a 12 bits medical gray scale image
down to 8 bits using a lookup operation. I then performed rendering
of the image using drawRenderedImage providing the AffineTransform object.
The AffineTransform object contains parameters for scaling and translation.


    BufferedImage source;
    ByteLookupType byteLookupTable;
    AffineTransform myAtx;
       .
       .
       .
    LookupOp lkop = new LookupOp(byteLookupTable, null);
    BufferedImage winlvlImage = lkop.filter(source, null);

    g2D.drawRenderedImage(winlvlImage, myAtx);


Everything works great until I try to concatenate a flip operation to the
AffineTranform object. Assuming I want to flip the image LEFT_RIGHT

    AffineTransform flipTransform = new AffineTransform(new double {-
1.0,0.0,0.0,1.0});
    flipTransform.translate(-source.getWidth(),0.0);

    myAtx.concatenate(flipTransform);

After I flip the image, the contrast of the image changes drastically. And
if I flip back, then everything looks great.  I was wondering how come a
spatial transformation changes the pixel values of the image.

A few more observation
(1) If I comment out the LookupOp step, everything works great
(2) If I don't perform any scaling prior to the flipping operation, things
work great too. Mathmatically, is there a problem cancatenating a scaling
operation with one that has negative value?

Any help is greatly appreciated!!

Thanks
Alfred Li
Senior Engineer
Synarc Inc.

ps I created the Gray Scale image using the following factory method

public class GrayScaleImageFactory

{
    public static BufferedImage createImage(int imageWidth, int
imageHeight, int imageDepth, short data[])
    {

        ComponentColorModel ccm = new ComponentColorModel(
                               ColorSpace.getInstance(ColorSpace.CS_GRAY),
                               new int[] {imageDepth}, false, false,
                               Transparency.OPAQUE,
                               DataBuffer.TYPE_USHORT);

        ComponentSampleModel csm = new ComponentSampleModel(
                                DataBuffer.TYPE_USHORT,
                                imageWidth,
                                imageHeight,1,imageWidth, new int[] {0});

        DataBuffer dataBuf = new DataBufferUShort((short[])data,
imageWidth);
        WritableRaster wr = Raster.createWritableRaster(csm, dataBuf, new
Point(0,0));
        return  new BufferedImage(ccm, wr, false, null);
    }
}

===========================================================================
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".

Reply via email to