New: Grayscale display mode
Hi all, I just committed a new display mode: grayscale. It is separate from the other display modes. The grayscale mode is a "Color display mode", see the menu. When activated, it shows all colors in grayscale on-canvas. This does not (yet?) influence exporting, or saving. It only concerns the on-canvas view of the file, like outline display mode.
Right now, there is no preference to change the grayscale calculation. At the moment it uses: grayscale value = 0.33 * red + 0.59 * green + 0.11 * blue. I found this somewhere on internet, but forgot where, and it might be wrong/unusual. I intended to add a preference setting for these values, but have not done so. Let me know if that is desired.
I tried assigning Shift+keypad5 to toggle the color display mode, but it does not work here on my netbook (Ctrl+keypad5 does work). Perhaps this is a Windows bug. If someone can suggest another keybinding, or... thanks!
Johan
On Feb 21, 2011, at 2:27 PM, <J.B.C.Engelen@...1887...> wrote:
I just committed a new display mode: grayscale. It is separate from the other display modes. The grayscale mode is a "Color display mode", see the menu. When activated, it shows all colors in grayscale on-canvas. This does not (yet?) influence exporting, or saving. It only concerns the on-canvas view of the file, like outline display mode.
Right now, there is no preference to change the grayscale calculation. At the moment it uses: grayscale value = 0.33 * red + 0.59 * green + 0.11 * blue. I found this somewhere on internet, but forgot where, and it might be wrong/unusual. I intended to add a preference setting for these values, but have not done so. Let me know if that is desired.
Cool.
The first note is that the function you have there is for general display primaries of TV's from North America, if I recall correctly. It also probably should be performed on linear RGB values, not the gamma loaded sRGB values that SVG uses, and then converted back from linear once it is done.
In the long run, I think we need to clarify what the goals are. If one merely wants to preview "if this were gray", then a better solution would be to leverage LittleCMS and hook into the display chain. We already have code for previewing, so it is "only" a matter of hooking in a proper grayscale ICC profile. :-)
For grayscale, I could see the usefulness of actually allowing one to "apply" this to a drawing. That is, once the user likes the looks of things they can press "Do it" to convert all the sRGB colors in the drawing to their gray values.
However, I think that overall it would be good to allow for a few common "views" of the drawing. "As grayscale", or as "protanopia color blindness", "tritanopia...", etc. or even "PC Display", "Mac Display", etc.
So in general I think having a few modes with 'baked in' color ICC profiles instead of raw code to do a conversion would be more flexible and more useful to the end users. Also it would probably be easier to finish the last 20% of getting the code correct.
On Feb 21, 2011, at 2:57 PM, Jon Cruz wrote:
So in general I think having a few modes with 'baked in' color ICC profiles instead of raw code to do a conversion would be more flexible and more useful to the end users. Also it would probably be easier to finish the last 20% of getting the code correct.
Let me know if you need a hand poking at that LCMS code. As a first step you can probably create a gray profile and use lcms calls to replace the 0.33 0.59 0.11 function implementation with lcms which will take care of the whole convert-to-linear-then-do-the-work-then-convert-back munge of math.
The CMS color picker code uses lcms to convert values one RGB triplet at a time, so you can use it that way. Or you can use a single lcms call to convert an entire buffer at once. That would probably be a very simple first step, and would be not nearly as complex as starting by changing the UI approach you have, etc.
-----Original Message----- From: Jon Cruz [mailto:jon@...18...] Sent: 22 February 2011 08:57 To: Engelen, J.B.C. (Johan) Cc: Inkscape-devel List Subject: Re: [Inkscape-devel] New: Grayscale display mode
On Feb 21, 2011, at 2:57 PM, Jon Cruz wrote:
So in general I think having a few modes with 'baked in' color ICC
profiles instead of raw code to do a conversion would be more flexible and more useful to the end users. Also it would probably be easier to finish the last 20% of getting the code correct.
Let me know if you need a hand poking at that LCMS code. As a first step you can probably create a gray profile and use lcms calls to replace the 0.33 0.59 0.11 function implementation with lcms which
will
take care of the whole
convert-to-linear-then-do-the-work-then-convert-
back munge of math.
The CMS color picker code uses lcms to convert values one RGB triplet at a time, so you can use it that way. Or you can use a single lcms call to convert an entire buffer at once. That would probably be a
very
simple first step, and would be not nearly as complex as starting by changing the UI approach you have, etc.
Before I started, I also thought about doing this in a more general way, but opted for the quick solution first. Now that it works, and I know a bit better where all the rendering happens, I can start working on making a more versatile solution. The next two weeks are busy though...
Ciao, Johan
2011/2/21 <J.B.C.Engelen@...1887...>:
Hi all, I just committed a new display mode: grayscale. It is separate from the other display modes. The grayscale mode is a "Color display mode", see the menu. When activated, it shows all colors in grayscale on-canvas. This does not (yet?) influence exporting, or saving. It only concerns the on-canvas view of the file, like outline display mode.
Display modes should not affect exporting or saving, by design. Grayscale exporting should be handled using a preference in the export dialog.
Right now, there is no preference to change the grayscale calculation. At the moment it uses: grayscale value = 0.33 * red + 0.59 * green + 0.11 * blue. I found this somewhere on internet, but forgot where, and it might be wrong/unusual. I intended to add a preference setting for these values, but have not done so. Let me know if that is desired.
The calculation should match the luminosity formula found in SVG filters and masks definition, which is: 0.2125 * R + 0.7154 * G + 0.0721 * B Additionally, the calculation should be performed in linear RGB, which means you need to convert between sRGB and that. The conversion formulas can be found e.g. here in the section "useful data": http://www.sjbrown.co.uk/2004/05/14/gamma-correct-rendering/
The feature will probably need some tweaks or a partial rewrite in order to work with the Cairo branch.
Regards, Krzysztof
-----Original Message----- From: Krzysztof Kosiński [mailto:tweenk.pl@...400...] Sent: 22 February 2011 00:05
2011/2/21 <J.B.C.Engelen@...1887...>:
Hi all, I just committed a new display mode: grayscale. It is separate from the other display modes. The grayscale mode is a "Color display mode", see the menu. When activated, it shows all colors in grayscale on-canvas. This does not (yet?) influence exporting, or saving. It
only
concerns the on-canvas view of the file, like outline display mode.
Display modes should not affect exporting or saving, by design. Grayscale exporting should be handled using a preference in the export dialog.
Ivan suggested that export would copy the grayscale setting, as is done in Xara apparently. I am neutral on this issue.
Right now, there is no preference to change the grayscale calculation. At the moment it uses: grayscale value = 0.33 * red + 0.59 * green + 0.11 * blue. I found this somewhere on internet, but forgot where,
and
it might be wrong/unusual. I intended to add a preference setting for these values, but have not done so. Let me know if that is desired.
The calculation should match the luminosity formula found in SVG filters and masks definition, which is: 0.2125 * R + 0.7154 * G + 0.0721 * B Additionally, the calculation should be performed in linear RGB, which means you need to convert between sRGB and that. The conversion formulas can be found e.g. here in the section "useful data": http://www.sjbrown.co.uk/2004/05/14/gamma-correct-rendering/
Since it was meant as a quick preview mode for color figures, I figured it does not make too much sense to go all out to make it 100% correct. Probably the real grayscale output depends on which printer you have anyway. But as Jon suggested, I can use the LCMS stuff and make everybody happy.
The feature will probably need some tweaks or a partial rewrite in order to work with the Cairo branch.
I was afraid of this, but implemented it anyway :P Perhaps I can help a bit once you are done with Cairoing. At least the boilerplate stuff of verbs, menus, etc., is done now. The actual grayscale code was only half a line of code... Hope you can finish the work soon. It'd be better for your mental health I think!
Cheers, Johan
On 21/2/11 23:27, J.B.C.Engelen@...1887... wrote:
I just committed a new display mode: grayscale. It is separate from the other display modes. The grayscale mode is a "Color display mode", see the menu. When activated, it shows all colors in grayscale on-canvas. This does not (yet?) influence exporting, or saving. It only concerns the on-canvas view of the file, like outline display mode.
Shouldn't a 'Color display mode' also affect the rendering of embedded or linked images?
Right now, there is no preference to change the grayscale calculation. At the moment it uses: grayscale value = 0.33 * red + 0.59 * green + 0.11 * blue. I found this somewhere on internet, but forgot where, and it might be wrong/unusual. I intended to add a preference setting for these values, but have not done so. Let me know if that is desired.
There are already several similar conversions used in Inskcape, two in 'Extensions > Color' (Desaturate, Grayscale), and one in 'Filters > Color > Desaturate'. Possibly the formulas could be coordinated so that the same color effect is achieved, be it as color display mode, extension modifying the objects' style attribute or as SVG filter effect?
I tried assigning Shift+keypad5 to toggle the color display mode, but it does not work here on my netbook (Ctrl+keypad5 does work). Perhaps this is a Windows bug. If someone can suggest another keybinding, or...
None of the default keyboard shortcuts assigned to keys from the numeric keypad work on an Apple laptop or wireless keyboard either (the embedded or emulated numeric keypad was removed by Apple). But at least they can be remapped in a custom user keymap file.
~suv
-----Original Message----- From: suv@...2204... [mailto:suv@...2204...] On Behalf Of ~suv Sent: 22 February 2011 09:45 To: Engelen, J.B.C. (Johan) Cc: inkscape-devel@lists.sourceforge.net Subject: Re: [Inkscape-devel] New: Grayscale display mode
On 21/2/11 23:27, J.B.C.Engelen@...1887... wrote:
I just committed a new display mode: grayscale. It is separate
from
the other display modes. The grayscale mode is a "Color display
mode",
see the menu. When activated, it shows all colors in grayscale on-canvas. This does not (yet?) influence exporting, or saving. It
only
concerns the on-canvas view of the file, like outline display mode.
Shouldn't a 'Color display mode' also affect the rendering of embedded or linked images?
Yes indeed, I did not yet go to the trouble of converting pixel images. All other stuff should work though.
Ciao, Johan
Hi all,
not sure if it is relevant at all (I know next to nothing about color profiles and haven't read this thread in detail), but I remember seeing this paper about color-to-grayscale conversion a while ago, which may or may not be of interest: http://cg.postech.ac.kr/research/robust_c2g/ Just thought I'd throw it in, in case anyone is interested (be if for this feature or just generally).
Cheers, Max
2011/2/21 <J.B.C.Engelen@...1887...>:
Hi all, I just committed a new display mode: grayscale. It is separate from the other display modes. The grayscale mode is a "Color display mode", see the menu. When activated, it shows all colors in grayscale on-canvas. This does not (yet?) influence exporting, or saving. It only concerns the on-canvas view of the file, like outline display mode.
Right now, there is no preference to change the grayscale calculation. At the moment it uses: grayscale value = 0.33 * red + 0.59 * green + 0.11 * blue. I found this somewhere on internet, but forgot where, and it might be wrong/unusual. I intended to add a preference setting for these values, but have not done so. Let me know if that is desired.
I tried assigning Shift+keypad5 to toggle the color display mode, but it does not work here on my netbook (Ctrl+keypad5 does work). Perhaps this is a Windows bug. If someone can suggest another keybinding, or... thanks!
Johan
Index, Search & Analyze Logs and other IT data in Real-Time with Splunk Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. Free Software Download: http://p.sf.net/sfu/splunk-dev2dev _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
participants (5)
-
unknown@example.com
-
Jon Cruz
-
Krzysztof Kosiński
-
Maximilian Albert
-
~suv