From 7715f0c1001cedbbce336757866499e19a9d0d27 Mon Sep 17 00:00:00 2001 From: DavidMOBrien Date: Sat, 14 Jan 2023 16:21:00 -0600 Subject: [PATCH] remove TODO --- SimpleCV/ImageClass.py | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/SimpleCV/ImageClass.py b/SimpleCV/ImageClass.py index 3207a927d..ea522dbf2 100644 --- a/SimpleCV/ImageClass.py +++ b/SimpleCV/ImageClass.py @@ -4005,26 +4005,25 @@ def applyHLSCurve(self, hCurve, lCurve, sCurve): :py:class:`ColorCurve` :py:meth:`applyRGBCurve` """ + if( hCurve is None or lCurve is None or sCurve is None ): + logger.warning("ImageClass.applyHLSCurve - we need all three curves") + return None + if( not isinstance(hCurve, ColorCurve) or not isinstance(lCurve, ColorCurve) or not isinstance(sCurve, ColorCurve) ): + logger.warning("ImageClass.applyHLSCurve - we need all three curves to be ColorCurve objects") + return None - #TODO CHECK ROI - #TODO CHECK CURVE SIZE - #TODO CHECK COLORSPACE - #TODO CHECK CURVE SIZE - temp = cv.CreateImage(self.size(), 8, 3) - #Move to HLS space - cv.CvtColor(self._bitmap, temp, cv.CV_RGB2HLS) - tempMat = cv.GetMat(temp) #convert the bitmap to a matrix - #now apply the color curve correction - tempMat = np.array(self.getMatrix()).copy() - tempMat[:, :, 0] = np.take(hCurve.mCurve, tempMat[:, :, 0]) - tempMat[:, :, 1] = np.take(sCurve.mCurve, tempMat[:, :, 1]) - tempMat[:, :, 2] = np.take(lCurve.mCurve, tempMat[:, :, 2]) - #Now we jimmy the np array into a cvMat - image = cv.CreateImageHeader((tempMat.shape[1], tempMat.shape[0]), cv.IPL_DEPTH_8U, 3) - cv.SetData(image, tempMat.tostring(), tempMat.dtype.itemsize * 3 * tempMat.shape[1]) - cv.CvtColor(image, image, cv.CV_HLS2RGB) - return Image(image, colorSpace=self._colorSpace) + if( len(hCurve) != 256 or len(lCurve) != 256 or len(sCurve) != 256 ): + logger.warning("ImageClass.applyHLSCurve - we need all three curves to be 256 points long") + return None + + retVal = self.getEmpty() + cv.CvtColor(self.getBitmap(), retVal, cv.CV_BGR2HLS) + cv.LUT(retVal, hCurve.getCurve(), retVal) + cv.LUT(retVal, lCurve.getCurve(), retVal) + cv.LUT(retVal, sCurve.getCurve(), retVal) + cv.CvtColor(retVal, retVal, cv.CV_HLS2BGR) + return Image(retVal) def applyRGBCurve(self, rCurve, gCurve, bCurve): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy