Info

此问题已关闭。 请重新打开它进行编辑或回答。

Importing Image for Colour Conversion

1 次查看(过去 30 天)
Justin
Justin 2012-4-16
关闭: MATLAB Answer Bot 2021-8-20
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!

回答(1 个)

Walter Roberson
Walter Roberson 2012-4-16
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 个评论
Image Analyst
Image Analyst 2012-4-16
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?

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by