Search in sources :

Example 1 with ContrastEnhancement

use of org.opengis.style.ContrastEnhancement in project geotoolkit by Geomatys.

the class RasterSymbolizerRenderer method applyContrastEnhancement.

/**
 * Returns contrast enhancement modified image.
 *
 * @param image worked image.
 * @param styleElement the {@link RasterSymbolizer} which contain contrast enhancement properties.
 * @return contrast enhancement modified image.
 * @throws PortrayalException if problem during gamma value application
 * @see #brigthen(java.awt.image.RenderedImage, int)
 */
private static RenderedImage applyContrastEnhancement(RenderedImage image, final RasterSymbolizer styleElement) throws PortrayalException {
    ensureNonNull("image", image);
    ensureNonNull("styleElement", styleElement);
    // -- contrast enhancement -------------------
    final ContrastEnhancement ce = styleElement.getContrastEnhancement();
    if (ce != null && image.getColorModel() instanceof ComponentColorModel) {
        // histogram/normalize adjustment ----------------------------------
        final ContrastMethod method = ce.getMethod();
        if (ContrastMethod.HISTOGRAM.equals(method)) {
            image = equalize(image);
        } else if (ContrastMethod.NORMALIZE.equals(method)) {
            image = normalize(image);
        }
        // gamma correction ------------------------------------------------
        final Double gamma = doubleValue(ce.getGammaValue());
        if (gamma != null && gamma != 1) {
            // Specification : page 35
            // A “GammaValue” tells how much to brighten (values greater than 1.0) or dim (values less than 1.0) an image.
            image = brigthen(image, (int) ((gamma - 1) * 255f));
        }
    }
    return image;
}
Also used : ContrastEnhancement(org.opengis.style.ContrastEnhancement) ComponentColorModel(java.awt.image.ComponentColorModel) ContrastMethod(org.opengis.style.ContrastMethod)

Example 2 with ContrastEnhancement

use of org.opengis.style.ContrastEnhancement in project geotoolkit by Geomatys.

the class Tester method createRasterSymbolizer.

private static RasterSymbolizer createRasterSymbolizer() {
    String name = "Raster symbolizer name";
    Description desc = STYLE_FACTORY.description("Raster symbolizer title", "Raster symbolizer description");
    Unit uom = Units.METRE;
    String geom = "geom";
    Expression opacity = FILTER_FACTORY.literal(0.5);
    ChannelSelection selection = STYLE_FACTORY.channelSelection(STYLE_FACTORY.selectedChannelType("chanel2", FILTER_FACTORY.literal(1)));
    OverlapBehavior overlap = OverlapBehavior.RANDOM;
    ColorMap colorMap = STYLE_FACTORY.colorMap();
    ContrastEnhancement enchance = STYLE_FACTORY.contrastEnhancement();
    ShadedRelief relief = STYLE_FACTORY.shadedRelief(FILTER_FACTORY.literal(3), true);
    Symbolizer outline = createLineSymbolizer();
    return STYLE_FACTORY.rasterSymbolizer(name, geom, desc, uom, opacity, selection, overlap, colorMap, enchance, relief, outline);
}
Also used : Description(org.opengis.style.Description) ContrastEnhancement(org.opengis.style.ContrastEnhancement) Expression(org.opengis.filter.Expression) ChannelSelection(org.opengis.style.ChannelSelection) ColorMap(org.opengis.style.ColorMap) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) Unit(javax.measure.Unit) ShadedRelief(org.opengis.style.ShadedRelief) PointSymbolizer(org.opengis.style.PointSymbolizer) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer) RasterSymbolizer(org.opengis.style.RasterSymbolizer) TextSymbolizer(org.opengis.style.TextSymbolizer) Symbolizer(org.opengis.style.Symbolizer) OverlapBehavior(org.opengis.style.OverlapBehavior)

Example 3 with ContrastEnhancement

use of org.opengis.style.ContrastEnhancement in project geotoolkit by Geomatys.

the class XMLUtilitiesTest method createRasterSymbolizer.

private static RasterSymbolizer createRasterSymbolizer() {
    String name = "Raster symbolizer name";
    Description desc = STYLE_FACTORY.description("Raster symbolizer title", "Raster symbolizer description");
    Unit uom = Units.METRE;
    String geom = "geom";
    Expression opacity = FILTER_FACTORY.literal(0.5);
    ChannelSelection selection = STYLE_FACTORY.channelSelection(STYLE_FACTORY.selectedChannelType("chanel2", FILTER_FACTORY.literal(1)));
    OverlapBehavior overlap = OverlapBehavior.RANDOM;
    ColorMap colorMap = STYLE_FACTORY.colorMap();
    ContrastEnhancement enchance = STYLE_FACTORY.contrastEnhancement();
    ShadedRelief relief = STYLE_FACTORY.shadedRelief(FILTER_FACTORY.literal(3), true);
    Symbolizer outline = createLineSymbolizer();
    return STYLE_FACTORY.rasterSymbolizer(name, geom, desc, uom, opacity, selection, overlap, colorMap, enchance, relief, outline);
}
Also used : Description(org.opengis.style.Description) ContrastEnhancement(org.opengis.style.ContrastEnhancement) Expression(org.opengis.filter.Expression) ChannelSelection(org.opengis.style.ChannelSelection) ColorMap(org.opengis.style.ColorMap) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) Unit(javax.measure.Unit) ShadedRelief(org.opengis.style.ShadedRelief) PointSymbolizer(org.opengis.style.PointSymbolizer) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer) RasterSymbolizer(org.opengis.style.RasterSymbolizer) TextSymbolizer(org.opengis.style.TextSymbolizer) Symbolizer(org.opengis.style.Symbolizer) OverlapBehavior(org.opengis.style.OverlapBehavior)

Example 4 with ContrastEnhancement

use of org.opengis.style.ContrastEnhancement in project geotoolkit by Geomatys.

the class Styles method colorCategorizeRaster.

public static MutableStyle colorCategorizeRaster() {
    final Map<Expression, Expression> values = new HashMap<>();
    values.put(StyleConstants.CATEGORIZE_LESS_INFINITY, SF.literal(new Color(46, 154, 88)));
    values.put(FF.literal(1003), SF.literal(new Color(46, 154, 88)));
    values.put(FF.literal(1800), SF.literal(new Color(251, 255, 128)));
    values.put(FF.literal(2800), SF.literal(new Color(224, 108, 31)));
    values.put(FF.literal(3500), SF.literal(new Color(200, 55, 55)));
    values.put(FF.literal(4397), SF.literal(new Color(215, 244, 244)));
    final Expression lookup = DEFAULT_CATEGORIZE_LOOKUP;
    final Literal fallback = DEFAULT_FALLBACK;
    final Expression function = SF.categorizeFunction(lookup, values, ThreshholdsBelongTo.SUCCEEDING, fallback);
    final ChannelSelection selection = null;
    final Expression opacity = LITERAL_ONE_FLOAT;
    final OverlapBehavior overlap = OverlapBehavior.LATEST_ON_TOP;
    final ColorMap colorMap = SF.colorMap(function);
    final ContrastEnhancement enchance = SF.contrastEnhancement(LITERAL_ONE_FLOAT, ContrastMethod.NONE);
    final ShadedRelief relief = SF.shadedRelief(LITERAL_ONE_FLOAT);
    final Symbolizer outline = null;
    final Unit uom = Units.POINT;
    final String geom = DEFAULT_GEOM;
    final String name = "raster symbol name";
    final Description desc = DEFAULT_DESCRIPTION;
    final RasterSymbolizer symbol = SF.rasterSymbolizer(name, geom, desc, uom, opacity, selection, overlap, colorMap, enchance, relief, outline);
    return SF.style(symbol);
}
Also used : Description(org.opengis.style.Description) HashMap(java.util.HashMap) ColorMap(org.opengis.style.ColorMap) Unit(javax.measure.Unit) ShadedRelief(org.opengis.style.ShadedRelief) PointSymbolizer(org.opengis.style.PointSymbolizer) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer) RasterSymbolizer(org.opengis.style.RasterSymbolizer) TextSymbolizer(org.opengis.style.TextSymbolizer) Symbolizer(org.opengis.style.Symbolizer) RasterSymbolizer(org.opengis.style.RasterSymbolizer) ContrastEnhancement(org.opengis.style.ContrastEnhancement) Expression(org.opengis.filter.Expression) ChannelSelection(org.opengis.style.ChannelSelection) Literal(org.opengis.filter.Literal) OverlapBehavior(org.opengis.style.OverlapBehavior)

Example 5 with ContrastEnhancement

use of org.opengis.style.ContrastEnhancement in project geotoolkit by Geomatys.

the class Styles method colorInterpolationRaster.

public static MutableStyle colorInterpolationRaster() {
    final List<InterpolationPoint> values = new ArrayList<>();
    values.add(SF.interpolationPoint(1003, SF.literal(new Color(46, 154, 88))));
    values.add(SF.interpolationPoint(1800, SF.literal(new Color(251, 255, 128))));
    values.add(SF.interpolationPoint(2800, SF.literal(new Color(224, 108, 31))));
    values.add(SF.interpolationPoint(3500, SF.literal(new Color(200, 55, 55))));
    values.add(SF.interpolationPoint(4397, SF.literal(new Color(215, 244, 244))));
    final Expression lookup = DEFAULT_CATEGORIZE_LOOKUP;
    final Literal fallback = DEFAULT_FALLBACK;
    final Expression function = SF.interpolateFunction(lookup, values, Method.COLOR, Mode.LINEAR, fallback);
    final ChannelSelection selection = null;
    final Expression opacity = LITERAL_ONE_FLOAT;
    final OverlapBehavior overlap = OverlapBehavior.LATEST_ON_TOP;
    final ColorMap colorMap = SF.colorMap(function);
    final ContrastEnhancement enchance = SF.contrastEnhancement(LITERAL_ONE_FLOAT, ContrastMethod.NONE);
    final ShadedRelief relief = SF.shadedRelief(LITERAL_ONE_FLOAT);
    final Symbolizer outline = null;
    final Unit uom = Units.POINT;
    final String geom = DEFAULT_GEOM;
    final String name = "raster symbol name";
    final Description desc = DEFAULT_DESCRIPTION;
    final RasterSymbolizer symbol = SF.rasterSymbolizer(name, geom, desc, uom, opacity, selection, overlap, colorMap, enchance, relief, outline);
    return SF.style(symbol);
}
Also used : InterpolationPoint(org.geotoolkit.style.function.InterpolationPoint) Description(org.opengis.style.Description) ColorMap(org.opengis.style.ColorMap) ArrayList(java.util.ArrayList) Unit(javax.measure.Unit) ShadedRelief(org.opengis.style.ShadedRelief) PointSymbolizer(org.opengis.style.PointSymbolizer) PolygonSymbolizer(org.opengis.style.PolygonSymbolizer) LineSymbolizer(org.opengis.style.LineSymbolizer) RasterSymbolizer(org.opengis.style.RasterSymbolizer) TextSymbolizer(org.opengis.style.TextSymbolizer) Symbolizer(org.opengis.style.Symbolizer) RasterSymbolizer(org.opengis.style.RasterSymbolizer) ContrastEnhancement(org.opengis.style.ContrastEnhancement) Expression(org.opengis.filter.Expression) ChannelSelection(org.opengis.style.ChannelSelection) Literal(org.opengis.filter.Literal) OverlapBehavior(org.opengis.style.OverlapBehavior)

Aggregations

ContrastEnhancement (org.opengis.style.ContrastEnhancement)12 Expression (org.opengis.filter.Expression)9 ChannelSelection (org.opengis.style.ChannelSelection)9 ColorMap (org.opengis.style.ColorMap)9 LineSymbolizer (org.opengis.style.LineSymbolizer)9 PointSymbolizer (org.opengis.style.PointSymbolizer)9 PolygonSymbolizer (org.opengis.style.PolygonSymbolizer)9 RasterSymbolizer (org.opengis.style.RasterSymbolizer)9 ShadedRelief (org.opengis.style.ShadedRelief)9 Symbolizer (org.opengis.style.Symbolizer)9 TextSymbolizer (org.opengis.style.TextSymbolizer)9 Unit (javax.measure.Unit)7 Description (org.opengis.style.Description)7 OverlapBehavior (org.opengis.style.OverlapBehavior)7 SimpleInternationalString (org.apache.sis.util.SimpleInternationalString)4 Literal (org.opengis.filter.Literal)2 ExtensionSymbolizer (org.opengis.style.ExtensionSymbolizer)2 InternationalString (org.opengis.util.InternationalString)2 ComponentColorModel (java.awt.image.ComponentColorModel)1 ArrayList (java.util.ArrayList)1