Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4906856
Votes 2
Synopsis Problem with Histogram operator with polygon ROI on tiled images (TIFF files)
Category jai:implementation
Reported Against 1.1.1
Release Fixed 1.1.3-beta
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs
Submit Date 14-AUG-2003
Description


FULL PRODUCT VERSION :
[  xxxxx@xxxxx   java]$ java -version
java version "1.4.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)

--
And, on another computer : 1.4.1_01

FULL OS VERSION :
Redhat Linux 8.0 and 9.0
Mandrake Linux 9.0
Windows XP

EXTRA RELEVANT SYSTEM CONFIGURATION :
Tested with JAI 1.1.1 and 1.1.2_beta

A DESCRIPTION OF THE PROBLEM :
When we create a ROI with a Polygon shape that covers 2 or more tiles of a tiled image, histogram operator fails.

We got an exception:
  java.lang.IllegalArgumentException
  The specified Rectangle is not completely contained within the Raster`s bounds.

But, if we create a ROI with de bounding box (rectangle shape) of the same polygon then histogram operator works fine.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See source code below.

1- Copy below source code
2- Compile the program
3- Find an tiled image (it used a TIFF file)
    -In my test, my roi size is 100x100
    -Tile size must be smaller than 100x100 in width and/or height
    -I can send an test image if necessary
4- Run the program
   java testPolygonROI myimage.tif

5- An exception will be throwed.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No Exception... an the Histogram  customer  should be correctly returned.
ACTUAL -
An exception.  See error message below.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
[  xxxxx@xxxxx   java]$ /home/eric/temp/j2sdk1.4.1/bin/java testPolygonROI
Image Size : 512, 512
Tile Size : 512, 8
Exception in thread "main" java.lang.IllegalArgumentException: The specified Rectangle is not completely contained within the Raster`s bounds.
        at javax.media.jai.PixelAccessor.getPixels(PixelAccessor.java:596)
        at javax.media.jai.Histogram.countPixelsByte(Histogram.java:694)
        at javax.media.jai.Histogram.countPixels(Histogram.java:667)
        at com.sun.media.jai.opimage.HistogramOpImage.accumulateStatistics(HistogramOpImage.java:114)
        at javax.media.jai.StatisticsOpImage.getProperty(StatisticsOpImage.java:300)
        at javax.media.jai.RenderedOp$1.getProperty(RenderedOp.java:1819)
        at javax.media.jai.PropertyEnvironment.getProperty(PropertyEnvironment.java:207)
        at javax.media.jai.PropertySourceImpl.getProperty(PropertySourceImpl.java:285)
        at javax.media.jai.WritablePropertySourceImpl.getProperty(WritablePropertySourceImpl.java:138)
        at javax.media.jai.RenderedOp.getProperty(RenderedOp.java:1993)
        at testPolygonROI.main(testPolygonROI.java:42)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
testPolygonROI.java
===================

import java.awt.*;
import javax.media.jai.*;


public class testPolygonROI {
    
    public static void main(String[] args) {
        // First argment if image filename to load.  By default : image512.tif
        String filename = args.length>0 ? args[0] : "image512.tif";
        PlanarImage image = JAI.create("fileload", filename);
        
        // Print image and tile size.
        System.out.println("Image Size : " + image.getWidth() + ", " + image.getHeight());
        System.out.println("Tile Size : " + image.getTileWidth() + ", " + image.getTileHeight());
        
        // Create a polygon
        Polygon polygon = new Polygon();
        polygon.addPoint(0, 0);
        polygon.addPoint(0, 100);
        polygon.addPoint(100, 100);
        polygon.addPoint(100, 0);
        
        // Our polygon is a square.  Get it as rectangle
        Rectangle rect = polygon.getBounds();
        
        // First test : ROI is a Rectangle
        // this test run ok without any problem
        ParameterBlockJAI pb1 = new ParameterBlockJAI("histogram");
        pb1.addSource(image);
        ROI roi1 = new ROIShape(rect);
        pb1.setParameter("roi", roi1);
        RenderedOp op1 = JAI.create("histogram", pb1);
        Histogram histo1 = (Histogram) op1.getProperty("histogram");

        // Second test : ROI is a Polygon that has the same area
        // this test fails when polygon ROI convert two or more tiles
        ParameterBlockJAI pb2 = new ParameterBlockJAI("histogram");
        pb2.addSource(image);
        ROI roi2 = new ROIShape(polygon);
        pb2.setParameter("roi", roi2);
        RenderedOp op2 = JAI.create("histogram", pb2);
        Histogram histo2 = (Histogram) op2.getProperty("histogram");
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Convert ROIShape to a ROI constucted by an RenderedImage.

  Polygon polygon = ....
  ROI roi = new ROIShape(polygon);
  roi = new ROI(roi.getAsImage());
  pb.setParameter("roi", roi);
  ...
(Incident Review ID: 185951) 
======================================================================

Verified with testPolygonROI2.java (attached) which does not require an input file.

  xxxxx@xxxxx   2003-08-14
Posted Date : 2005-11-16 18:50:10.0
Work Around
N/A
Evaluation
Problem is due to convex scan conversion going one line too far down.
Posted Date : 2005-11-16 18:50:10.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang