[ 
https://issues.apache.org/jira/browse/IMAGING-251?focusedWorklogId=432495&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-432495
 ]

ASF GitHub Bot logged work on IMAGING-251:
------------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/May/20 06:10
            Start Date: 10/May/20 06:10
    Worklog Time Spent: 10m 
      Work Description: kinow commented on a change in pull request #72:
URL: https://github.com/apache/commons-imaging/pull/72#discussion_r422592479



##########
File path: 
src/main/java/org/apache/commons/imaging/formats/tiff/TiffRasterStatistics.java
##########
@@ -0,0 +1,144 @@
+/*
+ * 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;
+
+/**
+ * Collects and stores a set of simple statistics from the input raster.
+ */
+public class TiffRasterStatistics {
+
+    private final int nSample;
+    private final int nNull;
+    private final float minValue;
+    private final float maxValue;
+    private final float meanValue;
+    private final float excludedValue;
+
+    /**
+     * Constructs an instance of this class, tabulating results from the input
+     * raster data.
+     *
+     * @param raster the input data
+     * @param excludedValue an optional value to ignore; use Float.NaN if 
no
+     * value is to be ignored.
+     */
+    TiffRasterStatistics(TiffRasterData raster, float excludedValue) {
+        this.excludedValue = excludedValue;
+        float vMin = Float.POSITIVE_INFINITY;
+        float vMax = Float.NEGATIVE_INFINITY;
+        double vSum = 0;
+        int nS = 0;
+        int nN = 0;
+        float[] data = raster.getData();
+        for (int i = 0; i < data.length; i++) {
+            float test = data[i];
+            if (Float.isNaN(test)) {
+                nN++;
+                continue;
+            }
+            if (test == excludedValue) {
+                continue;
+            }
+
+            nS++;
+            vSum += test;
+            if (test < vMin) {
+                vMin = test;
+            }
+            if (test > vMax) {
+                vMax = test;
+            }
+        }
+
+        minValue = vMin;
+        maxValue = vMax;
+        nSample = nS;
+        nNull = nN;
+        if (nSample == 0) {
+            meanValue = 0;
+        } else {
+            meanValue = (float) (vSum / nSample);
+        }
+    }
+
+    /**
+     * Get the count of the number of non-null and non-excluded samples in the
+     * collection.
+     *
+     * @return the a positive number, potentially zero
+     */
+    public int getCountOfSamples() {
+        return nSample;
+    }
+
+    /**
+     * Get the count of the number of null samples in the collection.
+     *
+     * @return the a positive number, potentially zero
+     */
+    public int getCountOfNulls() {
+        return nNull;
+    }
+
+    /**
+     * Get the minimum value found in the source data
+     *
+     * @return the minimum value found in the source data
+     */
+    public float getMinValue() {
+        return minValue;
+    }
+
+    /**
+     * Get the maximum value found in the source data
+     *
+     * @return the maximum value found in the source data
+     */
+    public float getMaxValue() {
+        return maxValue;
+    }
+
+    /**
+     * Get the mean value for all sample values in the raster. Null-data values
+     * and excluded values are not considered.
+     *
+     * @return the meanValuethe mean value of the samples

Review comment:
       "return the mean value of the samples"




----------------------------------------------------------------
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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 432495)
    Time Spent: 9h 50m  (was: 9h 40m)

> Support TIFF standard floating point data
> -----------------------------------------
>
>                 Key: IMAGING-251
>                 URL: https://issues.apache.org/jira/browse/IMAGING-251
>             Project: Commons Imaging
>          Issue Type: New Feature
>          Components: Format: TIFF
>    Affects Versions: 1.x
>            Reporter: Gary Lucas
>            Priority: Major
>             Fix For: 1.x
>
>         Attachments: ArizonaHillshade.jpg, Imaging252_USGS_n38w077.jpg
>
>          Time Spent: 9h 50m
>  Remaining Estimate: 0h
>
> Commons Imaging does not support the floating-point format included in the 
> TIFF specification. There are prominent data sources that issue products in 
> this format. The ability to support this information would open up new 
> application areas for Commons Imaging.
> TIFF is often used as a mechanism for distributing data from geophysical 
> applications in the form of GeoTIFF files.  Some of this is not imagery, but 
> data. For example, the US Geological Survey is currently releasing 
> high-resolution elevation data grids for the 3DEP program under the name 
> Cloud-Optimized GeoTIFF (COG). It is a substantial data set with significant 
> potential commercial and academic applications.
> To access this data means modifying the TIFF DataReaderStrips and 
> DataReaderTile classes to recognize floating point data (which is typically 
> indicated using TIFF tag #339, SampleFormat). Also, returning the data in the 
> form of a BufferedImage makes no sense at all, so the API on the 
> TiffImageParser and supporting classes would need additional methods to 
> return arrays of floats.  The good news here is that that requirement would 
> mean adding new methods to the classes rather than making significant changes 
> to existing classes. So the probability of unintended consequences or new 
> bugs in existing code would be minimized.
> Specification details for floating-point are given in the main TIFF-6 
> documentations and Adobe Photoshop TIFF Technical Note 3.
>  
> I am willing to volunteer to make these changes provided that there is 
> interest and a high probability that my contributions would be evaluated and, 
> if suitable, integrated into the Commons Imaging code base. 
> Thank you for your attention in this matter.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to