Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-devel] Re: [-DETECTION SPAM-] [Geotools-devel] Re: Raster Data Images

I will provide an example.

I have a world image which is a png+world file. The png is an RGBAlpha
Image, each channel is 32 bits, once I read it with ImageIO I get a
RenderedImage with ComponentColorModel and 4 bands of type integer.
I contruct a GridCoverage2D as follows:

GridCoverage2D gc=new GridCoverage2D(
                           "example",
                           providedImage,//renderedImage
                           crs,
                           envelope);

Now, the code you wrote automatically creates a non geophysic view
based on the R channel (the assumed visible band) scaling this channel
to 8 bits and also creating a MultiBandIndexColorModel based on a
grayscale.
What I basically see if I request geophysics(false) is a grayscale
image that correspond to the first band of the original image rescale
to 8 bits and with a grayscale palette applied on it, and this is not
what I expect!

When i build a GridCoverage2D providing a renderedImage that does not
automatically means that I built a Raster or a BufferedImage from
geophysics values that were float or real or whatever, it might be
that I have a REAL image with its own colors and transparency and I do
not want that to be changed!

WMS always asks for geophysics(false) expecting a nice view of the
geophysic data inside the GridCoverage2D, well if I build a GC2D from
a REAL image I want to retrieve that as it is, therefore to avoid
tricks on that side we have to take care of it inside the GC2D class
and the easiest thing to do is to provide a way to specify that
non-geophysic and geophysic view are the same thing!

The solution I found is simple and maybe not so efficient, but it is
for sure not invasive.

I put the three files I modified on the branch here

http://svn.geotools.org/geotools/branches/avoid_rescaling_hint

take a look at them, and tell me what you think.

Simone.




On 5/15/05, Martin Desruisseaux <martin.desruisseaux@xxxxxxxxxxxxx> wrote:
> simone giannecchini a écrit :
> > [...snip...] it is uncorrect to build a non geophysic view for
> > [...snip...] the fact that I really do not have a difference
> > between the geophysic and non-geophyisic view.
> > In such a case having a simple hint that allowed me to control the
> > automatic creation of a non-geophysic view would really be of help!
> 
> I agree with a hint if it doesn't duplicates an existing way of doing
> the same. I'm just trying to figure out the implication.
> 
> If the geophysics and non-geophysics view are the same, then the
> transform from "geophysics" to "non-geophysics" pixel values should be
> the identity transform, is it right? In such case, GridCoverage2D should
> detect by itself that when the "sampleToGeophysics" transform is an
> identity ones, "geophysics" and "non-geophysics" image are the same
> thing. If it doesn't, it is a bug that should be fixed.
> 
> 
> > I implemented what I said adding a Hint to the geotools factory class
> > and some new constructors to GC2D that allow you to provide hint when
> > you build a GC2D using a RenderedImage. In case yout ask, via the
> > hint, to NOT create a non-geophyisic view, I simply state that the
> > transformation between sampleValueRange and GeophysicValueRange is the
> > identity, therefore geophysic and non-geophysic view are coincident.
> 
> I agree with the approach of setting the "sampleToGeophysics" transform
> to identity. I just wonder why a hint is necessary in addition (except
> as a workaround for a possible bug in GridCoverage2D, if it doesn't
> detect by itself that non-geophysics and geophysics views are the same).
> 
> The idea is to creates all categories with the following constructors
> (for example):
> 
>    Category("The values", colors, lower, upper, 1, 0);
> 
> where 'lower' and 'upper' are the range of (geophysics / non-geophysics;
> they are the same) values in yours image, scale=1 and offset=0. If all
> categories are built with scale=1 and offset=0, then GridCoverage2D
> should know that geophysics and non-geophysics values are exactly the
> same, and no additional hints should be needed.
> 
> Could it work? I agree that some way of preventing undesired view is
> required, but I'm trying to avoid the "hint" way if it duplicates or
> conflict with the general way. If there is no way to achieve what you
> want using Category in the general way, then we will add the hint.
> 
>        Martin.
>


Back to the top