After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 155507 - A way to convert a single layer to grayscale
A way to convert a single layer to grayscale
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
git master
Other All
: Normal enhancement
: 2.4
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2004-10-15 14:11 UTC by Ville Pätsi
Modified: 2005-04-19 20:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Adds a Luminosity item in the Layer/Colors menu to apply the grayscale algorithm (7.79 KB, patch)
2005-04-10 19:29 UTC, Karine Delvare
none Details | Review
Splits "desaturate" in 3 formulae (13.46 KB, patch)
2005-04-11 21:05 UTC, Karine Delvare
none Details | Review
Desaturate dialog offering three formulae (17.71 KB, patch)
2005-04-14 18:39 UTC, Karine Delvare
committed Details | Review
Adds desaturate_full procedure in the PDB (1.76 KB, patch)
2005-04-19 19:57 UTC, Karine Delvare
committed Details | Review

Description Ville Pätsi 2004-10-15 14:11:19 UTC
We need a plug-in that uses the same algorithm as the image mode change from rgb
to grayscale so you could change a single layer.
Comment 1 Sven Neumann 2004-10-21 22:45:52 UTC
What about Desaturate (Layer->Colors->Desaturate) ?
Comment 2 Michael Natterer 2004-10-21 22:53:23 UTC
Desaturate does something different.
Should have confirmed this bug earlier :)
Comment 3 weskaggs 2004-12-13 21:23:10 UTC
Could be done with a script-fu:  put the layer into "Value" mode, insert a white
layer underneath it, and merge down.
Comment 4 Sven Neumann 2005-03-22 13:54:44 UTC
This would be very easy to implement. Probably even easier to do it in the core
than as a plug-in. The core already has gimp_drawable_convert_grayscale() so one
would only have to add an action for it and add it to the menus. The only real
problem is how to name the menu.
Comment 5 weskaggs 2005-03-22 16:29:03 UTC
If we were starting from scratch, the ideal thing would be to make "Desaturate"
do this instead of what it currently does:  in my experience the results are
superior 95% of the time.  But backward compatibility means that's not an
option.  Anything appearing next to "Desaturate" in the menu and with nearly the
same meaning is going to be confusing -- I would suggest "Make gray" as possibly
least confusing.
Comment 6 Sven Neumann 2005-03-24 23:41:16 UTC
- Desaturate (one way)
- Desaturate (another)
Comment 7 weskaggs 2005-03-24 23:45:31 UTC
Ah!  I have it: "Luminosity".  That's what it is, after all.
Comment 8 Sven Neumann 2005-04-10 18:10:37 UTC
My suggestion in comment #4 to use gimp_drawable_convert_grayscale() is of
course bogus. gimp_drawable_convert_grayscale() does actually convert the
drawable to grayscale. Here we want it to stay RGB but appear as grayscale (in
other words r == g == b for any pixel).
Comment 9 Sven Neumann 2005-04-10 18:18:59 UTC
Since there are even more ways to get gray pixels, perhaps we should have a
dialog instead that gives the choice of:

 [x] Lightness       (max(r,g.b) + min(r,g,b) / 2)
 [ ] Luminosity      (0.30 * r + 0.59 * g + 0.11 * b)
 [ ] Average         ((r + g + b) / 3)

Are there other reasonable ways that I missed?
Comment 10 Sven Neumann 2005-04-10 18:22:06 UTC
The first formula should be (max(r,g.b) + min(r,g,b)) / 2) of course.
Comment 11 Karine Delvare 2005-04-10 19:29:38 UTC
Created attachment 45108 [details] [review]
Adds a Luminosity item in the Layer/Colors menu to apply the grayscale algorithm

This is not the definitive solution since Sven proposed a dialog with various
algorithms to desaturate the layer.
Comment 12 Tuomas Kuosmanen 2005-04-11 14:45:07 UTC
Photoshop has this "Channel mixer" thing that lets you tune how you mix the
channels into grayscale - it's extremely nice for making "black and white
photos" from digital photos, as you can have different colors respond with
different luminocity.
Comment 13 Sven Neumann 2005-04-11 14:51:57 UTC
You know, GIMP has this "Channel Mixer" thing that let's you do exactly that.
It's located in Filters->Colors.
Comment 14 Tuomas Kuosmanen 2005-04-11 14:57:27 UTC
Yeah, just noticed. Funny I hadnt seen it before. I guess it should be in Layer
-> Colors from the user point of view - although the whole tools vs plugins
division is not very easy to solve, since one can make quite good arguments for
putting some things on either location.. neither is "wrong"..
Comment 15 Nathan Summers 2005-04-11 15:04:58 UTC
To make things even more fun, it turns out that the technical definition of
"desaturate" is r=g=b=max(r,g,b).  This, of course, is not the formula we
currently use for the "desaturate" menu item.

*sigh*

Tigert suggests that if we have a popup, we have a preview as well.
Comment 16 Nathan Summers 2005-04-11 20:31:50 UTC
It turns out that the luminosity formula above is not correct for sRGB.
Luminance for sRGB is 0.2126 * r + 0.7152 * g + 0.0722 * b.  
Comment 17 Karine Delvare 2005-04-11 21:05:17 UTC
Created attachment 45150 [details] [review]
Splits "desaturate" in 3 formulae

This patch should pave the way for a Desaturate dialog letting the user choose
the formula: desaturate can be called with one of the three modes currently
implemented.

With this patch, Desaturate still uses the (max+min)/2 formula, while
Luminosity uses the formula provided above. The third one (average) has no menu
item calling it.

Please review this patch before I go on with the dialog, thanks.
Comment 18 Karine Delvare 2005-04-14 18:39:53 UTC
Created attachment 45264 [details] [review]
Desaturate dialog offering three formulae
Comment 19 Sven Neumann 2005-04-16 14:57:06 UTC
2005-04-16  Sven Neumann  <sven@gimp.org>

	Applied a patch (with minor modifications) from Karine Delvare
	that makes it possible to choose between various ways to remove
	color from a drawable (bug #155507):

	* libgimpbase/gimpbaseenums.h: added new enum GimpDesaturateMode.

	* libgimpbase/gimpbaseenums.c
	* libgimp/gimpenums.c.tail
	* plug-ins/pygimp/gimpenums.py
	* tools/pdbgen/enums.pl: regenerated.

	* app/core/gimpdrawable-desaturate.[ch]: implement other formulas
	to remove colors from a drawable.

	* tools/pdbgen/pdb/color.pdb: let gimp_desaturate() call
	gimp_drawable_desaturate() with GIMP_DESATURATE_LIGHTNESS so that
	it behaves like it always did.

	* app/pdb/color_cmds.c: regenerated.

	* app/dialogs/Makefile.am
	* app/dialogs/desaturate-dialog.[ch]: new files that define a simple
	dialog to choose a mode for desaturation.

	* app/actions/drawable-actions.[ch]: use the new dialog.


Now what's left to do is to expose this functionality to the PDB.
Comment 20 Karine Delvare 2005-04-19 19:57:07 UTC
Created attachment 45455 [details] [review]
Adds desaturate_full procedure in the PDB
Comment 21 Michael Natterer 2005-04-19 20:31:57 UTC
Fixed in CVS:

2005-04-19  Michael Natterer  <mitch@gimp.org>

	* tools/pdbgen/pdb/color.pdb: applied patch from Karine Delvare
	which adds gimp_desaturate_full(). Fixes bug #155507.

	* app/pdb/color_cmds.c
	* app/pdb/internal_procs.c
	* libgimp/gimpcolor_pdb.[ch]: regenerated.

	* libgimp/gimp.def: added the new symbol.