Info

This question is closed. Reopen it to edit or answer.

Importing Image for Colour Conversion

3 views (last 30 days)
Justin
Justin on 16 Apr 2012
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi there,
I'm trying to use the colorspace transformation, which can be found here http://www.mathworks.com/matlabcentral/fileexchange/28790-colorspace-transformations
Here's the basic info on the function:
function varargout = colorspace(Conversion,varargin)
%COLORSPACE Transform a color image between color representations.
% B = COLORSPACE(S,A) transforms the color representation of image A
% where S is a string specifying the conversion. The input array %A should be a real full double array of size Mx3 or MxNx3. The % output B is the same size as A.
%
% S tells the source and destination color spaces, S = 'dest<-src', or
% alternatively, S = 'src->dest'.
%
% All conversions assume 2 degree observer and D65 illuminant.
So I've been trying to do this:
colour_wheel_lab = colorspace('hsv<-lab', colour_wheel)
But I keep getting error messages claiming there is an error when it gets to the source image Ii.e. image 'A' or the 'colour_wheel'). I've been loading the source image using 'imread' but I'm not sure if this puts it into the correct format for this function. Any ideas here? Do I need to convert the image into a different array?
Thanks in advance!

Answers (1)

Walter Roberson
Walter Roberson on 16 Apr 2012
Notice that A should be "a real full double array". If you are using imread() then you are probably getting an uint8 image. Use im2double() to convert it.
  1 Comment
Image Analyst
Image Analyst on 16 Apr 2012
He has an LAB image so he's already converted the RGB image into LAB, but that can be either integer or double depending on how he obtained it. I think if you used the built-in MATLAB color conversion function, makecform, then you can get either an integer LAB out, if you passed in uint8, or you can get a floating point lab image, if you passed in a floating point image. The range of the L, A, and B also varies depending on what you passed in, integers or doubles, and I'm not sure any of them are what you'd get out of a spectrophotometer or colorimeter. I'm not sure what he'd get for lab if he used the File Exchange file. Justin, any reason why you're not using the built-in "makecform()" function?

This question is closed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!