2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2006-01-12 08:50:44 +08:00
|
|
|
* gimphistogram module Copyright (C) 1999 Jay Cox <jaycox@gimp.org>
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2005-02-15 01:45:35 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2011-09-29 05:27:49 +08:00
|
|
|
#undef G_DISABLE_DEPRECATED /* GStaticMutex */
|
2012-04-17 03:01:39 +08:00
|
|
|
#include <gegl.h>
|
2000-12-19 22:43:54 +08:00
|
|
|
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
2012-03-25 05:29:53 +08:00
|
|
|
#include "core-types.h"
|
|
|
|
|
|
|
|
#include "base/pixel-processor.h"
|
|
|
|
#include "base/pixel-region.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2001-01-30 01:54:02 +08:00
|
|
|
#include "gimphistogram.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2005-02-14 09:33:14 +08:00
|
|
|
#ifdef ENABLE_MP
|
|
|
|
#define NUM_SLOTS GIMP_MAX_NUM_THREADS
|
|
|
|
#else
|
|
|
|
#define NUM_SLOTS 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-12-19 22:43:54 +08:00
|
|
|
struct _GimpHistogram
|
|
|
|
{
|
2008-02-05 05:41:57 +08:00
|
|
|
gint ref_count;
|
2005-02-14 09:33:14 +08:00
|
|
|
gint n_channels;
|
2000-12-19 22:43:54 +08:00
|
|
|
#ifdef ENABLE_MP
|
2005-02-14 09:33:14 +08:00
|
|
|
GStaticMutex mutex;
|
|
|
|
gchar slots[NUM_SLOTS];
|
2003-01-15 21:40:44 +08:00
|
|
|
#endif
|
2005-02-15 01:45:35 +08:00
|
|
|
gdouble *values[NUM_SLOTS];
|
2000-12-19 22:43:54 +08:00
|
|
|
};
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
|
|
|
|
|
2002-09-08 01:27:32 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2005-02-14 09:05:34 +08:00
|
|
|
static void gimp_histogram_alloc_values (GimpHistogram *histogram,
|
|
|
|
gint bytes);
|
|
|
|
static void gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
|
|
|
PixelRegion *region,
|
|
|
|
PixelRegion *mask);
|
2002-09-08 01:27:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
GimpHistogram *
|
2005-02-14 09:05:34 +08:00
|
|
|
gimp_histogram_new (void)
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
{
|
2007-05-22 18:43:48 +08:00
|
|
|
GimpHistogram *histogram = g_slice_new0 (GimpHistogram);
|
2003-01-15 21:40:44 +08:00
|
|
|
|
2008-02-05 05:41:57 +08:00
|
|
|
histogram->ref_count = 1;
|
|
|
|
|
2005-02-14 09:33:14 +08:00
|
|
|
#ifdef ENABLE_MP
|
|
|
|
g_static_mutex_init (&histogram->mutex);
|
|
|
|
#endif
|
2000-12-19 22:43:54 +08:00
|
|
|
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
return histogram;
|
|
|
|
}
|
|
|
|
|
2008-02-05 05:41:57 +08:00
|
|
|
GimpHistogram *
|
|
|
|
gimp_histogram_ref (GimpHistogram *histogram)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (histogram != NULL, NULL);
|
|
|
|
|
|
|
|
histogram->ref_count++;
|
|
|
|
|
|
|
|
return histogram;
|
|
|
|
}
|
|
|
|
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
void
|
2008-02-05 05:41:57 +08:00
|
|
|
gimp_histogram_unref (GimpHistogram *histogram)
|
2002-09-08 01:27:32 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (histogram != NULL);
|
|
|
|
|
2008-02-05 05:41:57 +08:00
|
|
|
histogram->ref_count--;
|
|
|
|
|
|
|
|
if (histogram->ref_count == 0)
|
|
|
|
{
|
2012-04-16 01:09:35 +08:00
|
|
|
gimp_histogram_clear_values (histogram);
|
2008-02-05 05:41:57 +08:00
|
|
|
g_slice_free (GimpHistogram, histogram);
|
|
|
|
}
|
2002-09-08 01:27:32 +08:00
|
|
|
}
|
|
|
|
|
2008-07-22 17:29:35 +08:00
|
|
|
/**
|
|
|
|
* gimp_histogram_duplicate:
|
|
|
|
* @histogram: a %GimpHistogram
|
|
|
|
*
|
|
|
|
* Creates a duplicate of @histogram. The duplicate has a reference
|
|
|
|
* count of 1 and contains the values from @histogram.
|
|
|
|
*
|
|
|
|
* Return value: a newly allocated %GimpHistogram
|
|
|
|
**/
|
|
|
|
GimpHistogram *
|
|
|
|
gimp_histogram_duplicate (GimpHistogram *histogram)
|
|
|
|
{
|
|
|
|
GimpHistogram *dup;
|
|
|
|
|
|
|
|
g_return_val_if_fail (histogram != NULL, NULL);
|
|
|
|
|
|
|
|
dup = gimp_histogram_new ();
|
|
|
|
|
|
|
|
#ifdef ENABLE_MP
|
|
|
|
g_static_mutex_lock (&histogram->mutex);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
dup->n_channels = histogram->n_channels;
|
|
|
|
dup->values[0] = g_memdup (histogram->values[0],
|
|
|
|
sizeof (gdouble) * dup->n_channels * 256);
|
|
|
|
|
|
|
|
#ifdef ENABLE_MP
|
|
|
|
g_static_mutex_unlock (&histogram->mutex);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return dup;
|
|
|
|
}
|
|
|
|
|
2012-04-17 03:01:39 +08:00
|
|
|
void
|
|
|
|
gimp_histogram_calc_gegl (GimpHistogram *histogram,
|
|
|
|
GeglBuffer *buffer,
|
|
|
|
const GeglRectangle *buffer_rect,
|
|
|
|
GeglBuffer *mask,
|
|
|
|
const GeglRectangle *mask_rect)
|
|
|
|
{
|
|
|
|
GeglBufferIterator *iter;
|
|
|
|
const Babl *format;
|
|
|
|
gint bpp;
|
|
|
|
gdouble *values;
|
|
|
|
|
|
|
|
g_return_if_fail (histogram != NULL);
|
|
|
|
g_return_if_fail (GEGL_IS_BUFFER (buffer));
|
|
|
|
g_return_if_fail (buffer_rect != NULL);
|
|
|
|
|
|
|
|
format = gegl_buffer_get_format (buffer);
|
|
|
|
bpp = babl_format_get_bytes_per_pixel (format);
|
|
|
|
|
|
|
|
gimp_histogram_alloc_values (histogram, bpp);
|
|
|
|
|
|
|
|
iter = gegl_buffer_iterator_new (buffer, buffer_rect, 0, NULL,
|
|
|
|
GEGL_BUFFER_READ, GEGL_ABYSS_NONE);
|
|
|
|
|
|
|
|
if (mask)
|
|
|
|
gegl_buffer_iterator_add (iter, mask, mask_rect, 0,
|
|
|
|
babl_format ("Y float"),
|
|
|
|
GEGL_BUFFER_READ, GEGL_ABYSS_NONE);
|
|
|
|
|
|
|
|
values = histogram->values[0];
|
|
|
|
|
|
|
|
#define VALUE(c,i) (values[(c) * 256 + (i)])
|
|
|
|
|
|
|
|
while (gegl_buffer_iterator_next (iter))
|
|
|
|
{
|
|
|
|
const guchar *data = iter->data[0];
|
|
|
|
gint max;
|
|
|
|
|
|
|
|
if (mask)
|
|
|
|
{
|
|
|
|
const gfloat *mask_data = iter->data[1];
|
|
|
|
|
|
|
|
switch (bpp)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
while (iter->length)
|
|
|
|
{
|
|
|
|
const gdouble masked = *mask_data;
|
|
|
|
|
|
|
|
VALUE (0, data[0]) += masked;
|
|
|
|
|
|
|
|
data += bpp;
|
|
|
|
mask_data += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
while (iter->length--)
|
|
|
|
{
|
|
|
|
const gdouble masked = *mask_data;
|
|
|
|
const gdouble weight = data[1] / 255.0;
|
|
|
|
|
|
|
|
VALUE (0, data[0]) += weight * masked;
|
|
|
|
VALUE (1, data[1]) += masked;
|
|
|
|
|
|
|
|
data += bpp;
|
|
|
|
mask_data += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* calculate separate value values */
|
|
|
|
while (iter->length--)
|
|
|
|
{
|
|
|
|
const gdouble masked = *mask_data;
|
|
|
|
|
|
|
|
VALUE (1, data[0]) += masked;
|
|
|
|
VALUE (2, data[1]) += masked;
|
|
|
|
VALUE (3, data[2]) += masked;
|
|
|
|
|
|
|
|
max = MAX (data[0], data[1]);
|
|
|
|
max = MAX (data[2], max);
|
|
|
|
|
|
|
|
VALUE (0, max) += masked;
|
|
|
|
|
|
|
|
data += bpp;
|
|
|
|
mask_data += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: /* calculate separate value values */
|
|
|
|
while (iter->length--)
|
|
|
|
{
|
|
|
|
const gdouble masked = *mask_data;
|
|
|
|
const gdouble weight = data[3] / 255.0;
|
|
|
|
|
|
|
|
VALUE (1, data[0]) += weight * masked;
|
|
|
|
VALUE (2, data[1]) += weight * masked;
|
|
|
|
VALUE (3, data[2]) += weight * masked;
|
|
|
|
VALUE (4, data[3]) += masked;
|
|
|
|
|
|
|
|
max = MAX (data[0], data[1]);
|
|
|
|
max = MAX (data[2], max);
|
|
|
|
|
|
|
|
VALUE (0, max) += weight * masked;
|
|
|
|
|
|
|
|
data += bpp;
|
|
|
|
mask_data += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* no mask */
|
|
|
|
{
|
|
|
|
switch (bpp)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
while (iter->length--)
|
|
|
|
{
|
|
|
|
VALUE (0, data[0]) += 1.0;
|
|
|
|
|
|
|
|
data += bpp;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
while (iter->length--)
|
|
|
|
{
|
|
|
|
const gdouble weight = data[1] / 255;
|
|
|
|
|
|
|
|
VALUE (0, data[0]) += weight;
|
|
|
|
VALUE (1, data[1]) += 1.0;
|
|
|
|
|
|
|
|
data += bpp;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* calculate separate value values */
|
|
|
|
while (iter->length--)
|
|
|
|
{
|
|
|
|
VALUE (1, data[0]) += 1.0;
|
|
|
|
VALUE (2, data[1]) += 1.0;
|
|
|
|
VALUE (3, data[2]) += 1.0;
|
|
|
|
|
|
|
|
max = MAX (data[0], data[1]);
|
|
|
|
max = MAX (data[2], max);
|
|
|
|
|
|
|
|
VALUE (0, max) += 1.0;
|
|
|
|
|
|
|
|
data += bpp;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: /* calculate separate value values */
|
|
|
|
while (iter->length--)
|
|
|
|
{
|
|
|
|
const gdouble weight = data[3] / 255;
|
|
|
|
|
|
|
|
VALUE (1, data[0]) += weight;
|
|
|
|
VALUE (2, data[1]) += weight;
|
|
|
|
VALUE (3, data[2]) += weight;
|
|
|
|
VALUE (4, data[3]) += 1.0;
|
|
|
|
|
|
|
|
max = MAX (data[0], data[1]);
|
|
|
|
max = MAX (data[2], max);
|
|
|
|
|
|
|
|
VALUE (0, max) += weight;
|
|
|
|
|
|
|
|
data += bpp;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef VALUE
|
|
|
|
}
|
|
|
|
|
2002-09-08 01:27:32 +08:00
|
|
|
void
|
2003-10-31 01:48:16 +08:00
|
|
|
gimp_histogram_calculate (GimpHistogram *histogram,
|
2006-04-12 20:49:29 +08:00
|
|
|
PixelRegion *region,
|
|
|
|
PixelRegion *mask)
|
2002-09-08 01:27:32 +08:00
|
|
|
{
|
2005-02-14 09:33:14 +08:00
|
|
|
gint i;
|
2002-09-08 01:27:32 +08:00
|
|
|
|
|
|
|
g_return_if_fail (histogram != NULL);
|
2012-04-16 01:09:35 +08:00
|
|
|
g_return_if_fail (region != NULL);
|
2004-01-13 21:35:58 +08:00
|
|
|
|
|
|
|
gimp_histogram_alloc_values (histogram, region->bytes);
|
2002-09-08 01:27:32 +08:00
|
|
|
|
2005-02-12 01:03:56 +08:00
|
|
|
pixel_regions_process_parallel ((PixelProcessorFunc)
|
|
|
|
gimp_histogram_calculate_sub_region,
|
2004-01-13 21:35:58 +08:00
|
|
|
histogram, 2, region, mask);
|
2002-09-08 01:27:32 +08:00
|
|
|
|
|
|
|
#ifdef ENABLE_MP
|
2005-02-14 09:33:14 +08:00
|
|
|
/* add up all slots */
|
|
|
|
for (i = 1; i < NUM_SLOTS; i++)
|
|
|
|
if (histogram->values[i])
|
|
|
|
{
|
2005-02-15 01:45:35 +08:00
|
|
|
gint j;
|
2004-01-13 21:35:58 +08:00
|
|
|
|
2005-02-15 01:45:35 +08:00
|
|
|
for (j = 0; j < histogram->n_channels * 256; j++)
|
|
|
|
histogram->values[0][j] += histogram->values[i][j];
|
2005-02-14 09:33:14 +08:00
|
|
|
}
|
2004-01-13 21:35:58 +08:00
|
|
|
#endif
|
2002-09-08 01:27:32 +08:00
|
|
|
}
|
|
|
|
|
2012-04-16 01:09:35 +08:00
|
|
|
void
|
|
|
|
gimp_histogram_clear_values (GimpHistogram *histogram)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_if_fail (histogram != NULL);
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_SLOTS; i++)
|
|
|
|
if (histogram->values[i])
|
|
|
|
{
|
|
|
|
g_free (histogram->values[i]);
|
|
|
|
histogram->values[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
histogram->n_channels = 0;
|
|
|
|
}
|
|
|
|
|
2005-02-15 01:45:35 +08:00
|
|
|
|
|
|
|
#define HISTOGRAM_VALUE(c,i) (histogram->values[0][(c) * 256 + (i)])
|
|
|
|
|
|
|
|
|
2002-09-08 01:27:32 +08:00
|
|
|
gdouble
|
2003-10-31 01:48:16 +08:00
|
|
|
gimp_histogram_get_maximum (GimpHistogram *histogram,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpHistogramChannel channel)
|
2002-09-08 01:27:32 +08:00
|
|
|
{
|
|
|
|
gdouble max = 0.0;
|
|
|
|
gint x;
|
|
|
|
|
|
|
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
|
|
|
|
2004-01-13 21:35:58 +08:00
|
|
|
/* the gray alpha channel is in slot 1 */
|
|
|
|
if (histogram->n_channels == 3 && channel == GIMP_HISTOGRAM_ALPHA)
|
|
|
|
channel = 1;
|
|
|
|
|
2005-03-16 23:52:13 +08:00
|
|
|
if (! histogram->values[0] ||
|
2004-07-07 00:33:30 +08:00
|
|
|
(channel != GIMP_HISTOGRAM_RGB && channel >= histogram->n_channels))
|
2003-11-01 10:39:34 +08:00
|
|
|
return 0.0;
|
|
|
|
|
2004-07-07 00:33:30 +08:00
|
|
|
if (channel == GIMP_HISTOGRAM_RGB)
|
|
|
|
for (x = 0; x < 256; x++)
|
|
|
|
{
|
2006-04-12 20:49:29 +08:00
|
|
|
max = MAX (max, HISTOGRAM_VALUE (GIMP_HISTOGRAM_RED, x));
|
|
|
|
max = MAX (max, HISTOGRAM_VALUE (GIMP_HISTOGRAM_GREEN, x));
|
|
|
|
max = MAX (max, HISTOGRAM_VALUE (GIMP_HISTOGRAM_BLUE, x));
|
2004-07-07 00:33:30 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
for (x = 0; x < 256; x++)
|
2005-02-15 01:45:35 +08:00
|
|
|
{
|
|
|
|
max = MAX (max, HISTOGRAM_VALUE (channel, x));
|
|
|
|
}
|
2002-09-08 01:27:32 +08:00
|
|
|
|
|
|
|
return max;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdouble
|
2003-10-31 01:48:16 +08:00
|
|
|
gimp_histogram_get_value (GimpHistogram *histogram,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpHistogramChannel channel,
|
|
|
|
gint bin)
|
2002-09-08 01:27:32 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
|
|
|
|
2004-01-13 21:35:58 +08:00
|
|
|
/* the gray alpha channel is in slot 1 */
|
|
|
|
if (histogram->n_channels == 3 && channel == GIMP_HISTOGRAM_ALPHA)
|
|
|
|
channel = 1;
|
|
|
|
|
2005-03-16 23:52:13 +08:00
|
|
|
if (! histogram->values[0] ||
|
2004-07-07 00:33:30 +08:00
|
|
|
bin < 0 || bin >= 256 ||
|
|
|
|
(channel == GIMP_HISTOGRAM_RGB && histogram->n_channels < 4) ||
|
|
|
|
(channel != GIMP_HISTOGRAM_RGB && channel >= histogram->n_channels))
|
|
|
|
return 0.0;
|
|
|
|
|
|
|
|
if (channel == GIMP_HISTOGRAM_RGB)
|
|
|
|
{
|
2005-02-15 01:45:35 +08:00
|
|
|
gdouble min = HISTOGRAM_VALUE (GIMP_HISTOGRAM_RED, bin);
|
2004-07-07 00:33:30 +08:00
|
|
|
|
2005-02-15 01:45:35 +08:00
|
|
|
min = MIN (min, HISTOGRAM_VALUE (GIMP_HISTOGRAM_GREEN, bin));
|
2002-09-08 01:27:32 +08:00
|
|
|
|
2005-02-15 01:45:35 +08:00
|
|
|
return MIN (min, HISTOGRAM_VALUE (GIMP_HISTOGRAM_BLUE, bin));
|
2004-07-07 00:33:30 +08:00
|
|
|
}
|
|
|
|
else
|
2005-02-14 09:33:14 +08:00
|
|
|
{
|
2005-02-15 01:45:35 +08:00
|
|
|
return HISTOGRAM_VALUE (channel, bin);
|
2005-02-14 09:33:14 +08:00
|
|
|
}
|
2002-09-08 01:27:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gdouble
|
2003-10-31 01:48:16 +08:00
|
|
|
gimp_histogram_get_channel (GimpHistogram *histogram,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpHistogramChannel channel,
|
|
|
|
gint bin)
|
2002-09-08 01:27:32 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
|
|
|
|
|
|
|
if (histogram->n_channels > 3)
|
2005-02-15 01:45:35 +08:00
|
|
|
channel++;
|
|
|
|
|
|
|
|
return gimp_histogram_get_value (histogram, channel, bin);
|
2002-09-08 01:27:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
2004-01-13 19:51:45 +08:00
|
|
|
gimp_histogram_n_channels (GimpHistogram *histogram)
|
2002-09-08 01:27:32 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (histogram != NULL, 0);
|
|
|
|
|
|
|
|
return histogram->n_channels - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdouble
|
2003-10-31 01:48:16 +08:00
|
|
|
gimp_histogram_get_count (GimpHistogram *histogram,
|
|
|
|
GimpHistogramChannel channel,
|
2006-04-12 20:49:29 +08:00
|
|
|
gint start,
|
|
|
|
gint end)
|
2002-09-08 01:27:32 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gdouble count = 0.0;
|
|
|
|
|
|
|
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
|
|
|
|
2004-01-13 21:35:58 +08:00
|
|
|
/* the gray alpha channel is in slot 1 */
|
|
|
|
if (histogram->n_channels == 3 && channel == GIMP_HISTOGRAM_ALPHA)
|
|
|
|
channel = 1;
|
|
|
|
|
2004-07-07 00:33:30 +08:00
|
|
|
if (channel == GIMP_HISTOGRAM_RGB)
|
|
|
|
return (gimp_histogram_get_count (histogram,
|
|
|
|
GIMP_HISTOGRAM_RED, start, end) +
|
2006-04-12 20:49:29 +08:00
|
|
|
gimp_histogram_get_count (histogram,
|
2004-07-07 00:33:30 +08:00
|
|
|
GIMP_HISTOGRAM_GREEN, start, end) +
|
2006-04-12 20:49:29 +08:00
|
|
|
gimp_histogram_get_count (histogram,
|
2004-07-07 00:33:30 +08:00
|
|
|
GIMP_HISTOGRAM_BLUE, start, end));
|
|
|
|
|
2005-03-16 23:52:13 +08:00
|
|
|
if (! histogram->values[0] ||
|
2004-07-07 00:33:30 +08:00
|
|
|
start > end ||
|
|
|
|
channel >= histogram->n_channels)
|
2003-11-01 10:39:34 +08:00
|
|
|
return 0.0;
|
|
|
|
|
2004-07-07 00:33:30 +08:00
|
|
|
start = CLAMP (start, 0, 255);
|
|
|
|
end = CLAMP (end, 0, 255);
|
|
|
|
|
2002-09-08 01:27:32 +08:00
|
|
|
for (i = start; i <= end; i++)
|
2005-02-15 01:45:35 +08:00
|
|
|
count += HISTOGRAM_VALUE (channel, i);
|
2002-09-08 01:27:32 +08:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdouble
|
2003-10-31 01:48:16 +08:00
|
|
|
gimp_histogram_get_mean (GimpHistogram *histogram,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpHistogramChannel channel,
|
|
|
|
gint start,
|
|
|
|
gint end)
|
2002-09-08 01:27:32 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gdouble mean = 0.0;
|
|
|
|
gdouble count;
|
|
|
|
|
|
|
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
|
|
|
|
2004-01-13 21:35:58 +08:00
|
|
|
/* the gray alpha channel is in slot 1 */
|
|
|
|
if (histogram->n_channels == 3 && channel == GIMP_HISTOGRAM_ALPHA)
|
|
|
|
channel = 1;
|
|
|
|
|
2005-03-16 23:52:13 +08:00
|
|
|
if (! histogram->values[0] ||
|
2004-07-07 00:33:30 +08:00
|
|
|
start > end ||
|
|
|
|
(channel == GIMP_HISTOGRAM_RGB && histogram->n_channels < 4) ||
|
|
|
|
(channel != GIMP_HISTOGRAM_RGB && channel >= histogram->n_channels))
|
2003-11-01 10:39:34 +08:00
|
|
|
return 0.0;
|
|
|
|
|
2004-07-07 00:33:30 +08:00
|
|
|
start = CLAMP (start, 0, 255);
|
|
|
|
end = CLAMP (end, 0, 255);
|
|
|
|
|
|
|
|
if (channel == GIMP_HISTOGRAM_RGB)
|
|
|
|
{
|
|
|
|
for (i = start; i <= end; i++)
|
2006-04-12 20:49:29 +08:00
|
|
|
mean += (i * HISTOGRAM_VALUE (GIMP_HISTOGRAM_RED, i) +
|
|
|
|
i * HISTOGRAM_VALUE (GIMP_HISTOGRAM_GREEN, i) +
|
|
|
|
i * HISTOGRAM_VALUE (GIMP_HISTOGRAM_BLUE, i));
|
2004-07-07 00:33:30 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = start; i <= end; i++)
|
2006-04-12 20:49:29 +08:00
|
|
|
mean += i * HISTOGRAM_VALUE (channel, i);
|
2004-07-07 00:33:30 +08:00
|
|
|
}
|
2002-09-08 01:27:32 +08:00
|
|
|
|
2003-10-31 01:48:16 +08:00
|
|
|
count = gimp_histogram_get_count (histogram, channel, start, end);
|
2002-09-08 01:27:32 +08:00
|
|
|
|
|
|
|
if (count > 0.0)
|
|
|
|
return mean / count;
|
|
|
|
|
|
|
|
return mean;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
2003-10-31 01:48:16 +08:00
|
|
|
gimp_histogram_get_median (GimpHistogram *histogram,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpHistogramChannel channel,
|
|
|
|
gint start,
|
|
|
|
gint end)
|
2002-09-08 01:27:32 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gdouble sum = 0.0;
|
|
|
|
gdouble count;
|
|
|
|
|
|
|
|
g_return_val_if_fail (histogram != NULL, -1);
|
|
|
|
|
2004-01-13 21:35:58 +08:00
|
|
|
/* the gray alpha channel is in slot 1 */
|
|
|
|
if (histogram->n_channels == 3 && channel == GIMP_HISTOGRAM_ALPHA)
|
|
|
|
channel = 1;
|
|
|
|
|
2005-03-16 23:52:13 +08:00
|
|
|
if (! histogram->values[0] ||
|
2004-07-07 00:33:30 +08:00
|
|
|
start > end ||
|
|
|
|
(channel == GIMP_HISTOGRAM_RGB && histogram->n_channels < 4) ||
|
|
|
|
(channel != GIMP_HISTOGRAM_RGB && channel >= histogram->n_channels))
|
2003-11-01 10:39:34 +08:00
|
|
|
return 0;
|
|
|
|
|
2004-07-07 00:33:30 +08:00
|
|
|
start = CLAMP (start, 0, 255);
|
|
|
|
end = CLAMP (end, 0, 255);
|
|
|
|
|
2003-10-31 01:48:16 +08:00
|
|
|
count = gimp_histogram_get_count (histogram, channel, start, end);
|
2002-09-08 01:27:32 +08:00
|
|
|
|
2004-07-07 00:33:30 +08:00
|
|
|
if (channel == GIMP_HISTOGRAM_RGB)
|
|
|
|
for (i = start; i <= end; i++)
|
|
|
|
{
|
2006-04-12 20:49:29 +08:00
|
|
|
sum += (HISTOGRAM_VALUE (GIMP_HISTOGRAM_RED, i) +
|
|
|
|
HISTOGRAM_VALUE (GIMP_HISTOGRAM_GREEN, i) +
|
|
|
|
HISTOGRAM_VALUE (GIMP_HISTOGRAM_BLUE, i));
|
2002-09-08 01:27:32 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
if (sum * 2 > count)
|
|
|
|
return i;
|
2004-07-07 00:33:30 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
for (i = start; i <= end; i++)
|
|
|
|
{
|
2006-04-12 20:49:29 +08:00
|
|
|
sum += HISTOGRAM_VALUE (channel, i);
|
2004-07-07 00:33:30 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
if (sum * 2 > count)
|
|
|
|
return i;
|
2004-07-07 00:33:30 +08:00
|
|
|
}
|
2002-09-08 01:27:32 +08:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-04-21 17:40:27 +08:00
|
|
|
/*
|
|
|
|
* adapted from GNU ocrad 0.14 : page_image_io.cc : otsu_th
|
|
|
|
*
|
|
|
|
* N. Otsu, "A threshold selection method from gray-level histograms,"
|
|
|
|
* IEEE Trans. Systems, Man, and Cybernetics, vol. 9, no. 1, pp. 62-66, 1979.
|
|
|
|
*/
|
|
|
|
gdouble
|
|
|
|
gimp_histogram_get_threshold (GimpHistogram *histogram,
|
|
|
|
GimpHistogramChannel channel,
|
|
|
|
gint start,
|
|
|
|
gint end)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gint maxval;
|
|
|
|
gdouble *hist = NULL;
|
|
|
|
gdouble *chist = NULL;
|
|
|
|
gdouble *cmom = NULL;
|
|
|
|
gdouble hist_max = 0.0;
|
|
|
|
gdouble chist_max = 0.0;
|
|
|
|
gdouble cmom_max = 0.0;
|
|
|
|
gdouble bvar_max = 0.0;
|
|
|
|
gint threshold = 127;
|
|
|
|
|
|
|
|
g_return_val_if_fail (histogram != NULL, -1);
|
|
|
|
|
|
|
|
/* the gray alpha channel is in slot 1 */
|
|
|
|
if (histogram->n_channels == 3 && channel == GIMP_HISTOGRAM_ALPHA)
|
|
|
|
channel = 1;
|
|
|
|
|
|
|
|
if (! histogram->values[0] ||
|
|
|
|
start > end ||
|
|
|
|
(channel == GIMP_HISTOGRAM_RGB && histogram->n_channels < 4) ||
|
|
|
|
(channel != GIMP_HISTOGRAM_RGB && channel >= histogram->n_channels))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
start = CLAMP (start, 0, 255);
|
|
|
|
end = CLAMP (end, 0, 255);
|
|
|
|
|
|
|
|
maxval = end - start;
|
|
|
|
|
|
|
|
hist = g_newa (gdouble, maxval + 1);
|
|
|
|
chist = g_newa (gdouble, maxval + 1);
|
|
|
|
cmom = g_newa (gdouble, maxval + 1);
|
|
|
|
|
|
|
|
if (channel == GIMP_HISTOGRAM_RGB)
|
|
|
|
{
|
|
|
|
for (i = start; i <= end; i++)
|
|
|
|
hist[i - start] = (HISTOGRAM_VALUE (GIMP_HISTOGRAM_RED, i) +
|
|
|
|
HISTOGRAM_VALUE (GIMP_HISTOGRAM_GREEN, i) +
|
|
|
|
HISTOGRAM_VALUE (GIMP_HISTOGRAM_BLUE, i));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = start; i <= end; i++)
|
|
|
|
hist[i - start] = HISTOGRAM_VALUE (channel, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
hist_max = hist[0];
|
|
|
|
chist[0] = hist[0];
|
|
|
|
cmom[0] = 0;
|
|
|
|
|
2011-10-13 13:13:09 +08:00
|
|
|
for (i = 1; i <= maxval; i++)
|
2006-04-21 17:40:27 +08:00
|
|
|
{
|
|
|
|
if (hist[i] > hist_max)
|
|
|
|
hist_max = hist[i];
|
|
|
|
|
|
|
|
chist[i] = chist[i-1] + hist[i];
|
|
|
|
cmom[i] = cmom[i-1] + i * hist[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
chist_max = chist[maxval];
|
|
|
|
cmom_max = cmom[maxval];
|
|
|
|
bvar_max = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < maxval; ++i)
|
|
|
|
if (chist[i] > 0 && chist[i] < chist_max)
|
|
|
|
{
|
|
|
|
gdouble bvar;
|
|
|
|
|
|
|
|
bvar = (gdouble) cmom[i] / chist[i];
|
|
|
|
bvar -= (cmom_max - cmom[i]) / (chist_max - chist[i]);
|
|
|
|
bvar *= bvar;
|
|
|
|
bvar *= chist[i];
|
|
|
|
bvar *= chist_max - chist[i];
|
|
|
|
|
|
|
|
if (bvar > bvar_max)
|
|
|
|
{
|
|
|
|
bvar_max = bvar;
|
|
|
|
threshold = start + i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return threshold;
|
|
|
|
}
|
|
|
|
|
2002-09-08 01:27:32 +08:00
|
|
|
gdouble
|
2003-10-31 01:48:16 +08:00
|
|
|
gimp_histogram_get_std_dev (GimpHistogram *histogram,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpHistogramChannel channel,
|
|
|
|
gint start,
|
|
|
|
gint end)
|
2002-09-08 01:27:32 +08:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gdouble dev = 0.0;
|
|
|
|
gdouble count;
|
|
|
|
gdouble mean;
|
|
|
|
|
|
|
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
|
|
|
|
2004-01-13 21:35:58 +08:00
|
|
|
/* the gray alpha channel is in slot 1 */
|
|
|
|
if (histogram->n_channels == 3 && channel == GIMP_HISTOGRAM_ALPHA)
|
|
|
|
channel = 1;
|
|
|
|
|
2005-03-16 23:52:13 +08:00
|
|
|
if (! histogram->values[0] ||
|
2004-07-07 00:33:30 +08:00
|
|
|
start > end ||
|
|
|
|
(channel == GIMP_HISTOGRAM_RGB && histogram->n_channels < 4) ||
|
|
|
|
(channel != GIMP_HISTOGRAM_RGB && channel >= histogram->n_channels))
|
2003-11-01 10:39:34 +08:00
|
|
|
return 0.0;
|
|
|
|
|
2002-09-08 01:27:32 +08:00
|
|
|
mean = gimp_histogram_get_mean (histogram, channel, start, end);
|
2003-10-31 01:48:16 +08:00
|
|
|
count = gimp_histogram_get_count (histogram, channel, start, end);
|
2002-09-08 01:27:32 +08:00
|
|
|
|
|
|
|
if (count == 0.0)
|
|
|
|
count = 1.0;
|
|
|
|
|
|
|
|
for (i = start; i <= end; i++)
|
2007-08-13 18:34:35 +08:00
|
|
|
{
|
|
|
|
gdouble value;
|
|
|
|
|
|
|
|
if (channel == GIMP_HISTOGRAM_RGB)
|
|
|
|
{
|
|
|
|
value = (HISTOGRAM_VALUE (GIMP_HISTOGRAM_RED, i) +
|
|
|
|
HISTOGRAM_VALUE (GIMP_HISTOGRAM_GREEN, i) +
|
|
|
|
HISTOGRAM_VALUE (GIMP_HISTOGRAM_BLUE, i));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
value = gimp_histogram_get_value (histogram, channel, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
dev += value * SQR (i - mean);
|
|
|
|
}
|
2002-09-08 01:27:32 +08:00
|
|
|
|
|
|
|
return sqrt (dev / count);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
2003-10-31 01:48:16 +08:00
|
|
|
gimp_histogram_alloc_values (GimpHistogram *histogram,
|
2002-09-08 01:27:32 +08:00
|
|
|
gint bytes)
|
|
|
|
{
|
|
|
|
if (bytes + 1 != histogram->n_channels)
|
|
|
|
{
|
2012-04-16 01:09:35 +08:00
|
|
|
gimp_histogram_clear_values (histogram);
|
2002-09-08 01:27:32 +08:00
|
|
|
|
|
|
|
histogram->n_channels = bytes + 1;
|
2005-02-14 09:33:14 +08:00
|
|
|
|
2012-04-17 03:01:39 +08:00
|
|
|
histogram->values[0] = g_new0 (gdouble, histogram->n_channels * 256);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_SLOTS; i++)
|
|
|
|
if (histogram->values[i])
|
|
|
|
memset (histogram->values[i],
|
|
|
|
0, histogram->n_channels * 256 * sizeof (gdouble));
|
2002-09-08 01:27:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-19 22:43:54 +08:00
|
|
|
static void
|
2000-01-09 20:40:10 +08:00
|
|
|
gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
2006-04-12 20:49:29 +08:00
|
|
|
PixelRegion *region,
|
|
|
|
PixelRegion *mask)
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
{
|
2000-12-19 22:43:54 +08:00
|
|
|
const guchar *src, *msrc;
|
|
|
|
const guchar *m, *s;
|
2005-02-15 01:45:35 +08:00
|
|
|
gdouble *values;
|
|
|
|
gint h, w, max;
|
2000-12-19 22:43:54 +08:00
|
|
|
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
#ifdef ENABLE_MP
|
2000-12-19 22:43:54 +08:00
|
|
|
gint slot = 0;
|
|
|
|
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
/* find an unused temporary slot to put our results in and lock it */
|
2005-02-14 07:50:18 +08:00
|
|
|
g_static_mutex_lock (&histogram->mutex);
|
2003-01-15 21:40:44 +08:00
|
|
|
|
2005-02-14 09:33:14 +08:00
|
|
|
while (histogram->slots[slot])
|
2003-01-15 21:40:44 +08:00
|
|
|
slot++;
|
|
|
|
|
2005-02-14 09:33:14 +08:00
|
|
|
values = histogram->values[slot];
|
|
|
|
histogram->slots[slot] = 1;
|
2003-01-15 21:40:44 +08:00
|
|
|
|
2005-02-14 07:50:18 +08:00
|
|
|
g_static_mutex_unlock (&histogram->mutex);
|
2003-01-15 21:40:44 +08:00
|
|
|
|
2005-02-14 09:05:34 +08:00
|
|
|
if (! values)
|
|
|
|
{
|
2005-02-15 01:45:35 +08:00
|
|
|
histogram->values[slot] = g_new0 (gdouble, histogram->n_channels * 256);
|
2005-02-14 09:33:14 +08:00
|
|
|
values = histogram->values[slot];
|
2005-02-14 09:05:34 +08:00
|
|
|
}
|
|
|
|
|
2003-01-15 21:40:44 +08:00
|
|
|
#else
|
2005-02-14 09:33:14 +08:00
|
|
|
values = histogram->values[0];
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
#endif
|
2000-12-19 22:43:54 +08:00
|
|
|
|
2005-02-15 01:45:35 +08:00
|
|
|
#define VALUE(c,i) (values[(c) * 256 + (i)])
|
|
|
|
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
h = region->h;
|
2000-12-19 22:43:54 +08:00
|
|
|
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
if (mask)
|
|
|
|
{
|
2004-01-13 06:35:17 +08:00
|
|
|
src = region->data;
|
2001-02-06 15:15:22 +08:00
|
|
|
msrc = mask->data;
|
2000-12-19 22:43:54 +08:00
|
|
|
|
2005-07-30 22:05:57 +08:00
|
|
|
switch (region->bytes)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
|
|
|
m = msrc;
|
2011-10-12 20:58:55 +08:00
|
|
|
w = region->w;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
while (w--)
|
|
|
|
{
|
2007-09-20 01:21:41 +08:00
|
|
|
const gdouble masked = m[0] / 255.0;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
VALUE (0, s[0]) += masked;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
s += 1;
|
|
|
|
m += 1;
|
|
|
|
}
|
2000-12-19 22:43:54 +08:00
|
|
|
|
2005-07-30 22:05:57 +08:00
|
|
|
src += region->rowstride;
|
|
|
|
msrc += mask->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
|
|
|
m = msrc;
|
2011-10-12 20:58:55 +08:00
|
|
|
w = region->w;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
while (w--)
|
|
|
|
{
|
2007-09-20 01:21:41 +08:00
|
|
|
const gdouble masked = m[0] / 255.0;
|
|
|
|
const gdouble weight = s[1] / 255.0;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2007-09-20 01:21:41 +08:00
|
|
|
VALUE (0, s[0]) += weight * masked;
|
2006-04-12 20:49:29 +08:00
|
|
|
VALUE (1, s[1]) += masked;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
s += 2;
|
|
|
|
m += 1;
|
|
|
|
}
|
2000-12-19 22:43:54 +08:00
|
|
|
|
2005-07-30 22:05:57 +08:00
|
|
|
src += region->rowstride;
|
|
|
|
msrc += mask->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* calculate separate value values */
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
|
|
|
m = msrc;
|
2011-10-12 20:58:55 +08:00
|
|
|
w = region->w;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
while (w--)
|
|
|
|
{
|
2007-09-20 01:21:41 +08:00
|
|
|
const gdouble masked = m[0] / 255.0;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
VALUE (1, s[0]) += masked;
|
|
|
|
VALUE (2, s[1]) += masked;
|
|
|
|
VALUE (3, s[2]) += masked;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
max = (s[0] > s[1]) ? s[0] : s[1];
|
2003-01-15 21:40:44 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
if (s[2] > max)
|
|
|
|
VALUE (0, s[2]) += masked;
|
|
|
|
else
|
|
|
|
VALUE (0, max) += masked;
|
2003-01-15 21:40:44 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
s += 3;
|
|
|
|
m += 1;
|
|
|
|
}
|
2000-12-19 22:43:54 +08:00
|
|
|
|
2005-07-30 22:05:57 +08:00
|
|
|
src += region->rowstride;
|
|
|
|
msrc += mask->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: /* calculate separate value values */
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
|
|
|
m = msrc;
|
2011-10-12 20:58:55 +08:00
|
|
|
w = region->w;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
while (w--)
|
|
|
|
{
|
2007-09-20 01:21:41 +08:00
|
|
|
const gdouble masked = m[0] / 255.0;
|
|
|
|
const gdouble weight = s[3] / 255.0;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2007-09-20 01:21:41 +08:00
|
|
|
VALUE (1, s[0]) += weight * masked;
|
|
|
|
VALUE (2, s[1]) += weight * masked;
|
|
|
|
VALUE (3, s[2]) += weight * masked;
|
2006-04-12 20:49:29 +08:00
|
|
|
VALUE (4, s[3]) += masked;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
max = (s[0] > s[1]) ? s[0] : s[1];
|
2003-01-15 21:40:44 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
if (s[2] > max)
|
2007-09-20 01:21:41 +08:00
|
|
|
VALUE (0, s[2]) += weight * masked;
|
2006-04-12 20:49:29 +08:00
|
|
|
else
|
2007-09-20 01:21:41 +08:00
|
|
|
VALUE (0, max) += weight * masked;
|
2003-01-15 21:40:44 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
s += 4;
|
|
|
|
m += 1;
|
|
|
|
}
|
2000-12-19 22:43:54 +08:00
|
|
|
|
2005-07-30 22:05:57 +08:00
|
|
|
src += region->rowstride;
|
|
|
|
msrc += mask->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
2006-04-12 20:49:29 +08:00
|
|
|
}
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
}
|
|
|
|
else /* no mask */
|
|
|
|
{
|
2000-12-19 22:43:54 +08:00
|
|
|
src = region->data;
|
|
|
|
|
2005-07-30 22:05:57 +08:00
|
|
|
switch (region->bytes)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
2011-10-12 20:58:55 +08:00
|
|
|
w = region->w;
|
2000-12-19 22:43:54 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
while (w--)
|
|
|
|
{
|
2005-02-15 01:45:35 +08:00
|
|
|
VALUE (0, s[0]) += 1.0;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
s += 1;
|
|
|
|
}
|
2000-12-19 22:43:54 +08:00
|
|
|
|
2005-07-30 22:05:57 +08:00
|
|
|
src += region->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
2011-10-12 20:58:55 +08:00
|
|
|
w = region->w;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
while (w--)
|
|
|
|
{
|
2007-09-20 01:21:41 +08:00
|
|
|
const gdouble weight = s[1] / 255;
|
|
|
|
|
|
|
|
VALUE (0, s[0]) += weight;
|
2005-02-15 01:45:35 +08:00
|
|
|
VALUE (1, s[1]) += 1.0;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
s += 2;
|
|
|
|
}
|
2000-12-19 22:43:54 +08:00
|
|
|
|
2005-07-30 22:05:57 +08:00
|
|
|
src += region->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* calculate separate value values */
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
2011-10-12 20:58:55 +08:00
|
|
|
w = region->w;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
while (w--)
|
|
|
|
{
|
2005-02-15 01:45:35 +08:00
|
|
|
VALUE (1, s[0]) += 1.0;
|
|
|
|
VALUE (2, s[1]) += 1.0;
|
|
|
|
VALUE (3, s[2]) += 1.0;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
max = (s[0] > s[1]) ? s[0] : s[1];
|
2003-01-15 21:40:44 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
if (s[2] > max)
|
|
|
|
VALUE (0, s[2]) += 1.0;
|
|
|
|
else
|
|
|
|
VALUE (0, max) += 1.0;
|
2003-01-15 21:40:44 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
s += 3;
|
|
|
|
}
|
2000-12-19 22:43:54 +08:00
|
|
|
|
2005-07-30 22:05:57 +08:00
|
|
|
src += region->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: /* calculate separate value values */
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
2011-10-12 20:58:55 +08:00
|
|
|
w = region->w;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
while (w--)
|
|
|
|
{
|
2007-09-20 01:21:41 +08:00
|
|
|
const gdouble weight = s[3] / 255;
|
|
|
|
|
|
|
|
VALUE (1, s[0]) += weight;
|
|
|
|
VALUE (2, s[1]) += weight;
|
|
|
|
VALUE (3, s[2]) += weight;
|
2005-02-15 01:45:35 +08:00
|
|
|
VALUE (4, s[3]) += 1.0;
|
2005-07-30 22:05:57 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
max = (s[0] > s[1]) ? s[0] : s[1];
|
2003-01-15 21:40:44 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
if (s[2] > max)
|
2007-09-20 01:21:41 +08:00
|
|
|
VALUE (0, s[2]) += weight;
|
2006-04-12 20:49:29 +08:00
|
|
|
else
|
2007-09-20 01:21:41 +08:00
|
|
|
VALUE (0, max) += weight;
|
2003-01-15 21:40:44 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
s += 4;
|
|
|
|
}
|
2000-12-19 22:43:54 +08:00
|
|
|
|
2005-07-30 22:05:57 +08:00
|
|
|
src += region->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
2006-04-12 20:49:29 +08:00
|
|
|
}
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ENABLE_MP
|
|
|
|
/* unlock this slot */
|
2005-02-14 07:50:18 +08:00
|
|
|
g_static_mutex_lock (&histogram->mutex);
|
2005-02-14 06:31:31 +08:00
|
|
|
|
2005-02-14 09:33:14 +08:00
|
|
|
histogram->slots[slot] = 0;
|
2005-02-14 06:31:31 +08:00
|
|
|
|
2005-02-14 07:50:18 +08:00
|
|
|
g_static_mutex_unlock (&histogram->mutex);
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
#endif
|
|
|
|
}
|