Support Lab colorspace when color thresholding

This commit is contained in:
Cristy
2020-02-28 13:40:20 -05:00
parent cca114ad7d
commit 22018122f8
4 changed files with 49 additions and 14 deletions
-12
View File
@@ -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)
{
+2
View File
@@ -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 *,
+39
View File
@@ -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 %
% %
% %
+8 -2
View File
@@ -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) \