Lab colorspace - clipping

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
User avatar
fmw42
Posts: 25756
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Lab colorspace - clipping

Post by fmw42 » 2014-08-01T11:52:02-07:00

Can you upload your image somewhere like dropbox.com (public folder), so I can download it and check things out?

User avatar
fmw42
Posts: 25756
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Lab colorspace - clipping

Post by fmw42 » 2014-08-01T11:53:44-07:00

probably due to the colors in your Paint file being sRGB and -colorspace changing them to linear RGB. Try using -colorspace sRGB in your command.

to be honest, I am still confused about why you are changing to linear RGB. In what colorspace is your input data? Were you not starting with LAB data or just trying to convert to LAB from sRGB.

jwtrexler
Posts: 31
Joined: 2014-07-03T22:03:37-07:00
Authentication code: 6789

Re: Lab colorspace - clipping

Post by jwtrexler » 2014-08-01T12:14:46-07:00

At the end, I will be starting with an RGB digital image from my camera, then converting the digital image to Lab space so I can compare tge Lab values a control image which I have had the Lab values determined with a colorimeter.

As for sending the file, I will try e-mailing it to you and if that doesn't work, I'll place it on a dropbox public folder, but I'll need to set one up, unless you are aware of a public folder already.

jwtrexler
Posts: 31
Joined: 2014-07-03T22:03:37-07:00
Authentication code: 6789

Re: Lab colorspace - clipping

Post by jwtrexler » 2014-08-01T12:44:10-07:00

Fmw42,
The color swatch I have been processing can be down loaded from:
mgur.com/LYHz9bE
and url is case sensitive.

jwtrexler
Posts: 31
Joined: 2014-07-03T22:03:37-07:00
Authentication code: 6789

Re: Lab colorspace - clipping

Post by jwtrexler » 2014-08-01T13:00:07-07:00

Fmw42,
You were right about the colorspace converting correctly. Hopefully this does not cause issues in converting to Lab space; I'll try that next.

As always, thank you for your help.

User avatar
fmw42
Posts: 25756
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Lab colorspace - clipping

Post by fmw42 » 2014-08-01T14:52:17-07:00

jwtrexler wrote:Fmw42,
The color swatch I have been processing can be down loaded from:
mgur.com/LYHz9bE
and url is case sensitive.
The web site cannot be found.

When you say you are starting with RGB, I think you really mean sRGB. Most tools create sRGB images and IM assumes them to be sRGB unless told otherwise. If you are on a current version of IM, -colorspace RGB will convert to linear RGB, which will be darker. Older IM systems had sRGB and RGB swapped in -colorspace. see viewtopic.php?f=4&t=21269

So if you have created an image with r,g,b values in Paint, I would assume they were sRGB. Thus -colorspace sRGB can be added with no effect, but it can be left off. If you want to be sure, and you know it is sRGB, then just use -set colorspace sRGB (before any other colorspace conversion).

Code: Select all

convert rgbimage -set colorspace sRGB -colorspace LAB -separate +channel labimage_%d.png

or try these for testing

Code: Select all

convert -size 1x1 xc:red -set colorspace sRGB -format "%[fx:mean.r] %[fx:mean.g] %[fx:mean.b]\n" info:
1 0 0

Code: Select all

convert -size 1x1 xc:red -set colorspace sRGB -colorspace LAB -format "%[fx:mean.r] %[fx:mean.g] %[fx:mean.b]\n" info:
0.532311 0.814176 0.763607

Code: Select all

convert -size 1x1 xc:red -set colorspace sRGB -colorspace LAB -format "%[fx:u.r] %[fx:u.g] %[fx:u.b]\n" info:
0.532311 0.814176 0.763607

Code: Select all

convert -size 1x1 xc:red -set colorspace sRGB -format "%[pixel:u.p{0,0}]\n" info:
red

Code: Select all

convert -size 1x1 xc:red -set colorspace sRGB -colorspace LAB -format "%[pixel:u.p{0,0}]\n" info:
cielab(53.2311%,81.4176%,76.3607%)


Code: Select all

convert -size 1x1 xc:red -set colorspace sRGB txt:
# ImageMagick pixel enumeration: 1,1,65535,srgb
0,0: (100%,0%,0%) #FFFF00000000 red

Code: Select all

convert -size 1x1 xc:red -set colorspace sRGB -colorspace LAB txt:
# ImageMagick pixel enumeration: 1,1,65535,cielab
0,0: (53.2311%,31.4168%,26.36%) #8845506D437B cielab(53.2311%,31.4168%,26.36%)


Seems still to be a bug. The values for LAB from txt:, do not agree with the others.


convert -version
Version: ImageMagick 6.8.9-6 Q16 x86_64 2014-07-28 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib cairo fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms lqr ltdl lzma openexr png ps rsvg tiff webp x xml zlib

jwtrexler
Posts: 31
Joined: 2014-07-03T22:03:37-07:00
Authentication code: 6789

Re: Lab colorspace - clipping

Post by jwtrexler » 2014-08-04T07:47:58-07:00

Is there a similar way to apply your suggestion using mean.r, mean.g, and mean.b to other statistical parameters, such as maxima, standard_deviation and kurtosis? I tried the identical approach (e.g. fx: maxima.r) with the first couple statistics and did not have success.

User avatar
fmw42
Posts: 25756
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Lab colorspace - clipping

Post by fmw42 » 2014-08-04T10:17:59-07:00

Works fine for me with IM 6.8.9.6 Q16 Max OSX. Note there is only one pixel. So min and max will be the same and std will be zero.

Code: Select all

convert -size 1x1 xc:red -set colorspace sRGB -format "%[fx:maxima.r] %[fx:maxima.g] %[fx:maxima.b]\n" info:
1 0 0

Code: Select all

convert -size 1x1 xc:red -set colorspace sRGB -format "%[fx:minima.r] %[fx:minima.g] %[fx:minima.b]\n" info:
1 0 0

Code: Select all

convert -size 1x1 xc:red -set colorspace sRGB -format "%[fx:standard_deviation.r] %[fx:standard_deviation.g] %[fx:standard_deviation.b]\n" info:
0 0 0

Try with two appended pixels of different colors

Code: Select all

convert -size 1x1 xc:red xc:blue +append -set colorspace sRGB -format "%[fx:maxima.r] %[fx:maxima.g] %[fx:maxima.b]\n" info:
1 0 1

Code: Select all

convert -size 1x1 xc:red xc:blue +append -set colorspace sRGB -format "%[fx:minima.r] %[fx:minima.g] %[fx:minima.b]\n" info:
0 0 0

Code: Select all

convert -size 1x1 xc:red xc:blue +append -set colorspace sRGB -format "%[fx:standard_deviation.r] %[fx:standard_deviation.g] %[fx:standard_deviation.b]\n" info:
0.5 0 0.5

Post Reply