Skimage/LAB-Transformation and grayscale images

153 views Asked by At

I am converting several images from rgb-colorspace to LAB-colorspace usign skimage.rgb2lab. In general this works pretty fine except for some grayscale images as they only contain a 2 color channels thus a 2-dimensional array and rgb2lab requires a 3-dimensional array.

Is there anyway to transform a grayscaleimage with only 2 channels into LAB space?

1

There are 1 answers

0
Mark Setchell On

There are some slightly odd aspects to your question, but in an effort to try and move you along, I would suggest you synthesize a zero-filled additional channel and stack that with your existing 2 channels to make 3. Along these lines:

extraChannel = np.zeros_like(twoChannel[...,0])
threeChannel = np.dstack((twoChannel, extraChannel))