Uploaded image for project: 'GeoServer'
  1. GEOS-7235

Raster styling: ChannelSelection overriding transparency

    Details

      Description

      Having imagery data to render as WMS I want to use the <ContrastEnhancement> of the <RasterSymbolizer> to enhance the image's contrast. To make my nodata-values transparent for the WMS output, my input raster has either defined a 4th alpha band or I define "InputTransparentColor" to 000000 in the layer properties of a 3-band rgb-raster accordingly (gdal dstnodata = 0). It works very well with the default raster style. But consider a custom style with contrast enhancement like this:

      <?xml version="1.0" encoding="ISO-8859-1"?>
      <StyledLayerDescriptor version="1.0.0" 
       xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/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>raster_contrast</Name>
          <UserStyle>
            <Title>Raster Contrast Enhancement</Title>
            <Abstract>Raster style with custom contrast adjustment</Abstract>
            <FeatureTypeStyle>
              <Rule>
                <Name>rule1</Name>
                <Title>Opaque Raster</Title>
                <Abstract>A raster with 100% opacity and custom contrast</Abstract>
                <RasterSymbolizer>
                  <Opacity>1.0</Opacity>
                  <ChannelSelection>
                    <RedChannel>
                      <SourceChannelName>1</SourceChannelName>
                      <ContrastEnhancement>
                        <Normalize>
                          <VendorOption name="algorithm">StretchToMinimumMaximum</VendorOption>
                          <VendorOption name="minValue">33</VendorOption>
                          <VendorOption name="maxValue">227</VendorOption>
                        </Normalize>
                        <GammaValue>0.6</GammaValue>
                      </ContrastEnhancement>
                    </RedChannel>
                    <GreenChannel>
                      <SourceChannelName>2</SourceChannelName>
                      <ContrastEnhancement>
                        <Normalize>
                          <VendorOption name="algorithm">StretchToMinimumMaximum</VendorOption>
                          <VendorOption name="minValue">44</VendorOption>
                          <VendorOption name="maxValue">225</VendorOption>
                        </Normalize>
                        <GammaValue>0.6</GammaValue>
                      </ContrastEnhancement>                
                    </GreenChannel>
                    <BlueChannel>
                      <SourceChannelName>3</SourceChannelName>
                      <ContrastEnhancement>
                        <Normalize>
                          <VendorOption name="algorithm">StretchToMinimumMaximum</VendorOption>
                          <VendorOption name="minValue">46</VendorOption>
                          <VendorOption name="maxValue">227</VendorOption>
                        </Normalize>
                        <GammaValue>0.6</GammaValue>
                      </ContrastEnhancement>                
                    </BlueChannel>
                  </ChannelSelection>            
                </RasterSymbolizer>
              </Rule>
            </FeatureTypeStyle>
          </UserStyle>
        </NamedLayer>
      </StyledLayerDescriptor>
      

      Using this style the transparent areas are being ignored and rendered black (r,g,b=0,0,0), even tough the corresponding alpha channel states 0 at the clicked coordinate. As I understand, the <ChannelSelection> of this SLD will strip out the alpha channel which GeoServer uses to render transparency. If the default raster style can handle alpha without problems it would be nice to combine it with <ChannelSelection> and <ContrastEnhancement> somehow. Can this be achieved on SLD level or within GeoServer?

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                dany111 Daniele Romagnoli
                Reporter:
                michikommader MichaelS
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: