GNOME Bugzilla – Bug 315080
WISHLIST: channel editing in grayscale
Last modified: 2018-05-24 11:36:43 UTC
Distribution/Version: Debian Sarge Hi, When working on individual colour channels (for example just the red channel) it would be really great if there was a way to view and work on it in grayscale rather than red, or whatever colour the channel is. So for example you make a new image, turn off visibility of the green and blue channels, and the red channel is displayed in grayscale. Painting on the image with a white brush only affects the red colour channel (not all channels as it does currently). Switching on visibility of the other 2 channels restores normal colour and operation again. Would this be at all possible? It would make channels much much easier to work with... Thanks guys! :)
What would be the benefit of displaying the channel in grayscale? How should the user interface for this look like?
Hi Sven, thanks for the quick reply. > How should the user interface for this look like? I've been having a think about this, maybe a new filter could be added to view -> display filters to show individual channels in grayscale only? Or if not, maybe an option on its own in the view menu ("Display single channels grayscale") or an option in the main preferences (somewhere in the "Image Windows" section perhaps). > What would be the benefit of displaying the channel in grayscale? I work in computer animation, so my team and I are often editing grayscale images like specularity, diffuse and bump maps for our 3D models. However since these images are often closely related and are best edited together, we combine each of these grayscale maps into one rgb image - specularity as the red channel, diffuse as the blue channel, bump as the green channel for example - and map each channel to the corresponding property in our animation application. It means we can edit all 3 maps together in one image, yet still work on the maps individually should we need to by just isolating specific channels. I realise this request probably sounds a little specialist (it is!), but we're trying to move from Photoshop to Gimp at the moment, and this is one of the snags that we've hit (in Photoshop, if you show only one channel it automatically drops to grayscale - it's just something we'd always taken for granted sadly). Also conceptually, it's a lot easier to see what a channel's doing individually in greyscale, and it's a lot easier on the eyes too. I recognise this option isn't for everyone, but it would be very handy for our sort of work.
I think I see that the PS behaviour makes some sense here. If this feature or the lack of it are being a problem for you, perhaps you could afford to help having it fixed? A patch would very much increase the likelihod of such a a change to happen. Let me know if you need any help implementing this.
Sure, I've got a couple of hours over the next 2 weeks or so that I can devote to this. I've grabbed the source code for Gimp 2.2.8 and I've created a new display filter that can isolate any colour channel, though from there I'm a little stuck. I need to find out which channels are visible and which aren't so I can decide which to isolate - how would I do this from within a display filter?
Created attachment 52252 [details] Zipped source files which enable grey-scale display of single channels
OK, never mind, I think I've got something working. I gave up on the display filter idea (I can't find any way for a display filter to get channel information from an image) and instead added an option to the Image->View menu and "Image Window Appearance" preferences called "Show Greyscale Channels". When it's on and you're looking at one colour channel of an image, the image is displayed in greyscale. When it's off and you're looking at one channel, you get the normal Gimp-like behaviour (ie the image is displayed in colour). I'm afraid I don't know how to make a patch, having never worked on opensource before, so I'm attaching a zip file with all the files that I modified (14 of them in total). If you get the source code to Gimp 2.2.8 and then extract my zip file in the Gimp 2.2.8 source directory, it should overwrite all the necessary files with my updated ones. I've just checked it myself and it worked fine on a clean build on my computer over here. I suggest that someone checks my code first before blindly checking it in - before last week I'd never touched Gimp's code, so it's very possible I've made mistakes/violated ways of doing things that I just don't know about. And of course, any feedback would be greatly appreciated in case I ever have to mess around with Gimp's code again :) Cheers, Karl
Reopening, I guess you accidentially closed this?
Oh sorry, I presumed that since I'd sumbitted a patch I should mark the bug as fixed... Should it only be marked as fixed when the patch has been accepted, or something?
I don't think anyone will expect to find that option in the View menu and if a user finds "Show Greyscale Channels" in the View menu, she will not know what it does and if she tries, it will do nothing. Before even trying to write a patch for this, we should find a reasonable user interface for it.
Hmm, good point. What sort of interface would you suggest for this then?
I wonder if we need a user interface at all or if we should just change the color channels to be shown in grayscale always. Is the current behaviour useful at all? This could also become a user preference or perhaps it could be added in the right-click menu of the Channels dialog?
I'd suggest keeping it as an option, at least for now - since no one has asked for this to be changed before, I guess at least some people do use the current behaviour. PS also has an option for it (named "Color Channels in Color"), so changing the behaviour completely without leaving users an option for it might be a little rash. Good interface suggestions by the way, especially the right-click channels option, I hadn't thought of that, that would definitely work much better than the view menu. Two more interface questions I'd like your input on, then I can probably code in the changes: - Should the option for this be set per-image or globally? (that is, should the user be able to have one image with colour channels and another with greyscale channels?) - What should the menu text for this be? On reflection "Show greyscale channels" is a little non-descriptive, and probably too long for a right-click menu as well. Any suggestions?
Sounds like a global option would be reasonable here. I doubt that anyone would need different settings for different images. Pretty please, next time do not attach another ZIP file but create a unified diff. Preferably against CVS but if you insist on working with the stable release, we should be able to merge your changes into the development branch based on a patch against the stable release.
Yeah, sorry about that Sven - I've since discovered developer.gimp.org and developer.gnome.org, so I should be (relatively) housetrained now :) I've followed your suggestion and I'm now working on the Gimp CVS code instead of Gimp 2.2.8. I've ported my greyscale code over, and changed it so that instead of the old View menu option there's now an option in the right-click channels menu, called "Show in greyscale". Turning it on will display the image in greyscale if only one channel is visible, and turning it off will revert to the old gimp behaviour. Whenever the value is changed, all open images are redrawn. The value is saved, so if you change the value and restart gimp, your saved value will still be there. Its value can also be set through the gimprc (where I've put a commented out example along with all the others). I did try adding an option to the global preferences window as well, but to be honest it seemed a bit stupid - it's so easily accessible in the right click menu of the channels dialog that there seemed to be very little point adding an identical option in a much harder to reach place, so I eventually took it out again. Let me know if you still want it in there anyway, shouldn't be too hard. I've attached a patch here, again comments are welcome.
Created attachment 52644 [details] [review] An updated patch to enable greyscale display of single channels
I don't think we need a menu item for this. A toggle in the preferences menu should be good enough or do you actually expect people to change this value frequently? Whatever we decide to do, the state of the UI needs to update with the gimprc option, not the other way around. The displays need to redraw if a change in the option is being notified from the gimprc object. Also there is no point in editing the gimprc file since that file is generated using the blurb you specify with the property.
No, I don't think the value will need changing frequently, so I've removed the right-click channels option and replaced it with a preferences option as suggested. I've also undone changes to the gimprc. However I have absolutely no idea how to set up the displays to redraw when my value in GimpCoreConfig is changed. I know I need to use signals, but I don't know how to implement it since I know very little about signals or GObject, and my various attempts have all failed. I've tried reading online tutorials, the GObject API reference and grepping the source for examples on how to achieve this, but nothing has helped. How can I set the displays to redraw upon notification, and how can I send this notification? Any suggestions would be a great help.
The display already connects to changes in a number of gimprc properties. See gimp_display_shell_connect() in app/display/gimpdisplayshell-handlers.c. You don't need to worry about sending the notification, this happens automatically when the property is changed.
Created attachment 52708 [details] [review] An updated patch to enable greyscale display of single channels Brilliant, thanks very much Sven, that info was exactly what I needed. Here's an updated patch - the preferences option is called "Show single channels in greyscale", it's under the "Image Windows" preferences group.
Why do you iterate over all displays? The individual displays are connected to the property anyway. Also, we should find something shorter than "show-channels-in-grayscale" for the gimprc option as well as for the function names. But that's minor things. What really bothers me is the implementation of actually drawing the channel. This should happen in the projection, not drawn on top of it.
> Why do you iterate over all displays? The individual displays > are connected to the property anyway. Oh, I didn't know. I've changed this, I'll make sure it's in the next patch I post here. > Also, we should find something shorter than > "show-channels-in-grayscale" for the gimprc option as well as > for the function names. Yes, I agree, and I'm open to suggestions. I'd already noticed that the names were too long, but I couldn't think of anything short that still made it clear what the option did. If anyone can think of a better name then I'll change it. > What really bothers me is the implementation of actually > drawing the channel. This should happen in the projection, > not drawn on top of it. Sorry, I'm not sure I understand, where do you mean by "in the projection"? I thought the current place for it was OK, since it's where other GUI-related rendering like selection highlighting and mask rendering happens.
But this rendering isn't GUI related. As far as I understand your request, you want single channels to be shown in grayscale. That should probably mean that the projection handles it like a grayscale channel.
I've looked at app/core/projection.c and app/core/projection-construct.c, and I can't find a logical way to do that. My understanding of the projection code from gimp_projection_construct() goes something like this, please correct me if I'm wrong: 1) The projection is initialised 2) Floating selection and then all visible layers are projected together, one at a time 3) All visible *user-added* channels (ie. not RGBA) are then projected as well, again one at a time I don't think there's any point in this process where the code can (for example) go "only the red channel is visible in our image, so we'll render it so that the resulting image is in greyscale and not in shades of red"... The only way I can think of getting this to work is to add a "step 4" to the process which conditionally converts it to greyscale afterwards (ie. the implementation that you disapprove of)... You know Gimp's much better than I do (obviously!), is there another way that you had in mind of achieving this?
Actually I don't know the projection code good enough to tell without having a close look. It's been a while since I looked at it in detail.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gimp/issues/158.