1

I am trying to use Region based Histogram Equalization on 'Approximation Coefficients' generated from Wavelet Decomposition.

Here is the code:-

loading image

img = cv2.imread("some_image.jpg")

discrete wavelet transform - cA Approx Coeff; cD Detail Coeff

cA, cD = pywt.dwt(img, 'db2')

Applying CLAHE (Contrast Limited Adaptive Histogram Equalization) on cA - Approx Coeff

clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
clahe.apply(cA)

I want to apply Contrast Limited Adaptive Histogram Equalization on 'cA'(Approx Coeff) however python throws an error. Can someone tell me where am I going wrong?

error: C:\projects\opencv-python\opencv\modules\imgproc\src\clahe.cpp:360: error: (-215) _src.type() == CV_8UC1 || _src.type() == CV_16UC1 in function `anonymous-namespace'::CLAHE_Impl::apply

UPDATE: I am trying to accomplish the Approx Coefficients-> REgion based histogram enhancement section of the diagram. Block diagram

Abishek S
  • 11
  • 4
  • 1
    basically it tells you that it accepts an 8bit greyscale image (1 channel) or 16 bit image (also 1 channel). OpenCV loads by default RGB images (even if it is a greyscale one). You can add another parameter (cv2.IMREAD_GRAYSCALE) to the imread function (2nd position) to load the image as a greyscale – api55 Dec 11 '17 at 10:22
  • I have updated the post with a link to the block diagram I am working on. For some reason CLAHE does not accept 'cA' as a proper input source. – Abishek S Dec 11 '17 at 11:01
  • print the shape of cA and it's type – api55 Dec 11 '17 at 12:49
  • shape: (720, 1280, 3) type: – Abishek S Dec 12 '17 at 04:16
  • the last ,3 tells you that it is a BGR (or any other 3 channel image) image and it should be 1 channel – api55 Dec 12 '17 at 05:55
  • The last 3 is indicative of the type of Wavelet Daubechies (db) you use. db1 gives rise to (720,1280,2) db2 gives rise to (720,1280,3) – Abishek S Dec 12 '17 at 06:07
  • The last three is NOT related to the number of channels but rather the type of wavelet decomposition one chooses. – Abishek S Dec 12 '17 at 06:09
  • well, in OpenCV it they want it to be 1 as the documentation says, I do not doubt your work, just I am telling you what OpenCV is expecting as input type.... to make it work it has to be "1 channel" or in other words 2 dimensional image like structure... – api55 Dec 12 '17 at 06:54

0 Answers0