Page 1 of 1

colorspace: gray channel handling

Posted: 2012-08-05T20:19:19-07:00
by fmw42
I am converting to grayscale so I am using the average of RGB values.
-colorspace gray is not an equal mix (average) of the r,g,b channels, if that matters. To get equal average, use -colorspace OHTA -channel R.

see
http://www.imagemagick.org/script/comma ... colorspace

Re: Getting pixel coordinates of individual pixels in an ima

Posted: 2012-08-05T22:37:31-07:00
by anthony
The R channel from OHTA seems a lot darker than average. Mayby it is another colorspace bug?

see the last image (Average OHTA) added to the example in...
http://www.imagemagick.org/Usage/color_ ... #grayscale

Re: Getting pixel coordinates of individual pixels in an ima

Posted: 2012-08-05T22:52:51-07:00
by fmw42
anthony wrote:The R channel from OHTA seems a lot darker than average. Mayby it is another colorspace bug?

see the last image (Average OHTA) added to the example in...
http://www.imagemagick.org/Usage/color_ ... #grayscale

I get the same results from using my graytoning script (which uses -color-matrix) and using the first channel of OHTA


graytoning -r 33.3333 -g 33.3333 -b 33.3333 rose: rose_ave.gif

convert rose: -set colorspace RGB -colorspace OHTA -channel r -separate rose_ohta_r.gif

Note that both use -set colorspace RGB. So you have to compare both with or both without. If without (linear gray), both results will be darker.

Re: Getting pixel coordinates of individual pixels in an ima

Posted: 2012-08-07T19:40:14-07:00
by anthony
Then the OHTA colorspace is not defined right!

Re: Getting pixel coordinates of individual pixels in an ima

Posted: 2012-08-07T21:08:19-07:00
by fmw42
anthony wrote:Then the OHTA colorspace is not defined right!
Same thing with all the other colorspaces. They convert to linear channels and will show darker than if converted keeping them non-linear.

Re: Getting pixel coordinates of individual pixels in an ima

Posted: 2012-08-07T21:49:14-07:00
by anthony
fmw42 wrote:
anthony wrote:Then the OHTA colorspace is not defined right!
Same thing with all the other colorspaces. They convert to linear channels and will show darker than if converted keeping them non-linear.
Hmmm I re-ran the examples for pulling grays from various colorspaces..
http://www.imagemagick.org/Usage/color_ ... #grayscale

The LAB lightness channel seems to be very odd!

Re: Getting pixel coordinates of individual pixels in an ima

Posted: 2012-08-07T21:57:48-07:00
by fmw42
my results from running your tests on IM 6.7.8.8 at http://www.imagemagick.org/Usage/color_ ... #grayscale are totally different from yours due to the channels being linear, except for OHTA. Most if not all images are much darker or more binary. By the way, you misspelled OHTA (as OTHA).

If I run them adding -set colorspace RGB, then I get your results, except for OHTA looks bright and LAB looks very bright.

Re: Getting pixel coordinates of individual pixels in an ima

Posted: 2012-08-07T22:02:18-07:00
by anthony
fmw42 wrote:my results from running your tests on IM 6.7.8.8 at http://www.imagemagick.org/Usage/color_ ... #grayscale are totally different from yours due to the fact that now individual channels are linear. Most if not all images are much darker. By the way, you misspelled OHTA (as OTHA).
GIVE it tome to update!!!!
The LAB image stands out, everything else is rather 'dark' by comparision.

Also this round trip failed!

Code: Select all

   convert rose: -separate -swap 0,2 -combine rose_rb_swap.gif
As such I do not think -separate actually sets colorspace quite right internally.

Re: Getting pixel coordinates of individual pixels in an ima

Posted: 2012-08-07T22:06:42-07:00
by fmw42
Also this round trip failed!

Code: Select all

convert rose: -separate -swap 0,2 -combine rose_rb_swap.gif
That is not a round trip. Perhaps I misunderstand what you are doing.

Re: Getting pixel coordinates of individual pixels in an ima

Posted: 2012-08-07T22:21:57-07:00
by fmw42
When this all gets straightened out, it might be nice to show both the linear and non-linear versions, especially as now that grayscale is linear and before it was non-linear.

Re: Getting pixel coordinates of individual pixels in an ima

Posted: 2012-08-07T22:26:51-07:00
by anthony
fmw42 wrote:
Also this round trip failed!

Code: Select all

convert rose: -separate -swap 0,2 -combine rose_rb_swap.gif
That is not a round trip. Perhaps I misunderstand what you are doing.
Yes. not really, but this is and the result is still 'darker' than it should be if colorspaces are being handled right.

Code: Select all

convert rose: -separate -combine test.gif
Neither of the two commands should really change data values in the image. The point of these are to gain access to data values, not modify them. Sure the 'gray' channel images from -separate is marked 'linear-gray' the values however should still conatin non-linear sRGB channel values, as that is what was asked for. Look like that is not the case!

Though really -combine needs a destination 'colorspace' argument. as such this I would have definatally expected to come out correct! But also comes out dark.

Code: Select all

   convert rose: -separate -combine -set colorspace sRGB test.gif
Actually it needs to be a proper argument so the -combine can handle CMYK due to the extra channel, ditto for RGBA or sRGBA. That is something that should have been done a LONG time ago!