Oh cool - can you get a OperationDescriptor that way? One we could pass to
JAIOperation so we do not have to take stuff into and out of a GridCoverage2D?
Jody
On 21/06/2010, at 8:32 PM, Jon Britton wrote:
> Hi Jody,
>
> I just do use this little method I've created, but then I still need to
> create a GridCoverage2D from the result.
>
> public static RenderedImage binarize(RenderedImage image, double threshold) {
> ParameterBlock pb = new ParameterBlock();
> pb.add(threshold).addSource(image);
> RenderedImage binarized = JAI.create("binarize", pb);
> return binarized;
> }
>
> Your way looks a bit nicer though :-)
>
> Jon
>
> On 21 June 2010 08:55, Jody Garnett <[email protected]> wrote:
> Afternoon Simone / Michael:
>
> Time for me to ask a question on the user list ... I was looking to produce a
> black and white image to feed into the raster to vector process. And it was
> not as easy as I remember.
>
> I did find a few interesting parts to the puzzle:
> - The JAI Operation binarize seems to do the trick
> - OperationJAI can wrap up a JAI OperationDescriptor in geotools clothing so
> it can be applied to grid coverages ... but got stuck as Binarize operation
> does not seem to run around as an instance you can pass in to JAIOperation;
> and it is not captured as a subclass either
>
> Moving on there is a utility class:
> - Operations - looks very useful but could not sort out how to get it to
> threshold my raster
>
> Finally I found:
> - ImageWorker a very easy class for working on images directly ...
> - ... but then you need to go through the steps to wrap the result back up in
> a coverage using a CoverageFactoryFinder etc...
>
> So the question is? Did I miss something - why was this one so hard :-)
>
> For reference here is the sample code I ended up with:
> GridCoverage2D gradient = (GridCoverage2D)
> Operations.DEFAULT.gradientMagnitude( dem );
> RenderedImage rawImage = gradient.getRenderedImage();
>
> ImageWorker worker = new ImageWorker( rawImage );
> worker.binarize(maxSlope);
>
> RenderedImage processed = worker.getRenderedImage();
> GridCoverageFactory fac = CoverageFactoryFinder.getGridCoverageFactory(null);
>
> GridCoverage2D slope = fac.create( "slope", processed, dem.getEnvelope() );
>
>
> Notes:
> - I think last time I went straight to JAI operations and used the threshold
> operation
> - I noticed ImageWorker had a AreaOfInterest construct that could be turned
> into a Java shape? Could we use that for a super fast raster to vector
> calculation? or is it likely to be just as processor intensive as our own?
>
> Jody
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit. See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users