diff --git a/MagickCore/gem.c b/MagickCore/gem.c
index 3866087..14d7d79 100644
--- a/MagickCore/gem.c
+++ b/MagickCore/gem.c
@@ -1330,15 +1330,25 @@
 %      component of the LCH color space.
 %
 */
+
+static inline void ConvertXYZToLCHab(const double X,const double Y,
+  const double Z,double *luma,double *chroma,double *hue)
+{
+  double
+    a,
+    b;
+
+  ConvertXYZToLab(X,Y,Z,luma,&a,&b);
+  *chroma=hypot(a,b);
+  *hue=180.0*atan2(b,a)/MagickPI;
+  if (*hue < 0.0)
+    *hue+=360.0;
+}
+
 MagickPrivate void ConvertRGBToLCHab(const double red,const double green,
   const double blue,double *luma,double *chroma,double *hue)
 {
   double
-    a,
-    b,
-    C,
-    H,
-    L,
     X,
     Y,
     Z;
@@ -1350,14 +1360,7 @@
   assert(chroma != (double *) NULL);
   assert(hue != (double *) NULL);
   ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z);
-  ConvertXYZToLab(X,Y,Z,&L,&a,&b);
-  C=hypot(255.0*(a-0.5)/500.0,255.0*(b-0.5)/200.0);
-  H=180.0*atan2(255.0*(b-0.5)/200.0,255.0*(a-0.5)/500.0)/MagickPI/360.0;
-  if (H < 0.0)
-    H+=1.0;
-  *luma=(100.0*L+16.0)/116.0;
-  *chroma=C;
-  *hue=H;
+  ConvertXYZToLCHab(X,Y,Z,luma,chroma,hue);
 }
 
 /*
@@ -1388,15 +1391,25 @@
 %      component of the LCHuv color space.
 %
 */
+
+static inline void ConvertXYZToLCHuv(const double X,const double Y,
+  const double Z,double *luma,double *chroma,double *hue)
+{
+  double
+    a,
+    b;
+
+  ConvertXYZToLab(X,Y,Z,luma,&a,&b);
+  *chroma=hypot(a,b);
+  *hue=180.0*atan2(b,a)/MagickPI;
+  if (*hue < 0.0)
+    *hue+=360.0;
+}
+
 MagickPrivate void ConvertRGBToLCHuv(const double red,const double green,
   const double blue,double *luma,double *chroma,double *hue)
 {
   double
-    C,
-    H,
-    L,
-    u,
-    v,
     X,
     Y,
     Z;
@@ -1408,16 +1421,7 @@
   assert(chroma != (double *) NULL);
   assert(hue != (double *) NULL);
   ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z);
-  ConvertXYZToLuv(X,Y,Z,&L,&u,&v);
-  C=hypot((354.0*u-134.0)/100.0,(262.0*v-140.0)/100.0);
-  H=180.0*atan2((262.0*v-140.0)/100.0,(354.0*u-134.0)/100.0)/MagickPI/360.0;
-  if (H < 0.0)
-    H+=1.0;
-  if (H >= 1.0)
-    H-=1.0;
-  *luma=L;
-  *chroma=C;
-  *hue=H;
+  ConvertXYZToLCHuv(X,Y,Z,luma,chroma,hue);
 }
 
 /*