## JAB XYZ conversion

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?".
tag
Posts: 3
Joined: 2020-01-16T06:34:32-07:00
Authentication code: 1152

### JAB XYZ conversion

Hello,

Thanks for implementing the JAB / XYZ conversions !

Two questions:
1) What are the typical ranges of values for Jz, Bz and Bz ?
(In LAB we see most frequently values in the range of 0-100 for L and -100-100 for both A and B.)

I copied your C code as is and ran it in a Mac Xcode environment. Unfortunately I get "nan" errors
(the argument to the power function is negative).
Here is an example:
Jz: 0.0100000000 Az: 0.0100000000 Bz: 0.0100000000
Lp: -0.0739180044 Mp: 0.1188013079 Sp: 0.4673181094
L: nan M: 0.0008343982 S: 0.0353095188
I had previously coded the JAB/XYZ in Mathematica based on the original article of Safdar et. al.
but ran into similar problems. But since I am unsure of what range of values to feed the function
this may be the source of my problems.

I would greatly appreciate any help/suggestions you could make !

Many Thanks !

snibgo
Posts: 12922
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

### Re: JAB XYZ conversion

Perhaps you are referring to my Jzazbz colorspace page. IM does not (yet) have the Jzazbz and JzCzhz colorspaces.

My implementation calculates all three channels in a range of zero to QuantumRange, with neutral values of az and bz as 50% of quantum.

I point out in the Numerical Values section that converting a sRGB image to Jzazbz results in Jz close to zero, and az and bz close to 50%. "Close" means a couple of percent.

Thus, values of az and bz of around 1% will not be colours in the sRGB colorspace. I expect they are not colours at all.
snibgo's IM pages: im.snibgo.com

tag
Posts: 3
Joined: 2020-01-16T06:34:32-07:00
Authentication code: 1152

### Re: JAB XYZ conversion

Hello,

Thanks for the swift reply ! Can you tell me where QuantumRange is defined
or what its value is ? I did not find it on your page where the code is.

Many Thanks !

snibgo
Posts: 12922
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

### Re: JAB XYZ conversion

QuantumRange is defined in one of the IM header files. The value depends on the Q-number of the IM installation: 2^N-1. For Q8 this is 255, for Q16 it is 65535, for Q32 it is 4294967295.

I'm not sure that my implementation of Jzazbz and JzCzhz is correct, but I can't find any other implementation to compare it against.
snibgo's IM pages: im.snibgo.com

tag
Posts: 3
Joined: 2020-01-16T06:34:32-07:00
Authentication code: 1152

### Re: JAB XYZ conversion

OK thanks for the information.

I have written to the authors (Safdar et. al. ) of the original article regarding value ranges
but have not as yet received a reply. If they do reply I will post the response here.

In any case many thanks for your help !

magick
Posts: 11220
Joined: 2003-05-31T11:32:55-07:00

### Re: JAB XYZ conversion

snibgo
Posts: 12922
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

### Re: JAB XYZ conversion

@magick: You have my permission to refactor my code under the ImageMagick license. (Or to do anything else with it that you want.)

There are three diff files, from v7.0.8-64:

http://snibgo.com/imforums/jz_colorspace_c.diff
http://snibgo.com/imforums/jz_colorspace_h.diff
http://snibgo.com/imforums/jz_option_c.diff

The property "JzazbzDebug" dumps values at every pixel. I put this in for easy comparison with other implementations. But you might want to remove that.

The property "JzazbzPeakLum" is only a small penalty, and I think it is useful.
snibgo's IM pages: im.snibgo.com

snibgo
Posts: 12922
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

### Re: JAB XYZ conversion

@tag: When the colorspace are incorporated into ImageMagick, you will be able to do things like this:

Code: Select all

``````magick xc:rgb(1%,49%,51%) -set colorspace Jzazbz -colorspace sRGB txt:

# ImageMagick pixel enumeration: 1,1,4294967295,srgb