Skip to content

Raster Hue Rotate and Saturation

John Schulz edited this page Jul 24, 2017 · 21 revisions

Create a new rendering transformation option. This approach would be considered a raster-to-raster transformation and would require creating and executing a new process and operation/function and extending its use to the <Transformation> SLD.

This will allow the transformation to adjust the color of 3 band rasters by changing the color space to rotate the images hue for aesthetic purposes before styling the raster layer.

The steps that need to be taken are:

  1. Create a new HueRotateProcess.java at org.geotools.process.raster. The process should execute HueRotate when called ie. via wps request.

  2. Create a HueRotate.java operation to be executed by the HueRotateProcess at org.geotools.coverage.processing.operation The HueRotate operation should be able to take a raster as a source to work with. In the operation two parameters should be needed "data" should extract the GridCoverage2d to work with the color space and pixels, and "hue" should be a number indicating in degrees how far around the 'color wheel' the hue should be rotated.

  3. Add org.geotools.process.raster.HueRotateProcess to RasterProcess META-INF library org.geotools.process.raster.RasterProcess as part of the 'Process Raster Plugin'

References:

Status

Choose one of:

  • Under Discussion
  • In Progress
  • Completed
  • Rejected,
  • Deferred

Voting:

  • Andrea Aime
  • Ben Caradoc-Davies
  • Christian Mueller
  • Ian Turton
  • Justin Deoliveira
  • Jody Garnett
  • Simone Giannecchini

Tasks

Work is being done by John Schulz

  1. Write implementation
  2. Verify with test case
  3. Documentation changes
    • API change make a note upgrading page.
    • Explain the usage of new functions
    • Update the user guide with code example

Challenges will include using the JAI library to efficiently convert between HSV and RGB for entire raster images to achieve desired transformation in HueRotateOperation.

Example

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
  xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
  xmlns="http://www.opengis.net/sld"
  xmlns:ogc="http://www.opengis.net/ogc"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <NamedLayer>
    <Name>hue_rotate</Name>
    <UserStyle>
      <Title>Hue Rotate</Title>
      <Abstract>Rotates hue of each pixel from raster</Abstract>
      <FeatureTypeStyle>
      <Transformation>
        <ogc:Function name="ras:HueRotate">
          <ogc:Function name="parameter">
            <ogc:Literal>data</ogc:Literal>
          <ogc:Function name="parameter">
            <ogc:Literal>hue</ogc:Literal>
            <ogc:Literal>30</ogc:Literal>
          </ogc:Function>
        </ogc:Function>
      </Transformation>
      <Rule>
        <RasterSymbolizer>
          <Opacity>1.0</Opacity>
        </RasterSymbolizer>
      </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

API /

I believe that this will not require any API change. It should just add additional functions for rendering transformations on rasters.

Clone this wiki locally