Simone Giannecchini a écrit :
> is there anyway me (or anyone else like aaime) can help you out with
> the merge. [...snip...]
>
> Plz, let me know how I can be of help, I am sure others will follow...
Thanks for your offer. I'm still porting ImageUtilities. Not yet finished, but
I made some progress.
Commited latest bunch of work as of revision 20230.
I'm working only on module/coverage. I would let the merge of other modules
(including module/main)
to other peoples if possible. Once the merge is finished, I would suggest to
work directly on trunk,
especially if future work are mostly bug fixes, unless there is other major
work undergoing.
All new methods in ImageUtilities were moved in org.geotools.image.ImageWorker
(a new class). I have
not yet finished it. But if you want, you could copy ImageWorker from trunk to
the coverage branch
and start changing the references to ImageUtilities to ImageWorker in the code.
And of course test,
test and test, since I made my best but have probably done some mistakes there
and there. Note: I
have added a convenience method for testing. More detais below.
Differences between ImageWorker and ImageUtilities:
---------------------------------------------------
* Instead of a bunch of static methods, we create one ImageWorker instance
with the image we
want to work on. From this point, we control various methods like
"forceIndexColorModel()"
for applying operations on the image. Advantages are:
- We have more control on the operation process (including tile cache
control) through
ImageWorker.setRenderingHint(...). So we can control the whole set of
rendering hints,
compared to a few boolean parameters in the static methods.
- The static methods were expecting and returning a mix of PlanarImage or
RenderedOp
objects. ImageWorker allow to access to the image result through
getRenderedImage(),
getPlanarImage() or getRenderedOperation(), at user choice. For users
who just want
a RenderedImage, the above choice allows them to get that image without
creating an
unecessary "Null" operation.
* The static methods had a some duplicated code, which I tried to reduce.
Some methods
also had hard-coded values (e.g. addTransparency2IndexColorModel), which I
tried to
avoid as well.
* Sometime the algorithm has been significatively changed. For example
ImageUtilities.addTransparency2IndexColorModel(...) tries to set the
transparent pixel
value using the "Add" operation, while I believe that the intend was a
combinaison of
"And" and "Or" operations. I reimplemented this method using such "And" /
"Or", and
took the occasion to factor out a part of the code as a new "mask" method.
Testing
-------------------------------------------------
I have not yet tested all methods, but I tested some of them. Try the following
from the command line:
java org.geotools.image.ImageWorker PP20000102.png -operation binarize
Where PP20000102.png should be some image on yours disk. This main method
actually do nothing more
than loading the image, applying the specified operation and invoking the
following method:
imageWorker.show();
The 'show()' method will display a widget with a buch of informations for
browsing the operation
chain. This is a kind of "toString()" method for debugging purpose, but much
more elaborated. Note:
Use a raisonable image size - this widget is for debugging the operation chain,
not for testing its
capacity to render large images.
Note: ImageWorker.show() requires "gt2-widgets-swing.jar" to be in the
classpath. For all other
methods, this dependency is of course not needed.
Javadoc:
-------------------------------------------------
http://javadoc.geotools.fr/snapshot/org/geotools/image/ImageWorker.html
Mapping from ImageUtilities to ImageWorker
(I admit that using ImageWorker is more verbove):
-------------------------------------------------
Old:
image = ImageUtilities.rescale2Byte(image);
Proposed replacement:
ImageWorker worker = new ImageWorker(image);
worker.rescaleToBytes();
image = worker.getPlanarImage();
-------------------------------------------------------------
Old:
image = ImageUtilities.RGBIndexColorModel(image);
Proposed replacement:
ImageWorker worker = new ImageWorker(image);
worker.forceIndexColorModel();
image = worker.getPlanarImage();
-------------------------------------------------------------
Old:
image = ImageUtilities.direct2ComponentColorModel(image);
image = ImageUtilities.reformatColorModel2ComponentColorModel(image);
Proposed replacement:
ImageWorker worker = new ImageWorker(image);
worker.forceComponentColorModel();
image = worker.getPlanarImage();
-------------------------------------------------------------
Old:
image = ImageUtilities.binarizeImageExt(image, threshold, cacheMe);
Proposed replacement:
ImageWorker worker = new ImageWorker(image);
if (!cacheMe) {
worker.setRenderingHint(JAI.KEY_TILE_CACHE, null);
}
worker.binarize(threshold);
image = worker.getRenderedOperation();
-------------------------------------------------------------
Old:
image = ImageUtilities.roiExt(image, threshold, cacheMe);
Proposed replacement:
ImageWorker worker = new ImageWorker(image);
if (!cacheMe) {
worker.setRenderingHint(JAI.KEY_TILE_CACHE, null);
}
worker.binarize(threshold);
image = worker.getImageAsROI();
-------------------------------------------------------------
Old:
image = ImageUtilities.bandCombineSimple(image, cacheMe);
image = ImageUtilities.convertIHS(image, cacheMe);
Proposed replacement:
ImageWorker worker = new ImageWorker(image);
if (!cacheMe) {
worker.setRenderingHint(JAI.KEY_TILE_CACHE, null);
}
worker.intensity();
image = worker.getRenderedOperation();
-------------------------------------------------------------
Old:
image = ImageUtilities.selectBand(image, threshold, cacheMe);
Proposed replacement:
ImageWorker worker = new ImageWorker(image);
if (!cacheMe) {
worker.setRenderingHint(JAI.KEY_TILE_CACHE, null);
}
worker.retainFirstBand(threshold);
image = worker.getRenderedOperation();
-------------------------------------------------------------
Old:
image = ImageUtilities.addTransparency2IndexColorModel(image, alpha,
optimizeForGIF);
Proposed replacement:
ImageWorker worker = new ImageWorker(image);
if (optimizeForGIF) {
worker.setRenderingHint(ImageWorker.TILING_ALLOWED, Boolean.FALSE);
}
worker.addTransparencyToIndexColorModel(threshold);
image = worker.getRenderedOperation();
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel