Version: ImageMagick 7.0.5-0 Q16 x86_64 + Perl Magic + Linux

When converting from XYZ to xyY any pixels with X+Y+Z=0 values are converted to NaN (within Perl Magick). These need to be changed by the user to sensible values for onward processing.

In my own processing, I'm converting from XYZ to xyY - processing - then converting back to XYZ. I'm using ACES colour space so negative values of y can (and do) happen. Also processing in HDI so negative values of Y are possible (although I usually clamp these to zero).

It would be really useful if the conversion routine could resolve the NaN issue within the conversion.

The (veritable) Mr Lindbloom suggests that under these conditions the x & y values should be set to the color space white point (which may differ from file to file) and the Y value should be set to 0. http://www.brucelindbloom.com/index.htm ... atrix.html. In addition, when Y=0 then the current conversion results in y=0, which gives additional problems with the inverse conversion.

The inverse conversion has a singularity at y=0, again giving a NaN. Mr Lindbloom suggests under these conditions the result should be set to X=Y=Z=0.

However, when working with wide colorspaces (like ACES) which can have legitimate y=0 values (and non zero x & Y values) this solution may not be ideal. I'll think this one through more thoroughly when I've got some spare time. Perhaps the inverse transformation equations can be reworked to remove this singularity? Possibly the y=0 value should be "nudged" slightly to give a positive value? In the meantime X=Y=Z=0 is better than NaN.

Would it be possible for the wizards to implement this?

Alternatively, is there a

**computationally efficient**way of removing the NaN's as suggested above using normal IM commands? I've tried creating an alpha mask then compositing a single value image with the original image and mask, which works, but is horrendously inefficient (I've 10,000's of big files to process).

Mike