kinow commented on a change in pull request #72: IMAGING-251 support for TIFF floating-point formats URL: https://github.com/apache/commons-imaging/pull/72#discussion_r404594350
########## File path: src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/fp/PhotometricInterpreterFloat.java ########## @@ -0,0 +1,312 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.imaging.formats.tiff.photometricinterpreters.fp; + +import java.awt.Color; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import org.apache.commons.imaging.ImageReadException; +import org.apache.commons.imaging.common.ImageBuilder; +import org.apache.commons.imaging.formats.tiff.TiffDirectory; +import org.apache.commons.imaging.formats.tiff.TiffField; +import org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants; +import org.apache.commons.imaging.formats.tiff.photometricinterpreters.PhotometricInterpreter; + +/** + * Implements a custom photometric interpreter that can be supplied by + * applications in order to render Java images from real-valued TIFF data + * products. Most TIFF files include a specification for a "photometric + * interpreter" that implements logic for transforming the raw data in a TIFF + * file to a rendered image. But the TIFF standard does not include a + * specification for a photometric interpreter that can be used for rendering + * floating-point data. TIFF files are sometimes used to specify non-image data + * as a floating-point raster. This approach is particularly common in GeoTIFF + * files (TIFF files that contain tags for supporting geospatial reference + * metadata for Geographic Information Systems). Because of the limits of the + * stock photometric interpreters, most floating-point TIFF files to not produce + * useful images. + * <p> + * This class allows an Apache Commons implementation to construct and specify a + * custom photometric interpreter when reading from a TIFF file. Applications + * may supply their own palette that maps real-valued data to specified colors. + * <p> + * This class provides two constructors: + * <ol> + * <li>A simple constructor to support gray scales</li> + * <li>A constructor to support a color palette (with potential + * interpolation)</li> + * </ol> + * <p> + * To use this class, an application must access the TIFF file using the + * low-level, TIFF-specific API provided by the Apache Commons Imaging library. + * + */ +public class PhotometricInterpreterFloat extends PhotometricInterpreter { + + ArrayList<IPaletteEntry> rangePaletteEntries = new ArrayList<>(); + ArrayList<IPaletteEntry> singleValuePaletteEntries = new ArrayList<>(); + + float minFound = Float.POSITIVE_INFINITY; + float maxFound = Float.NEGATIVE_INFINITY; + int xMin; + int yMin; + int xMax; + int yMax; + + double sumFound; + int nFound; Review comment: Could we make the members above `private` or some other access modifier? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
