gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 8481efc 2/7: Non-blank minimum and maximum for


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 8481efc 2/7: Non-blank minimum and maximum for long in statistics
Date: Tue, 16 Aug 2016 14:30:38 +0000 (UTC)

branch: master
commit 8481efcf6acfd078bdea4ce7f8ab8f85655fd4b4
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    Non-blank minimum and maximum for long in statistics
    
    Two new functions were added to lib/statistics.c (and its header) for
    finding the minimum and maximum values in a long array (while ignoring
    blank values). All the functions until now were for float and double
    types. Since NaN is not available for the long type, it was necessary to
    check for the pixel not being a blank pixel.
---
 lib/gnuastro/statistics.h |    8 ++++++++
 lib/statistics.c          |   41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/lib/gnuastro/statistics.h b/lib/gnuastro/statistics.h
index ad910e1..d4df04b 100644
--- a/lib/gnuastro/statistics.h
+++ b/lib/gnuastro/statistics.h
@@ -31,6 +31,14 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
  *****************    Mininum and Maximum    ********************
  ****************************************************************/
 void
+gal_statistics_long_non_blank_min(long *in, size_t size, long *min,
+                                  long blank);
+
+void
+gal_statistics_long_non_blank_max(long *in, size_t size, long *max,
+                                  long blank);
+
+void
 gal_statistics_float_min(float *in, size_t size, float *min);
 
 void
diff --git a/lib/statistics.c b/lib/statistics.c
index 9d25b69..b6a0b81 100644
--- a/lib/statistics.c
+++ b/lib/statistics.c
@@ -27,6 +27,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <errno.h>
 #include <error.h>
 #include <float.h>
+#include <stdint.h>
 #include <stdlib.h>
 
 #include <gnuastro/qsort.h>
@@ -44,6 +45,46 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 /****************************************************************
  *****************    Mininum and Maximum    ********************
  ****************************************************************/
+/* Find the the minimum (non-blank) value in an array of type long. Note
+   that the long type doesn't have a NaN value like the floats above. So as
+   blank pixels, a value in the range of acceptable values is given. so we
+   have to explicitly ignore those values.*/
+void
+gal_statistics_long_non_blank_min(long *in, size_t size, long *min,
+                                  long blank)
+{
+  long tmin=INT32_MAX, *lpt;
+  lpt=in+size;
+  do
+    if(*in!=blank && *in<tmin)
+      tmin=*in;
+  while(++in<lpt);
+  *min=tmin;
+}
+
+
+
+
+
+/* Find the the minimum (non-blank) value in an array of type long. See the
+   explanation above `gal_statistics_long_min'. */
+void
+gal_statistics_long_non_blank_max(long *in, size_t size, long *max,
+                                  long blank)
+{
+  long tmax=INT32_MIN, *lpt;
+  lpt=in+size;
+  do
+    if(*in!=blank && *in>tmax)
+      tmax=*in;
+  while(++in<lpt);
+  *max=tmax;
+}
+
+
+
+
+
 void
 gal_statistics_float_min(float *in, size_t size, float *min)
 {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]