http://www.imagemagick.org/script/comma ... #grayscale says the formula for "-colorspace gray" is "(R'^2 + G'^2 + B'^2) / 3.0".
I trust that is incorrect, and the formula is really "sqrt ((R'^2 + G'^2 + B'^2) / 3.0)".
If the documentation is correct, then the name is misleading, as the result wouldn't be the Root Mean Square.
It would be helpful if the documentation explained the difference between eg R and R'.
grayscale RMS
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
grayscale RMS
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: grayscale RMS
I do not see that at the reference you pointed to. -grayscale method will depend upon which method you choose as per http://www.imagemagick.org/script/comma ... #intensity. If the method it rec601luminance, then that is equivalent to -colorspace gray.
The formula for RMS is indeed in error and should include the sqrt. I believe that is actually what it is doing.
There is also an error in that the apostrophe formulae represent non-linear and non-apostrophe formulae represent linear.
You can verify that by
convert lena.jpg -colorspace gray lena_test1.jpg
convert lena.jpg -set colorspace RGB -colorspace gray lena_test2.jpg
convert lena.jpg -grayscale rec601luminance lena_test3.jpg
convert lena.jpg -grayscale rec601luma lena_test4.jpg
test1 and test3 are (equivalent and) darker so are linear, test2 and test4 are (equivalent and) lighter and are non-linear
I will correct the docs, tomorrow, if Anthony does not fix them tonight.
The formula for RMS is indeed in error and should include the sqrt. I believe that is actually what it is doing.
There is also an error in that the apostrophe formulae represent non-linear and non-apostrophe formulae represent linear.
You can verify that by
convert lena.jpg -colorspace gray lena_test1.jpg
convert lena.jpg -set colorspace RGB -colorspace gray lena_test2.jpg
convert lena.jpg -grayscale rec601luminance lena_test3.jpg
convert lena.jpg -grayscale rec601luma lena_test4.jpg
test1 and test3 are (equivalent and) darker so are linear, test2 and test4 are (equivalent and) lighter and are non-linear
I will correct the docs, tomorrow, if Anthony does not fix them tonight.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: grayscale RMS
The -grayscale methods are the same as -intensity
RMS was one suggested method, and by no means are all the intensity methods sorted out and finalized.
And many not be correct, -- I have not looked that closely as yet.
It is for this reason that
while producing no error does not yet list any method (they are all 'hidden').
Basically the setting/operator is not yet final.
In fact now is a good time for suggestions as what should be added/modified/tested to the methods list.
NOTE: some methods will depend on the colorspace of the image being converted. Rec709Luma and the like for example will convert to the same value for the same image regardless of the colorspace the image is in (formula is colorspace dependant).
Same goes for brightness (maximum of the pixels linear RGB values as used for HSB colorspace. However a method such as (not yet added) Maximum would probably just take the maximum of the current color values in the image regardless of what colorspace the image is currently in.
Other methods to be added probably include value from specific channel (color or some other added channel availble in IMv7),
RMS was one suggested method, and by no means are all the intensity methods sorted out and finalized.
And many not be correct, -- I have not looked that closely as yet.
It is for this reason that
Code: Select all
convert -list intensity
Basically the setting/operator is not yet final.
In fact now is a good time for suggestions as what should be added/modified/tested to the methods list.
NOTE: some methods will depend on the colorspace of the image being converted. Rec709Luma and the like for example will convert to the same value for the same image regardless of the colorspace the image is in (formula is colorspace dependant).
Same goes for brightness (maximum of the pixels linear RGB values as used for HSB colorspace. However a method such as (not yet added) Maximum would probably just take the maximum of the current color values in the image regardless of what colorspace the image is currently in.
Other methods to be added probably include value from specific channel (color or some other added channel availble in IMv7),
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/