Commit 3307c719 authored by Michael Natterer's avatar Michael Natterer 😴

pdb, app, libgimp: change ranges for histogram and threshold to 0.0..1.0

They used to be 0..255, inherited from the old gimp_histogram() and
gimp_threshold() procedures. This commit deprecates these old
procedures and changes the ranges in the new gimp_drawable_histogram()
and gimp_drawable_threshold() to double with a 0.0..1.0 range.
parent d918a212
......@@ -1244,12 +1244,12 @@ register_color_procs (GimpPDB *pdb)
"gimp-histogram");
gimp_procedure_set_static_strings (procedure,
"gimp-histogram",
"Returns information on the intensity histogram for the specified drawable.",
"This tool makes it possible to gather information about the intensity histogram of a drawable. A channel to examine is first specified. This can be either value, red, green, or blue, depending on whether the drawable is of type color or grayscale. Second, a range of intensities are specified. The 'gimp-histogram' function returns statistics based on the pixels in the drawable that fall under this range of values. Mean, standard deviation, median, number of pixels, and percentile are all returned. Additionally, the total count of pixels in the image is returned. Counts of pixels are weighted by any associated alpha values and by the current selection mask. That is, pixels that lie outside an active selection mask will not be counted. Similarly, pixels with transparent alpha values will not be counted. The returned mean, std_dev and median are in the range (0..255) for 8-bit images, or if the plug-in is not precision-aware, and in the range (0.0..1.0) otherwise.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
NULL);
"Deprecated: Use 'gimp-drawable-histogram' instead.",
"Deprecated: Use 'gimp-drawable-histogram' instead.",
"",
"",
"",
"gimp-drawable-histogram");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
......@@ -1370,12 +1370,12 @@ register_color_procs (GimpPDB *pdb)
"gimp-threshold");
gimp_procedure_set_static_strings (procedure,
"gimp-threshold",
"Threshold the specified drawable.",
"This procedures generates a threshold map of the specified drawable. All pixels between the values of 'low_threshold' and 'high_threshold' are replaced with white, and all other pixels with black.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1997",
NULL);
"Deprecated: Use 'gimp-drawable-threshold' instead.",
"Deprecated: Use 'gimp-drawable-threshold' instead.",
"",
"",
"",
"gimp-drawable-threshold");
gimp_procedure_add_argument (procedure,
gimp_param_spec_drawable_id ("drawable",
"drawable",
......
......@@ -376,8 +376,8 @@ drawable_histogram_invoker (GimpProcedure *procedure,
GimpValueArray *return_vals;
GimpDrawable *drawable;
gint32 channel;
gint32 start_range;
gint32 end_range;
gdouble start_range;
gdouble end_range;
gdouble mean = 0.0;
gdouble std_dev = 0.0;
gdouble median = 0.0;
......@@ -387,8 +387,8 @@ drawable_histogram_invoker (GimpProcedure *procedure,
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 0), gimp);
channel = g_value_get_enum (gimp_value_array_index (args, 1));
start_range = g_value_get_int (gimp_value_array_index (args, 2));
end_range = g_value_get_int (gimp_value_array_index (args, 3));
start_range = g_value_get_double (gimp_value_array_index (args, 2));
end_range = g_value_get_double (gimp_value_array_index (args, 3));
if (success)
{
......@@ -402,19 +402,16 @@ drawable_histogram_invoker (GimpProcedure *procedure,
if (success)
{
GimpHistogram *histogram = gimp_histogram_new (TRUE);
gint start = start_range;
gint end = end_range;
gint n_bins;
gint start;
gint end;
gimp_drawable_calculate_histogram (drawable, histogram);
n_bins = gimp_histogram_n_bins (histogram);
if (n_bins != 256)
{
start = ROUND ((gdouble) start * (n_bins - 1) / 255);
end = ROUND ((gdouble) end * (n_bins - 1) / 255);
}
start = ROUND ((gdouble) start * (n_bins - 1));
end = ROUND ((gdouble) end * (n_bins - 1));
mean = gimp_histogram_get_mean (histogram, channel,
start, end);
......@@ -682,12 +679,12 @@ drawable_threshold_invoker (GimpProcedure *procedure,
{
gboolean success = TRUE;
GimpDrawable *drawable;
gint32 low_threshold;
gint32 high_threshold;
gdouble low_threshold;
gdouble high_threshold;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 0), gimp);
low_threshold = g_value_get_int (gimp_value_array_index (args, 1));
high_threshold = g_value_get_int (gimp_value_array_index (args, 2));
low_threshold = g_value_get_double (gimp_value_array_index (args, 1));
high_threshold = g_value_get_double (gimp_value_array_index (args, 2));
if (success)
{
......@@ -698,8 +695,8 @@ drawable_threshold_invoker (GimpProcedure *procedure,
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gimp:threshold",
"low", low_threshold / 255.0,
"high", high_threshold / 255.0,
"low", low_threshold,
"high", high_threshold,
NULL);
gimp_drawable_apply_operation (drawable, progress,
......@@ -1000,7 +997,7 @@ register_drawable_color_procs (GimpPDB *pdb)
gimp_procedure_set_static_strings (procedure,
"gimp-drawable-histogram",
"Returns information on the intensity histogram for the specified drawable.",
"This tool makes it possible to gather information about the intensity histogram of a drawable. A channel to examine is first specified. This can be either value, red, green, or blue, depending on whether the drawable is of type color or grayscale. Second, a range of intensities are specified. The 'gimp-histogram' function returns statistics based on the pixels in the drawable that fall under this range of values. Mean, standard deviation, median, number of pixels, and percentile are all returned. Additionally, the total count of pixels in the image is returned. Counts of pixels are weighted by any associated alpha values and by the current selection mask. That is, pixels that lie outside an active selection mask will not be counted. Similarly, pixels with transparent alpha values will not be counted. The returned mean, std_dev and median are in the range (0..255) for 8-bit images, or if the plug-in is not precision-aware, and in the range (0.0..1.0) otherwise.",
"This tool makes it possible to gather information about the intensity histogram of a drawable. A channel to examine is first specified. This can be either value, red, green, or blue, depending on whether the drawable is of type color or grayscale. Second, a range of intensities are specified. The 'gimp-drawable-histogram' function returns statistics based on the pixels in the drawable that fall under this range of values. Mean, standard deviation, median, number of pixels, and percentile are all returned. Additionally, the total count of pixels in the image is returned. Counts of pixels are weighted by any associated alpha values and by the current selection mask. That is, pixels that lie outside an active selection mask will not be counted. Similarly, pixels with transparent alpha values will not be counted. The returned mean, std_dev and median are in the range (0..255) for 8-bit images or if the plug-in is not precision-aware, and in the range (0.0..1.0) otherwise.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
......@@ -1014,22 +1011,22 @@ register_drawable_color_procs (GimpPDB *pdb)
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("channel",
"channel",
"The channel to modify",
"The channel to query",
GIMP_TYPE_HISTOGRAM_CHANNEL,
GIMP_HISTOGRAM_VALUE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("start-range",
"start range",
"Start of the intensity measurement range",
0, 255, 0,
GIMP_PARAM_READWRITE));
g_param_spec_double ("start-range",
"start range",
"Start of the intensity measurement range",
0.0, 1.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("end-range",
"end range",
"End of the intensity measurement range",
0, 255, 0,
GIMP_PARAM_READWRITE));
g_param_spec_double ("end-range",
"end range",
"End of the intensity measurement range",
0.0, 1.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_double ("mean",
"mean",
......@@ -1279,17 +1276,17 @@ register_drawable_color_procs (GimpPDB *pdb)
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("low-threshold",
"low threshold",
"The low threshold value",
0, 255, 0,
GIMP_PARAM_READWRITE));
g_param_spec_double ("low-threshold",
"low threshold",
"The low threshold value",
0.0, 1.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("high-threshold",
"high threshold",
"The high threshold value",
0, 255, 0,
GIMP_PARAM_READWRITE));
g_param_spec_double ("high-threshold",
"high threshold",
"The high threshold value",
0.0, 1.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}
......@@ -488,24 +488,7 @@ gimp_colorize (gint32 drawable_ID,
* @count: Alpha-weighted pixel count for range.
* @percentile: Percentile that range falls under.
*
* Returns information on the intensity histogram for the specified
* drawable.
*
* This tool makes it possible to gather information about the
* intensity histogram of a drawable. A channel to examine is first
* specified. This can be either value, red, green, or blue, depending
* on whether the drawable is of type color or grayscale. Second, a
* range of intensities are specified. The gimp_histogram() function
* returns statistics based on the pixels in the drawable that fall
* under this range of values. Mean, standard deviation, median, number
* of pixels, and percentile are all returned. Additionally, the total
* count of pixels in the image is returned. Counts of pixels are
* weighted by any associated alpha values and by the current selection
* mask. That is, pixels that lie outside an active selection mask will
* not be counted. Similarly, pixels with transparent alpha values will
* not be counted. The returned mean, std_dev and median are in the
* range (0..255) for 8-bit images, or if the plug-in is not
* precision-aware, and in the range (0.0..1.0) otherwise.
* Deprecated: Use gimp_drawable_histogram() instead.
*
* Returns: TRUE on success.
**/
......@@ -602,12 +585,7 @@ gimp_hue_saturation (gint32 drawable_ID,
* @low_threshold: The low threshold value.
* @high_threshold: The high threshold value.
*
* Threshold the specified drawable.
*
* This procedures generates a threshold map of the specified drawable.
* All pixels between the values of 'low_threshold' and
* 'high_threshold' are replaced with white, and all other pixels with
* black.
* Deprecated: Use gimp_drawable_threshold() instead.
*
* Returns: TRUE on success.
**/
......
......@@ -81,6 +81,7 @@ gboolean gimp_colorize (gint32 drawable_ID,
gdouble hue,
gdouble saturation,
gdouble lightness);
GIMP_DEPRECATED_FOR(gimp_drawable_histogram)
gboolean gimp_histogram (gint32 drawable_ID,
GimpHistogramChannel channel,
gint start_range,
......@@ -97,6 +98,7 @@ gboolean gimp_hue_saturation (gint32 drawable_ID,
gdouble hue_offset,
gdouble lightness,
gdouble saturation);
GIMP_DEPRECATED_FOR(gimp_drawable_threshold)
gboolean gimp_threshold (gint32 drawable_ID,
gint low_threshold,
gint high_threshold);
......
......@@ -340,7 +340,7 @@ gimp_drawable_equalize (gint32 drawable_ID,
/**
* gimp_drawable_histogram:
* @drawable_ID: The drawable.
* @channel: The channel to modify.
* @channel: The channel to query.
* @start_range: Start of the intensity measurement range.
* @end_range: End of the intensity measurement range.
* @mean: Mean intensity value.
......@@ -357,16 +357,16 @@ gimp_drawable_equalize (gint32 drawable_ID,
* intensity histogram of a drawable. A channel to examine is first
* specified. This can be either value, red, green, or blue, depending
* on whether the drawable is of type color or grayscale. Second, a
* range of intensities are specified. The gimp_histogram() function
* returns statistics based on the pixels in the drawable that fall
* under this range of values. Mean, standard deviation, median, number
* of pixels, and percentile are all returned. Additionally, the total
* count of pixels in the image is returned. Counts of pixels are
* range of intensities are specified. The gimp_drawable_histogram()
* function returns statistics based on the pixels in the drawable that
* fall under this range of values. Mean, standard deviation, median,
* number of pixels, and percentile are all returned. Additionally, the
* total count of pixels in the image is returned. Counts of pixels are
* weighted by any associated alpha values and by the current selection
* mask. That is, pixels that lie outside an active selection mask will
* not be counted. Similarly, pixels with transparent alpha values will
* not be counted. The returned mean, std_dev and median are in the
* range (0..255) for 8-bit images, or if the plug-in is not
* range (0..255) for 8-bit images or if the plug-in is not
* precision-aware, and in the range (0.0..1.0) otherwise.
*
* Returns: TRUE on success.
......@@ -376,8 +376,8 @@ gimp_drawable_equalize (gint32 drawable_ID,
gboolean
gimp_drawable_histogram (gint32 drawable_ID,
GimpHistogramChannel channel,
gint start_range,
gint end_range,
gdouble start_range,
gdouble end_range,
gdouble *mean,
gdouble *std_dev,
gdouble *median,
......@@ -393,8 +393,8 @@ gimp_drawable_histogram (gint32 drawable_ID,
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_INT32, channel,
GIMP_PDB_INT32, start_range,
GIMP_PDB_INT32, end_range,
GIMP_PDB_FLOAT, start_range,
GIMP_PDB_FLOAT, end_range,
GIMP_PDB_END);
*mean = 0.0;
......@@ -650,9 +650,9 @@ gimp_drawable_posterize (gint32 drawable_ID,
* Since: 2.10
**/
gboolean
gimp_drawable_threshold (gint32 drawable_ID,
gint low_threshold,
gint high_threshold)
gimp_drawable_threshold (gint32 drawable_ID,
gdouble low_threshold,
gdouble high_threshold)
{
GimpParam *return_vals;
gint nreturn_vals;
......@@ -661,8 +661,8 @@ gimp_drawable_threshold (gint32 drawable_ID,
return_vals = gimp_run_procedure ("gimp-drawable-threshold",
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_INT32, low_threshold,
GIMP_PDB_INT32, high_threshold,
GIMP_PDB_FLOAT, low_threshold,
GIMP_PDB_FLOAT, high_threshold,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
......
......@@ -59,8 +59,8 @@ gboolean gimp_drawable_equalize (gint32 drawable_ID,
gboolean mask_only);
gboolean gimp_drawable_histogram (gint32 drawable_ID,
GimpHistogramChannel channel,
gint start_range,
gint end_range,
gdouble start_range,
gdouble end_range,
gdouble *mean,
gdouble *std_dev,
gdouble *median,
......@@ -85,8 +85,8 @@ gboolean gimp_drawable_levels_stretch (gint32 drawable_ID);
gboolean gimp_drawable_posterize (gint32 drawable_ID,
gint levels);
gboolean gimp_drawable_threshold (gint32 drawable_ID,
gint low_threshold,
gint high_threshold);
gdouble low_threshold,
gdouble high_threshold);
G_END_DECLS
......
......@@ -547,7 +547,7 @@ for 8-bit images, or if the plug-in is not precision-aware, and in the
range (0.0..1.0) otherwise.
HELP
&std_pdb_misc;
&std_pdb_deprecated ('gimp-drawable-histogram');
@inargs = (
{ name => 'drawable', type => 'drawable',
......@@ -687,8 +687,7 @@ between the values of 'low_threshold' and 'high_threshold' are replaced with
white, and all other pixels with black.
HELP
&std_pdb_misc;
$date = '1997';
&std_pdb_deprecated ('gimp-drawable-threshold');
@inargs = (
{ name => 'drawable', type => 'drawable',
......
......@@ -385,21 +385,23 @@ Returns information on the intensity histogram for the specified drawable.
BLURB
$help = <<'HELP';
This tool makes it possible to gather information about the intensity
histogram of a drawable. A channel to examine is first specified. This
can be either value, red, green, or blue, depending on whether the
drawable is of type color or grayscale. Second, a range of intensities
are specified. The gimp_histogram() function returns statistics based
on the pixels in the drawable that fall under this range of
values. Mean, standard deviation, median, number of pixels, and
percentile are all returned. Additionally, the total count of pixels
in the image is returned. Counts of pixels are weighted by any
are specified. The gimp_drawable_histogram() function returns
statistics based on the pixels in the drawable that fall under this
range of values. Mean, standard deviation, median, number of pixels,
and percentile are all returned. Additionally, the total count of
pixels in the image is returned. Counts of pixels are weighted by any
associated alpha values and by the current selection mask. That is,
pixels that lie outside an active selection mask will not be
counted. Similarly, pixels with transparent alpha values will not be
counted. The returned mean, std_dev and median are in the range (0..255)
for 8-bit images, or if the plug-in is not precision-aware, and in the
range (0.0..1.0) otherwise.
counted. The returned mean, std_dev and median are in the range
(0..255) for 8-bit images or if the plug-in is not precision-aware,
and in the range (0.0..1.0) otherwise.
HELP
&std_pdb_misc;
......@@ -409,10 +411,10 @@ HELP
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' },
{ name => 'channel', type => 'enum GimpHistogramChannel',
desc => 'The channel to modify' },
{ name => 'start_range', type => '0 <= int32 < 256',
desc => 'The channel to query' },
{ name => 'start_range', type => '0.0 <= float <= 1.0',
desc => 'Start of the intensity measurement range' },
{ name => 'end_range', type => '0 <= int32 < 256',
{ name => 'end_range', type => '0.0 <= float <= 1.0',
desc => 'End of the intensity measurement range' }
);
......@@ -446,19 +448,16 @@ HELP
if (success)
{
GimpHistogram *histogram = gimp_histogram_new (TRUE);
gint start = start_range;
gint end = end_range;
gint n_bins;
gint start;
gint end;
gimp_drawable_calculate_histogram (drawable, histogram);
n_bins = gimp_histogram_n_bins (histogram);
if (n_bins != 256)
{
start = ROUND ((gdouble) start * (n_bins - 1) / 255);
end = ROUND ((gdouble) end * (n_bins - 1) / 255);
}
start = ROUND ((gdouble) start * (n_bins - 1));
end = ROUND ((gdouble) end * (n_bins - 1));
mean = gimp_histogram_get_mean (histogram, channel,
start, end);
......@@ -741,9 +740,10 @@ sub drawable_threshold {
$blurb = 'Threshold the specified drawable.';
$help = <<'HELP';
This procedures generates a threshold map of the specified drawable. All pixels
between the values of 'low_threshold' and 'high_threshold' are replaced with
white, and all other pixels with black.
This procedures generates a threshold map of the specified
drawable. All pixels between the values of 'low_threshold' and
'high_threshold' are replaced with white, and all other pixels with
black.
HELP
&std_pdb_misc;
......@@ -753,9 +753,9 @@ HELP
@inargs = (
{ name => 'drawable', type => 'drawable',
desc => 'The drawable' },
{ name => 'low_threshold', type => '0 <= int32 <= 255',
{ name => 'low_threshold', type => '0.0 <= float <= 1.0',
desc => 'The low threshold value' },
{ name => 'high_threshold', type => '0 <= int32 <= 255',
{ name => 'high_threshold', type => '0.0 <= float <= 1.0',
desc => 'The high threshold value' }
);
......@@ -769,8 +769,8 @@ HELP
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gimp:threshold",
"low", low_threshold / 255.0,
"high", high_threshold / 255.0,
"low", low_threshold,
"high", high_threshold,
NULL);
gimp_drawable_apply_operation (drawable, progress,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment