It's not a secret anymore!*
The moose likes Other JSE/JEE APIs and the fly likes Java Advanced Imaging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java Advanced Imaging" Watch "Java Advanced Imaging" New topic
Author

Java Advanced Imaging

herr_doktor
Greenhorn

Joined: Sep 09, 2005
Posts: 1
I am developing a Java application using Java Advanced Imaging. I am trying to perfrom a Histogram Equalization on a source PlanarImage but I get an error when I try to display the result.

The method that does the equalization "equalize(...)" does not return an error. The error is produced when I call "displayImage(...)". The source is a satellite image with 6 bands, and the datatype is byte.

Thankyou!!!

//-------------------------------------------------------------------------------------
The Java error:

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: One factory fails for the operation "matchcdf"
at imaging.listener.JAIErrorListener.errorOccurred(JAIErrorListener.java:19)
at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1686)
at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:481)
at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:340)
at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:830)
at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:878)
at javax.media.jai.RenderedOp.getWidth(RenderedOp.java:2190)
at com.sun.media.jai.widget.DisplayJAI.<init>(DisplayJAI.java:102)

//-----------------------------------------------------------------------------------

//-----------------------------------------------------------------------

//This is my code. For this post I've put all my code into the following class,but in my app it is spread
across several classes.

class HistogramEqualize
{
PlanarImage source;
PlanarImage target;
int[] bandIndices=new int[]{0,1,2};

public HistogramEqualize()
{
//bandselect
source=bandSelect();

//set property
source.setProperty("histogram",getHistogram2());

//equalize the image
target=equalize(source);

//display the image....................error occurs when I try to display the image
displayImage(target);
}


public PlanarImage bandSelect()
{
ParameterBlock params=new ParameterBlock();
params.addSource(source);
params.add(bandIndices);

//perform bandselect
return JAI.create("bandselect",params);
}

public Histogram getHistogram2()
{
int[] bins = {256, 256, 256};
double[] low = {0.0D, 0.0D, 0.0D};
double[] high = {256.0D, 256.0D, 256.0D};

Histogram histogram= new Histogram(bins, low, high);

ROI roi=new ROIShape(source.getBounds());

ParameterBlock pb = new ParameterBlock();
pb.addSource(source);
pb.add(roi); //roi
pb.add(1);
pb.add(1);
pb.add(bins);
pb.add(low);
pb.add(high);

RenderedOp dst = JAI.create("histogram", pb, null);
histogram = (Histogram) dst.getProperty("histogram");

return histogram;
}

public PlanarImage equalize(PlanarImage src)
{
int bands=3;
int binCount=256;

// Create an equalization CDF.
float[][] CDFeq = new float[bands][];

//for each band
for(int b = 0; b < bands; ++b)
{
CDFeq[b] = new float[binCount];

//for each bin of this band
for(int i = 0; i < binCount; i++)
{
//band by bin
CDFeq[b][i] = (float)(i+1)/(float)binCount;
}
}

//Create a histogram-equalized image.
return (PlanarImage)JAI.create("matchcdf", src, CDFeq);
}


public void displayImage(PlanarImage i)
{
JScrollPane scrollFasc = new JScrollPane();

JDialog j=new JDialog();
DisplayJAI myJ=new DisplayJAI(i);
scrollFasc.getViewport().add(myJ);
j.add(scrollFasc);
j.setSize(800,800);
j.setAlwaysOnTop(true);
j.setVisible(true);
}
}

//-----------------------------------------------------------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Advanced Imaging
 
Similar Threads
JAI - creating multi page tiff images
Java Advanced Imaging: Set up a RenderableOp Graph
perspective transformation in java2d
JAI rotate leaves 1px black border - why?
Image Rotation