/* PIKA - Photo and Image Kooker Application
 * a rebranding of The GNU Image Manipulation Program (created with heckimp)
 * A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
 *
 * Original copyright, applying to most contents (license remains unchanged): 
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * gimphistogram module Copyright (C) 1999 Jay Cox <jaycox@gimp.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef __PIKA_HISTOGRAM_H__
#define __PIKA_HISTOGRAM_H__


#include "pikaobject.h"


#define PIKA_TYPE_HISTOGRAM            (pika_histogram_get_type ())
#define PIKA_HISTOGRAM(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_HISTOGRAM, PikaHistogram))
#define PIKA_HISTOGRAM_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_HISTOGRAM, PikaHistogramClass))
#define PIKA_IS_HISTOGRAM(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_HISTOGRAM))
#define PIKA_IS_HISTOGRAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_HISTOGRAM))
#define PIKA_HISTOGRAM_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_HISTOGRAM, PikaHistogramClass))


typedef struct _PikaHistogramPrivate PikaHistogramPrivate;
typedef struct _PikaHistogramClass   PikaHistogramClass;

struct _PikaHistogram
{
  PikaObject            parent_instance;

  PikaHistogramPrivate *priv;
};

struct _PikaHistogramClass
{
  PikaObjectClass  parent_class;
};


GType           pika_histogram_get_type        (void) G_GNUC_CONST;

PikaHistogram * pika_histogram_new             (PikaTRCType           trc);

PikaHistogram * pika_histogram_duplicate       (PikaHistogram        *histogram);

void            pika_histogram_calculate       (PikaHistogram        *histogram,
                                                GeglBuffer           *buffer,
                                                const GeglRectangle  *buffer_rect,
                                                GeglBuffer           *mask,
                                                const GeglRectangle  *mask_rect);
PikaAsync     * pika_histogram_calculate_async (PikaHistogram        *histogram,
                                                GeglBuffer           *buffer,
                                                const GeglRectangle  *buffer_rect,
                                                GeglBuffer           *mask,
                                                const GeglRectangle  *mask_rect);

void            pika_histogram_clear_values    (PikaHistogram        *histogram,
                                                gint                  n_components);

gdouble         pika_histogram_get_maximum     (PikaHistogram        *histogram,
                                                PikaHistogramChannel  channel);
gdouble         pika_histogram_get_count       (PikaHistogram        *histogram,
                                                PikaHistogramChannel  channel,
                                                gint                  start,
                                                gint                  end);
gdouble         pika_histogram_get_mean        (PikaHistogram        *histogram,
                                                PikaHistogramChannel  channel,
                                                gint                  start,
                                                gint                  end);
gdouble         pika_histogram_get_median      (PikaHistogram        *histogram,
                                                PikaHistogramChannel  channel,
                                                gint                  start,
                                                gint                  end);
gdouble         pika_histogram_get_std_dev     (PikaHistogram        *histogram,
                                                PikaHistogramChannel  channel,
                                                gint                  start,
                                                gint                  end);
gdouble         pika_histogram_get_threshold   (PikaHistogram        *histogram,
                                                PikaHistogramChannel  channel,
                                                gint                  start,
                                                gint                  end);
gdouble         pika_histogram_get_value       (PikaHistogram        *histogram,
                                                PikaHistogramChannel  channel,
                                                gint                  bin);
gdouble         pika_histogram_get_component   (PikaHistogram        *histogram,
                                                gint                  component,
                                                gint                  bin);
gint            pika_histogram_n_components    (PikaHistogram        *histogram);
gint            pika_histogram_n_bins          (PikaHistogram        *histogram);
gboolean        pika_histogram_has_channel     (PikaHistogram        *histogram,
                                                PikaHistogramChannel  channel);


#endif /* __PIKA_HISTOGRAM_H__ */
