From: Michael B. <mic...@gm...> - 2008-05-01 02:53:33
|
G'day Steve, Thanks for your reply. Your code is similar to what I've been doing. I was calling ConvolveDescriptor.create() but peering into the JAI source code (yikes) all that happens there is that it loads a parameter block and calls JAI.create() for you. Do you use float or double data grid coverages Steve ? I've just tried changing my input coverages from float to int and now the convolution works ! This gets me moving again for a while, but eventually I will want to use float or double data. My (very uneducated) guess is that deep in the bowels of JAI there is some optimization that provides wonderful speed but goes awry with float data (?) cheers Michael On Thu, May 1, 2008 at 2:59 AM, Steve Ansari <Ste...@no...> wrote: > Hello Michael, > > I've run into problems with using even sized kernels (such as 10x10) on > Mac. This was an accident - I actually wanted odd sized only. Anyway, > this is how I do convolve: > > float[] kernelMatrix = new float[kernelSize*kernelSize]; > for (int k=0; k<kernelMatrix.length; k++) { > kernelMatrix[k] = 1.0f/(kernelSize * kernelSize); > } > KernelJAI kernel = new KernelJAI(kernelSize, kernelSize, > kernelMatrix); > ParameterBlock pb = new ParameterBlock(); > pb.addSource(gc.getRenderedImage()); > pb.add(kernel); > PlanarImage output = JAI.create("convolve", pb, null); > WritableRaster outRaster = output.getData(); > > Where 'gc' is your original GridCoverage and 'outRaster' is used to > create another GridCoverage. > > I've had trouble trying to do a convolve other ways (such as with the > 'java.awt.image' stuff). This is the only thing I could get to work. > > I hope this helps. > Steve > |