Page 1 of 1
-set colorspace RGB, still confused
Posted: 2013-04-04T13:49:51-07:00
by GreenKoopa
Here is another example showing that I still don't understand what
-set colorspace RGB does. Here adding it before a -threshold causes the channels I'm not operating on to change (very slightly). I don't understand why any processing time is spent on the GB channels and how that relates to colorspace?
Code: Select all
convert -size 100x1 gradient:#000-#FFF -set colorspace RGB -channel R -separate -print "%r" -threshold 50% -set colorspace RGB 1.png
convert -size 100x1 gradient:#000-#FFF -set colorspace RGB -channel R -separate -set colorspace RGB -print "%r" -threshold 50% 2.png
compare -channel R -metric MEPP 1.png 2.png null:
compare -channel G -metric MEPP 1.png 2.png null:
compare -channel B -metric MEPP 1.png 2.png null:
DirectClass Gray
DirectClass Gray
0 (0, 0)
23 (5.35527e-011, 1.5259e-005)
23 (5.35527e-011, 1.5259e-005)
ImageMagick 6.8.3-0 2013-02-13 Q16 on Windows
Re: -set colorspace RGB, still confused
Posted: 2013-04-04T15:08:44-07:00
by fmw42
Properly (to avoid possible issues) you should add +channel after -separate so that you get only the red channel in each of the 3 channels, since IM 6 does not support 1 channel images. A grayscale image is 3 channels that are all the same.
Second you do not need the second -set colorspace RGB, only the first. The image is already linear from using the first -set colorspace and thus the second one is superfluous, if the processing is done right.
Try these. I have added a -scale 100x20 so that the images can be viewed better. I am using 6.8.3.9 (There have been some grayscale issue that have occurred afterwards that caused the gamma to be set incorrectly, that should finally be cleared up in 6.8.4.7)
im6839 convert -size 100x1 gradient:#000-#FFF -set colorspace RGB -channel R -separate +channel -threshold 50% -set colorspace RGB -scale 100x20 1.png
im6839 convert -size 100x1 gradient:#000-#FFF -set colorspace RGB -channel R -separate +channel -set colorspace RGB -threshold 50% -scale 100x20 2.png
im6839 convert -size 100x1 gradient:#000-#FFF -set colorspace RGB -channel R -separate +channel -threshold 50% -scale 100x20 3.png
The last one is the one that is correct, though all will give the same results.
Image: 1.png
Class: PseudoClass
Colorspace: Gray
Type: Bilevel
Depth: 8/1-bit
Alpha: False
Channels: gray
Rendering intent: Undefined
Gamma: 1
Image: 2.png
Class: PseudoClass
Colorspace: Gray
Type: Bilevel
Depth: 8/1-bit
Alpha: False
Channels: gray
Rendering intent: Undefined
Gamma: 1
Image: 3.png
Class: PseudoClass
Colorspace: Gray
Type: Bilevel
Depth: 8/1-bit
Alpha: False
Channels: gray
Rendering intent: Undefined
Gamma: 1
The important parts are the colorspace/type and gamma.
Re: -set colorspace RGB, still confused
Posted: 2013-04-04T19:35:55-07:00
by GreenKoopa
My apologies for not being clear. These two examples produce what I expect and are visually identical. Omitting +channel is intentional. It shows that despite working with only the red channel, the BG channels are getting modified by -threshold. The change is slight, but because of the -channel R there should be no processing at all. I agree that the second -set colorspace RGB should be superfluous. In the first case, it does nothing. But in the second case, it halves the processing time (with -size 3000x20000 and output to null:) and changes (or probably stops changing) the results. I don't understand why?
Re: -set colorspace RGB, still confused
Posted: 2013-04-04T20:13:17-07:00
by fmw42
If you only want to process the Red channel you have to leave off -separate and then add +channel at the end so that it turns on the GB channels.
Once you specify -separate, IM takes the one channel and makes it into 3 identical channels.
It does not make sense to me that your second command would work any faster than the first, just because you put -set colorspace RGB before -threshold vs after it. It is just a setting and does nothing itself in terms of pixel processing.
I am not sure why the red difference is 0 and the other two channels are 23. But 23 out 65535 is insignificant.
Re: -set colorspace RGB, still confused
Posted: 2013-04-11T11:47:28-07:00
by GreenKoopa
fmw42 wrote:Second you do not need the second -set colorspace RGB, only the first. The image is already linear from using the first -set colorspace and thus the second one is superfluous, if the processing is done right.
The second
-set colorspace RGB, despite being labeled superfluous, is causing an even larger difference in version 6.8.4-8.