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 05:11:19 +00:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimphistogram module Copyright (C) 1999 Jay Cox <jaycox@earthlink.net>
|
|
|
|
*
|
|
|
|
* 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 2 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2005-02-14 17:45:35 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2001-12-07 16:10:53 +00:00
|
|
|
#include <glib-object.h>
|
2000-12-19 14:43:54 +00:00
|
|
|
|
2001-01-23 23:56:18 +00:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
2001-05-22 23:05:35 +00:00
|
|
|
#include "base-types.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
|
2001-01-29 17:54:02 +00:00
|
|
|
#include "gimphistogram.h"
|
2001-05-22 23:05:35 +00:00
|
|
|
#include "pixel-processor.h"
|
|
|
|
#include "pixel-region.h"
|
2000-12-29 15:22:01 +00: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 05:11:19 +00:00
|
|
|
|
2005-02-14 01:33:14 +00:00
|
|
|
#ifdef ENABLE_MP
|
|
|
|
#define NUM_SLOTS GIMP_MAX_NUM_THREADS
|
|
|
|
#else
|
|
|
|
#define NUM_SLOTS 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
struct _GimpHistogram
|
|
|
|
{
|
2005-02-14 01:33:14 +00:00
|
|
|
gint n_channels;
|
2000-12-19 14:43:54 +00:00
|
|
|
#ifdef ENABLE_MP
|
2005-02-14 01:33:14 +00:00
|
|
|
GStaticMutex mutex;
|
|
|
|
gchar slots[NUM_SLOTS];
|
2003-01-15 13:40:44 +00:00
|
|
|
#endif
|
2005-02-14 17:45:35 +00:00
|
|
|
gdouble *values[NUM_SLOTS];
|
2000-12-19 14:43:54 +00: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 05:11:19 +00:00
|
|
|
|
|
|
|
|
2002-09-07 17:27:32 +00:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2005-02-14 01:05:34 +00:00
|
|
|
static void gimp_histogram_alloc_values (GimpHistogram *histogram,
|
|
|
|
gint bytes);
|
|
|
|
static void gimp_histogram_free_values (GimpHistogram *histogram);
|
|
|
|
static void gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
|
|
|
PixelRegion *region,
|
|
|
|
PixelRegion *mask);
|
2002-09-07 17:27:32 +00: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 05:11:19 +00:00
|
|
|
GimpHistogram *
|
2005-02-14 01:05:34 +00: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 05:11:19 +00:00
|
|
|
{
|
2005-02-14 01:05:34 +00:00
|
|
|
GimpHistogram *histogram = g_new0 (GimpHistogram, 1);
|
2003-01-15 13:40:44 +00:00
|
|
|
|
2005-02-14 01:33:14 +00:00
|
|
|
#ifdef ENABLE_MP
|
|
|
|
g_static_mutex_init (&histogram->mutex);
|
|
|
|
#endif
|
2000-12-19 14:43:54 +00: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 05:11:19 +00:00
|
|
|
return histogram;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_histogram_free (GimpHistogram *histogram)
|
2002-09-07 17:27:32 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (histogram != NULL);
|
|
|
|
|
|
|
|
gimp_histogram_free_values (histogram);
|
|
|
|
g_free (histogram);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-10-30 17:48:16 +00:00
|
|
|
gimp_histogram_calculate (GimpHistogram *histogram,
|
2002-09-07 17:27:32 +00:00
|
|
|
PixelRegion *region,
|
|
|
|
PixelRegion *mask)
|
|
|
|
{
|
2005-02-14 01:33:14 +00:00
|
|
|
gint i;
|
2002-09-07 17:27:32 +00:00
|
|
|
|
|
|
|
g_return_if_fail (histogram != NULL);
|
|
|
|
|
2004-01-13 13:35:58 +00:00
|
|
|
if (! region)
|
2003-11-01 02:39:34 +00:00
|
|
|
{
|
2004-01-13 13:35:58 +00:00
|
|
|
gimp_histogram_free_values (histogram);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_histogram_alloc_values (histogram, region->bytes);
|
2002-09-07 17:27:32 +00:00
|
|
|
|
2005-02-14 01:33:14 +00:00
|
|
|
for (i = 0; i < NUM_SLOTS; i++)
|
|
|
|
if (histogram->values[i])
|
2005-02-14 17:45:35 +00:00
|
|
|
memset (histogram->values[i],
|
|
|
|
0, histogram->n_channels * 256 * sizeof (gdouble));
|
2002-09-07 17:27:32 +00:00
|
|
|
|
2005-02-11 17:03:56 +00:00
|
|
|
pixel_regions_process_parallel ((PixelProcessorFunc)
|
|
|
|
gimp_histogram_calculate_sub_region,
|
2004-01-13 13:35:58 +00:00
|
|
|
histogram, 2, region, mask);
|
2002-09-07 17:27:32 +00:00
|
|
|
|
|
|
|
#ifdef ENABLE_MP
|
2005-02-14 01:33:14 +00:00
|
|
|
/* add up all slots */
|
|
|
|
for (i = 1; i < NUM_SLOTS; i++)
|
|
|
|
if (histogram->values[i])
|
|
|
|
{
|
2005-02-14 17:45:35 +00:00
|
|
|
gint j;
|
2004-01-13 13:35:58 +00:00
|
|
|
|
2005-02-14 17:45:35 +00:00
|
|
|
for (j = 0; j < histogram->n_channels * 256; j++)
|
|
|
|
histogram->values[0][j] += histogram->values[i][j];
|
2005-02-14 01:33:14 +00:00
|
|
|
}
|
2004-01-13 13:35:58 +00:00
|
|
|
#endif
|
2002-09-07 17:27:32 +00:00
|
|
|
}
|
|
|
|
|
2005-02-14 17:45:35 +00:00
|
|
|
|
|
|
|
#define HISTOGRAM_VALUE(c,i) (histogram->values[0][(c) * 256 + (i)])
|
|
|
|
|
|
|
|
|
2002-09-07 17:27:32 +00:00
|
|
|
gdouble
|
2003-10-30 17:48:16 +00:00
|
|
|
gimp_histogram_get_maximum (GimpHistogram *histogram,
|
2002-09-07 17:27:32 +00:00
|
|
|
GimpHistogramChannel channel)
|
|
|
|
{
|
|
|
|
gdouble max = 0.0;
|
|
|
|
gint x;
|
|
|
|
|
|
|
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
|
|
|
|
2004-01-13 13:35:58 +00:00
|
|
|
/* the gray alpha channel is in slot 1 */
|
|
|
|
if (histogram->n_channels == 3 && channel == GIMP_HISTOGRAM_ALPHA)
|
|
|
|
channel = 1;
|
|
|
|
|
2005-03-16 15:52:13 +00:00
|
|
|
if (! histogram->values[0] ||
|
2004-07-06 16:33:30 +00:00
|
|
|
(channel != GIMP_HISTOGRAM_RGB && channel >= histogram->n_channels))
|
2003-11-01 02:39:34 +00:00
|
|
|
return 0.0;
|
|
|
|
|
2004-07-06 16:33:30 +00:00
|
|
|
if (channel == GIMP_HISTOGRAM_RGB)
|
|
|
|
for (x = 0; x < 256; x++)
|
|
|
|
{
|
2005-02-14 17:45:35 +00: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-06 16:33:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
for (x = 0; x < 256; x++)
|
2005-02-14 17:45:35 +00:00
|
|
|
{
|
|
|
|
max = MAX (max, HISTOGRAM_VALUE (channel, x));
|
|
|
|
}
|
2002-09-07 17:27:32 +00:00
|
|
|
|
|
|
|
return max;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdouble
|
2003-10-30 17:48:16 +00:00
|
|
|
gimp_histogram_get_value (GimpHistogram *histogram,
|
|
|
|
GimpHistogramChannel channel,
|
2002-09-07 17:27:32 +00:00
|
|
|
gint bin)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
|
|
|
|
2004-01-13 13:35:58 +00:00
|
|
|
/* the gray alpha channel is in slot 1 */
|
|
|
|
if (histogram->n_channels == 3 && channel == GIMP_HISTOGRAM_ALPHA)
|
|
|
|
channel = 1;
|
|
|
|
|
2005-03-16 15:52:13 +00:00
|
|
|
if (! histogram->values[0] ||
|
2004-07-06 16:33:30 +00: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-14 17:45:35 +00:00
|
|
|
gdouble min = HISTOGRAM_VALUE (GIMP_HISTOGRAM_RED, bin);
|
2004-07-06 16:33:30 +00:00
|
|
|
|
2005-02-14 17:45:35 +00:00
|
|
|
min = MIN (min, HISTOGRAM_VALUE (GIMP_HISTOGRAM_GREEN, bin));
|
2002-09-07 17:27:32 +00:00
|
|
|
|
2005-02-14 17:45:35 +00:00
|
|
|
return MIN (min, HISTOGRAM_VALUE (GIMP_HISTOGRAM_BLUE, bin));
|
2004-07-06 16:33:30 +00:00
|
|
|
}
|
|
|
|
else
|
2005-02-14 01:33:14 +00:00
|
|
|
{
|
2005-02-14 17:45:35 +00:00
|
|
|
return HISTOGRAM_VALUE (channel, bin);
|
2005-02-14 01:33:14 +00:00
|
|
|
}
|
2002-09-07 17:27:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gdouble
|
2003-10-30 17:48:16 +00:00
|
|
|
gimp_histogram_get_channel (GimpHistogram *histogram,
|
|
|
|
GimpHistogramChannel channel,
|
2002-09-07 17:27:32 +00:00
|
|
|
gint bin)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
|
|
|
|
|
|
|
if (histogram->n_channels > 3)
|
2005-02-14 17:45:35 +00:00
|
|
|
channel++;
|
|
|
|
|
|
|
|
return gimp_histogram_get_value (histogram, channel, bin);
|
2002-09-07 17:27:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
2004-01-13 11:51:45 +00:00
|
|
|
gimp_histogram_n_channels (GimpHistogram *histogram)
|
2002-09-07 17:27:32 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (histogram != NULL, 0);
|
|
|
|
|
|
|
|
return histogram->n_channels - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdouble
|
2003-10-30 17:48:16 +00:00
|
|
|
gimp_histogram_get_count (GimpHistogram *histogram,
|
|
|
|
GimpHistogramChannel channel,
|
|
|
|
gint start,
|
|
|
|
gint end)
|
2002-09-07 17:27:32 +00:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gdouble count = 0.0;
|
|
|
|
|
|
|
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
|
|
|
|
2004-01-13 13:35:58 +00:00
|
|
|
/* the gray alpha channel is in slot 1 */
|
|
|
|
if (histogram->n_channels == 3 && channel == GIMP_HISTOGRAM_ALPHA)
|
|
|
|
channel = 1;
|
|
|
|
|
2004-07-06 16:33:30 +00:00
|
|
|
if (channel == GIMP_HISTOGRAM_RGB)
|
|
|
|
return (gimp_histogram_get_count (histogram,
|
|
|
|
GIMP_HISTOGRAM_RED, start, end) +
|
|
|
|
gimp_histogram_get_count (histogram,
|
|
|
|
GIMP_HISTOGRAM_GREEN, start, end) +
|
|
|
|
gimp_histogram_get_count (histogram,
|
|
|
|
GIMP_HISTOGRAM_BLUE, start, end));
|
|
|
|
|
2005-03-16 15:52:13 +00:00
|
|
|
if (! histogram->values[0] ||
|
2004-07-06 16:33:30 +00:00
|
|
|
start > end ||
|
|
|
|
channel >= histogram->n_channels)
|
2003-11-01 02:39:34 +00:00
|
|
|
return 0.0;
|
|
|
|
|
2004-07-06 16:33:30 +00:00
|
|
|
start = CLAMP (start, 0, 255);
|
|
|
|
end = CLAMP (end, 0, 255);
|
|
|
|
|
2002-09-07 17:27:32 +00:00
|
|
|
for (i = start; i <= end; i++)
|
2005-02-14 17:45:35 +00:00
|
|
|
count += HISTOGRAM_VALUE (channel, i);
|
2002-09-07 17:27:32 +00:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdouble
|
2003-10-30 17:48:16 +00:00
|
|
|
gimp_histogram_get_mean (GimpHistogram *histogram,
|
2002-09-07 17:27:32 +00:00
|
|
|
GimpHistogramChannel channel,
|
2003-10-30 17:48:16 +00:00
|
|
|
gint start,
|
2002-09-07 17:27:32 +00:00
|
|
|
gint end)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gdouble mean = 0.0;
|
|
|
|
gdouble count;
|
|
|
|
|
|
|
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
|
|
|
|
2004-01-13 13:35:58 +00:00
|
|
|
/* the gray alpha channel is in slot 1 */
|
|
|
|
if (histogram->n_channels == 3 && channel == GIMP_HISTOGRAM_ALPHA)
|
|
|
|
channel = 1;
|
|
|
|
|
2005-03-16 15:52:13 +00:00
|
|
|
if (! histogram->values[0] ||
|
2004-07-06 16:33:30 +00:00
|
|
|
start > end ||
|
|
|
|
(channel == GIMP_HISTOGRAM_RGB && histogram->n_channels < 4) ||
|
|
|
|
(channel != GIMP_HISTOGRAM_RGB && channel >= histogram->n_channels))
|
2003-11-01 02:39:34 +00:00
|
|
|
return 0.0;
|
|
|
|
|
2004-07-06 16:33:30 +00:00
|
|
|
start = CLAMP (start, 0, 255);
|
|
|
|
end = CLAMP (end, 0, 255);
|
|
|
|
|
|
|
|
if (channel == GIMP_HISTOGRAM_RGB)
|
|
|
|
{
|
|
|
|
for (i = start; i <= end; i++)
|
2005-02-14 17:45:35 +00: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-06 16:33:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = start; i <= end; i++)
|
2005-02-14 17:45:35 +00:00
|
|
|
mean += i * HISTOGRAM_VALUE (channel, i);
|
2004-07-06 16:33:30 +00:00
|
|
|
}
|
2002-09-07 17:27:32 +00:00
|
|
|
|
2003-10-30 17:48:16 +00:00
|
|
|
count = gimp_histogram_get_count (histogram, channel, start, end);
|
2002-09-07 17:27:32 +00:00
|
|
|
|
|
|
|
if (count > 0.0)
|
|
|
|
return mean / count;
|
|
|
|
|
|
|
|
return mean;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
2003-10-30 17:48:16 +00:00
|
|
|
gimp_histogram_get_median (GimpHistogram *histogram,
|
|
|
|
GimpHistogramChannel channel,
|
|
|
|
gint start,
|
2002-09-07 17:27:32 +00:00
|
|
|
gint end)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gdouble sum = 0.0;
|
|
|
|
gdouble count;
|
|
|
|
|
|
|
|
g_return_val_if_fail (histogram != NULL, -1);
|
|
|
|
|
2004-01-13 13:35:58 +00:00
|
|
|
/* the gray alpha channel is in slot 1 */
|
|
|
|
if (histogram->n_channels == 3 && channel == GIMP_HISTOGRAM_ALPHA)
|
|
|
|
channel = 1;
|
|
|
|
|
2005-03-16 15:52:13 +00:00
|
|
|
if (! histogram->values[0] ||
|
2004-07-06 16:33:30 +00:00
|
|
|
start > end ||
|
|
|
|
(channel == GIMP_HISTOGRAM_RGB && histogram->n_channels < 4) ||
|
|
|
|
(channel != GIMP_HISTOGRAM_RGB && channel >= histogram->n_channels))
|
2003-11-01 02:39:34 +00:00
|
|
|
return 0;
|
|
|
|
|
2004-07-06 16:33:30 +00:00
|
|
|
start = CLAMP (start, 0, 255);
|
|
|
|
end = CLAMP (end, 0, 255);
|
|
|
|
|
2003-10-30 17:48:16 +00:00
|
|
|
count = gimp_histogram_get_count (histogram, channel, start, end);
|
2002-09-07 17:27:32 +00:00
|
|
|
|
2004-07-06 16:33:30 +00:00
|
|
|
if (channel == GIMP_HISTOGRAM_RGB)
|
|
|
|
for (i = start; i <= end; i++)
|
|
|
|
{
|
2005-02-14 17:45:35 +00:00
|
|
|
sum += (HISTOGRAM_VALUE (GIMP_HISTOGRAM_RED, i) +
|
|
|
|
HISTOGRAM_VALUE (GIMP_HISTOGRAM_GREEN, i) +
|
|
|
|
HISTOGRAM_VALUE (GIMP_HISTOGRAM_BLUE, i));
|
2002-09-07 17:27:32 +00:00
|
|
|
|
2004-07-06 16:33:30 +00:00
|
|
|
if (sum * 2 > count)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
for (i = start; i <= end; i++)
|
|
|
|
{
|
2005-02-14 17:45:35 +00:00
|
|
|
sum += HISTOGRAM_VALUE (channel, i);
|
2004-07-06 16:33:30 +00:00
|
|
|
|
|
|
|
if (sum * 2 > count)
|
|
|
|
return i;
|
|
|
|
}
|
2002-09-07 17:27:32 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdouble
|
2003-10-30 17:48:16 +00:00
|
|
|
gimp_histogram_get_std_dev (GimpHistogram *histogram,
|
2002-09-07 17:27:32 +00:00
|
|
|
GimpHistogramChannel channel,
|
2003-10-30 17:48:16 +00:00
|
|
|
gint start,
|
2002-09-07 17:27:32 +00:00
|
|
|
gint end)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gdouble dev = 0.0;
|
|
|
|
gdouble count;
|
|
|
|
gdouble mean;
|
|
|
|
|
|
|
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
|
|
|
|
2004-01-13 13:35:58 +00:00
|
|
|
/* the gray alpha channel is in slot 1 */
|
|
|
|
if (histogram->n_channels == 3 && channel == GIMP_HISTOGRAM_ALPHA)
|
|
|
|
channel = 1;
|
|
|
|
|
2005-03-16 15:52:13 +00:00
|
|
|
if (! histogram->values[0] ||
|
2004-07-06 16:33:30 +00:00
|
|
|
start > end ||
|
|
|
|
(channel == GIMP_HISTOGRAM_RGB && histogram->n_channels < 4) ||
|
|
|
|
(channel != GIMP_HISTOGRAM_RGB && channel >= histogram->n_channels))
|
2003-11-01 02:39:34 +00:00
|
|
|
return 0.0;
|
|
|
|
|
2002-09-07 17:27:32 +00:00
|
|
|
mean = gimp_histogram_get_mean (histogram, channel, start, end);
|
2003-10-30 17:48:16 +00:00
|
|
|
count = gimp_histogram_get_count (histogram, channel, start, end);
|
2002-09-07 17:27:32 +00:00
|
|
|
|
|
|
|
if (count == 0.0)
|
|
|
|
count = 1.0;
|
|
|
|
|
|
|
|
for (i = start; i <= end; i++)
|
2005-02-14 17:45:35 +00:00
|
|
|
dev += gimp_histogram_get_value (histogram, channel, i) * SQR (i - mean);
|
2002-09-07 17:27:32 +00:00
|
|
|
|
|
|
|
return sqrt (dev / count);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
2003-10-30 17:48:16 +00:00
|
|
|
gimp_histogram_alloc_values (GimpHistogram *histogram,
|
2002-09-07 17:27:32 +00:00
|
|
|
gint bytes)
|
|
|
|
{
|
|
|
|
if (bytes + 1 != histogram->n_channels)
|
|
|
|
{
|
|
|
|
gimp_histogram_free_values (histogram);
|
|
|
|
|
|
|
|
histogram->n_channels = bytes + 1;
|
2005-02-14 01:33:14 +00:00
|
|
|
|
2005-02-14 17:45:35 +00:00
|
|
|
histogram->values[0] = g_new (gdouble, histogram->n_channels * 256);
|
2002-09-07 17:27:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_histogram_free_values (GimpHistogram *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 05:11:19 +00:00
|
|
|
{
|
2005-02-14 17:45:35 +00:00
|
|
|
gint i;
|
2000-12-19 14:43:54 +00:00
|
|
|
|
2005-02-14 01:33:14 +00:00
|
|
|
for (i = 0; i < NUM_SLOTS; i++)
|
|
|
|
if (histogram->values[i])
|
|
|
|
{
|
|
|
|
g_free (histogram->values[i]);
|
|
|
|
histogram->values[i] = NULL;
|
|
|
|
}
|
2003-11-01 02:39:34 +00:00
|
|
|
|
2005-02-14 01:33:14 +00:00
|
|
|
histogram->n_channels = 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 05:11:19 +00:00
|
|
|
}
|
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
static void
|
2000-01-09 12:40:10 +00:00
|
|
|
gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
2003-10-30 17:48:16 +00:00
|
|
|
PixelRegion *region,
|
2000-01-09 12:40:10 +00:00
|
|
|
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 05:11:19 +00:00
|
|
|
{
|
2000-12-19 14:43:54 +00:00
|
|
|
const guchar *src, *msrc;
|
|
|
|
const guchar *m, *s;
|
2005-02-14 17:45:35 +00:00
|
|
|
gdouble *values;
|
|
|
|
gint h, w, max;
|
2000-12-19 14:43:54 +00: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 05:11:19 +00:00
|
|
|
#ifdef ENABLE_MP
|
2000-12-19 14:43:54 +00: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 05:11:19 +00:00
|
|
|
/* find an unused temporary slot to put our results in and lock it */
|
2005-02-13 23:50:18 +00:00
|
|
|
g_static_mutex_lock (&histogram->mutex);
|
2003-01-15 13:40:44 +00:00
|
|
|
|
2005-02-14 01:33:14 +00:00
|
|
|
while (histogram->slots[slot])
|
2003-01-15 13:40:44 +00:00
|
|
|
slot++;
|
|
|
|
|
2005-02-14 01:33:14 +00:00
|
|
|
values = histogram->values[slot];
|
|
|
|
histogram->slots[slot] = 1;
|
2003-01-15 13:40:44 +00:00
|
|
|
|
2005-02-13 23:50:18 +00:00
|
|
|
g_static_mutex_unlock (&histogram->mutex);
|
2003-01-15 13:40:44 +00:00
|
|
|
|
2005-02-14 01:05:34 +00:00
|
|
|
if (! values)
|
|
|
|
{
|
2005-02-14 17:45:35 +00:00
|
|
|
histogram->values[slot] = g_new0 (gdouble, histogram->n_channels * 256);
|
2005-02-14 01:33:14 +00:00
|
|
|
values = histogram->values[slot];
|
2005-02-14 01:05:34 +00:00
|
|
|
}
|
|
|
|
|
2003-01-15 13:40:44 +00:00
|
|
|
#else
|
2005-02-14 01:33:14 +00: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 05:11:19 +00:00
|
|
|
#endif
|
2000-12-19 14:43:54 +00:00
|
|
|
|
2005-02-14 17:45:35 +00: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 05:11:19 +00:00
|
|
|
h = region->h;
|
|
|
|
w = region->w;
|
2000-12-19 14:43:54 +00: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 05:11:19 +00:00
|
|
|
if (mask)
|
|
|
|
{
|
2000-12-19 14:43:54 +00:00
|
|
|
gdouble masked;
|
|
|
|
|
2004-01-12 22:35:17 +00:00
|
|
|
src = region->data;
|
2001-02-06 07:15:22 +00:00
|
|
|
msrc = mask->data;
|
2000-12-19 14:43:54 +00:00
|
|
|
|
2005-07-30 14:05:57 +00:00
|
|
|
switch (region->bytes)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
|
|
|
m = msrc;
|
|
|
|
w = region->w;
|
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
while (w--)
|
|
|
|
{
|
|
|
|
masked = m[0] / 255.0;
|
2005-07-30 14:05:57 +00:00
|
|
|
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (0, s[0]) += masked;
|
2005-07-30 14:05:57 +00:00
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
s += 1;
|
|
|
|
m += 1;
|
|
|
|
}
|
|
|
|
|
2005-07-30 14:05:57 +00:00
|
|
|
src += region->rowstride;
|
|
|
|
msrc += mask->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
|
|
|
m = msrc;
|
|
|
|
w = region->w;
|
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
while (w--)
|
|
|
|
{
|
|
|
|
masked = m[0] / 255.0;
|
2005-07-30 14:05:57 +00:00
|
|
|
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (0, s[0]) += masked;
|
|
|
|
VALUE (1, s[1]) += masked;
|
2005-07-30 14:05:57 +00:00
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
s += 2;
|
|
|
|
m += 1;
|
|
|
|
}
|
|
|
|
|
2005-07-30 14:05:57 +00:00
|
|
|
src += region->rowstride;
|
|
|
|
msrc += mask->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* calculate separate value values */
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
|
|
|
m = msrc;
|
|
|
|
w = region->w;
|
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
while (w--)
|
|
|
|
{
|
|
|
|
masked = m[0] / 255.0;
|
2005-07-30 14:05:57 +00:00
|
|
|
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (1, s[0]) += masked;
|
|
|
|
VALUE (2, s[1]) += masked;
|
|
|
|
VALUE (3, s[2]) += masked;
|
2005-07-30 14:05:57 +00:00
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
max = (s[0] > s[1]) ? s[0] : s[1];
|
2003-01-15 13:40:44 +00:00
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
if (s[2] > max)
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (0, s[2]) += masked;
|
2000-12-19 14:43:54 +00:00
|
|
|
else
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (0, max) += masked;
|
2003-01-15 13:40:44 +00:00
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
s += 3;
|
|
|
|
m += 1;
|
|
|
|
}
|
|
|
|
|
2005-07-30 14:05:57 +00:00
|
|
|
src += region->rowstride;
|
|
|
|
msrc += mask->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: /* calculate separate value values */
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
|
|
|
m = msrc;
|
|
|
|
w = region->w;
|
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
while (w--)
|
|
|
|
{
|
|
|
|
masked = m[0] / 255.0;
|
2005-07-30 14:05:57 +00:00
|
|
|
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (1, s[0]) += masked;
|
|
|
|
VALUE (2, s[1]) += masked;
|
|
|
|
VALUE (3, s[2]) += masked;
|
|
|
|
VALUE (4, s[3]) += masked;
|
2005-07-30 14:05:57 +00:00
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
max = (s[0] > s[1]) ? s[0] : s[1];
|
2003-01-15 13:40:44 +00:00
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
if (s[2] > max)
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (0, s[2]) += masked;
|
2000-12-19 14:43:54 +00:00
|
|
|
else
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (0, max) += masked;
|
2003-01-15 13:40:44 +00:00
|
|
|
|
2004-01-12 22:35:17 +00:00
|
|
|
s += 4;
|
2000-12-19 14:43:54 +00:00
|
|
|
m += 1;
|
|
|
|
}
|
|
|
|
|
2005-07-30 14:05:57 +00:00
|
|
|
src += region->rowstride;
|
|
|
|
msrc += mask->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
2000-12-19 14:43:54 +00: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 05:11:19 +00:00
|
|
|
}
|
|
|
|
else /* no mask */
|
|
|
|
{
|
2000-12-19 14:43:54 +00:00
|
|
|
src = region->data;
|
|
|
|
|
2005-07-30 14:05:57 +00:00
|
|
|
switch (region->bytes)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
|
|
|
w = region->w;
|
2000-12-19 14:43:54 +00:00
|
|
|
|
|
|
|
while (w--)
|
|
|
|
{
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (0, s[0]) += 1.0;
|
2005-07-30 14:05:57 +00:00
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
s += 1;
|
|
|
|
}
|
|
|
|
|
2005-07-30 14:05:57 +00:00
|
|
|
src += region->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
|
|
|
w = region->w;
|
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
while (w--)
|
|
|
|
{
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (0, s[0]) += 1.0;
|
|
|
|
VALUE (1, s[1]) += 1.0;
|
2005-07-30 14:05:57 +00:00
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
s += 2;
|
|
|
|
}
|
|
|
|
|
2005-07-30 14:05:57 +00:00
|
|
|
src += region->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* calculate separate value values */
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
|
|
|
w = region->w;
|
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
while (w--)
|
|
|
|
{
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (1, s[0]) += 1.0;
|
|
|
|
VALUE (2, s[1]) += 1.0;
|
|
|
|
VALUE (3, s[2]) += 1.0;
|
2005-07-30 14:05:57 +00:00
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
max = (s[0] > s[1]) ? s[0] : s[1];
|
2003-01-15 13:40:44 +00:00
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
if (s[2] > max)
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (0, s[2]) += 1.0;
|
2000-12-19 14:43:54 +00:00
|
|
|
else
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (0, max) += 1.0;
|
2003-01-15 13:40:44 +00:00
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
s += 3;
|
|
|
|
}
|
|
|
|
|
2005-07-30 14:05:57 +00:00
|
|
|
src += region->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: /* calculate separate value values */
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
s = src;
|
|
|
|
w = region->w;
|
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
while (w--)
|
|
|
|
{
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (1, s[0]) += 1.0;
|
|
|
|
VALUE (2, s[1]) += 1.0;
|
|
|
|
VALUE (3, s[2]) += 1.0;
|
|
|
|
VALUE (4, s[3]) += 1.0;
|
2005-07-30 14:05:57 +00:00
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
max = (s[0] > s[1]) ? s[0] : s[1];
|
2003-01-15 13:40:44 +00:00
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
if (s[2] > max)
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (0, s[2]) += 1.0;
|
2000-12-19 14:43:54 +00:00
|
|
|
else
|
2005-02-14 17:45:35 +00:00
|
|
|
VALUE (0, max) += 1.0;
|
2003-01-15 13:40:44 +00:00
|
|
|
|
2000-12-19 14:43:54 +00:00
|
|
|
s += 4;
|
|
|
|
}
|
|
|
|
|
2005-07-30 14:05:57 +00:00
|
|
|
src += region->rowstride;
|
|
|
|
}
|
|
|
|
break;
|
2000-12-19 14:43:54 +00: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 05:11:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ENABLE_MP
|
|
|
|
/* unlock this slot */
|
2005-02-13 23:50:18 +00:00
|
|
|
g_static_mutex_lock (&histogram->mutex);
|
2005-02-13 22:31:31 +00:00
|
|
|
|
2005-02-14 01:33:14 +00:00
|
|
|
histogram->slots[slot] = 0;
|
2005-02-13 22:31:31 +00:00
|
|
|
|
2005-02-13 23:50:18 +00: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 05:11:19 +00:00
|
|
|
#endif
|
|
|
|
}
|