mirror of
https://github.com/ImageMagick/ImageMagick.git
synced 2026-06-08 15:37:13 +02:00
Support Lab colorspace when color thresholding
This commit is contained in:
@@ -197,18 +197,6 @@ static void ConvertRGBToLMS(const double red,const double green,
|
||||
ConvertXYZToLMS(X,Y,Z,L,M,S);
|
||||
}
|
||||
|
||||
static void ConvertRGBToLab(const double red,const double green,
|
||||
const double blue,double *L,double *a,double *b)
|
||||
{
|
||||
double
|
||||
X,
|
||||
Y,
|
||||
Z;
|
||||
|
||||
ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z);
|
||||
ConvertXYZToLab(X,Y,Z,L,a,b);
|
||||
}
|
||||
|
||||
static void ConvertRGBToLuv(const double red,const double green,
|
||||
const double blue,double *L,double *u,double *v)
|
||||
{
|
||||
|
||||
@@ -69,6 +69,8 @@ extern MagickPrivate void
|
||||
double *),
|
||||
ConvertRGBToHWB(const double,const double,const double,double *,double *,
|
||||
double *),
|
||||
ConvertRGBToLab(const double,const double,const double,double *,double *,
|
||||
double *),
|
||||
ConvertRGBToLCHab(const double,const double,const double,double *,double *,
|
||||
double *),
|
||||
ConvertRGBToLCHuv(const double,const double,const double,double *,double *,
|
||||
|
||||
@@ -1273,6 +1273,45 @@ MagickPrivate void ConvertRGBToHWB(const double red,const double green,
|
||||
% %
|
||||
% %
|
||||
% %
|
||||
% C o n v e r t R G B T o L a b %
|
||||
% %
|
||||
% %
|
||||
% %
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%
|
||||
% ConvertRGBToLab() transforms a (red, green, blue) to a (L, a, b) triple.
|
||||
%
|
||||
% The format of the ConvertRGBToLCHab method is:
|
||||
%
|
||||
% void ConvertRGBToLCHab(const double red,const double green,
|
||||
% const double blue,double *L,double *a,double *b)
|
||||
%
|
||||
% A description of each parameter follows:
|
||||
%
|
||||
% o red, green, blue: A Quantum value representing the red, green, and
|
||||
% blue component of a pixel.
|
||||
%
|
||||
% o L, a, b: A pointer to a double value representing a component of the
|
||||
% Lab color space.
|
||||
%
|
||||
*/
|
||||
MagickPrivate void ConvertRGBToLab(const double red,const double green,
|
||||
const double blue,double *L,double *a,double *b)
|
||||
{
|
||||
double
|
||||
X,
|
||||
Y,
|
||||
Z;
|
||||
|
||||
ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z);
|
||||
ConvertXYZToLab(X,Y,Z,L,a,b);
|
||||
}
|
||||
|
||||
/*
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% %
|
||||
% %
|
||||
% %
|
||||
% C o n v e r t R G B T o L C H a b %
|
||||
% %
|
||||
% %
|
||||
|
||||
@@ -1289,6 +1289,14 @@ MagickExport MagickBooleanType ColorThresholdImage(Image *image,
|
||||
&stop.red,&stop.green,&stop.blue);
|
||||
break;
|
||||
}
|
||||
case LabColorspace:
|
||||
{
|
||||
ConvertRGBToLab(start_color->red,start_color->green,start_color->blue,
|
||||
&start.red,&start.green,&start.blue);
|
||||
ConvertRGBToLab(stop_color->red,stop_color->green,stop_color->blue,
|
||||
&stop.red,&stop.green,&stop.blue);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
start.red*=QuantumScale;
|
||||
@@ -1307,8 +1315,6 @@ MagickExport MagickBooleanType ColorThresholdImage(Image *image,
|
||||
stop.green*=QuantumRange;
|
||||
stop.blue*=QuantumRange;
|
||||
progress=0;
|
||||
/* convert start/stop colorspace to the same as image colorspace */
|
||||
/* for hsv() will need ConvertRGBToHSV() and them compare in HSV */
|
||||
image_view=AcquireAuthenticCacheView(image,exception);
|
||||
#if defined(MAGICKCORE_OPENMP_SUPPORT)
|
||||
#pragma omp parallel for schedule(static) shared(progress,status) \
|
||||
|
||||
Reference in New Issue
Block a user