I need to do an image processing in python. i want to use wavelet transform as the filterbank. Can anyone suggest me which one library should i use? I had pywavelet installed, but i don't know how to combine it with opencv. If i use wavedec2 command, it raise ValueError("Expected 2D input data.")
Can anyone help me?
Use the concatenate() Function of NumPy to Combine Images in Python. We can read images using the imread() function of OpenCV and store them in a matrix. We can use the concatenate() function of NumPy to concatenate the matrices of the images along different axes.
OpenCV is a pre-built, open-source CPU-only library (package) that is widely used for computer vision, machine learning, and image processing applications.
Introduction. OpenCV is a great tool for image processing and performing computer vision tasks. It is an open-source library that can be used to perform tasks like face detection, objection tracking, landmark detection, and much more. It supports multiple languages including python, java C++.
Hope this helps
import numpy as np
import pywt
import cv2
def w2d(img, mode='haar', level=1):
imArray = cv2.imread(img)
#Datatype conversions
#convert to grayscale
imArray = cv2.cvtColor( imArray,cv2.COLOR_RGB2GRAY )
#convert to float
imArray = np.float32(imArray)
imArray /= 255;
# compute coefficients
coeffs=pywt.wavedec2(imArray, mode, level=level)
#Process Coefficients
coeffs_H=list(coeffs)
coeffs_H[0] *= 0;
# reconstruction
imArray_H=pywt.waverec2(coeffs_H, mode);
imArray_H *= 255;
imArray_H = np.uint8(imArray_H)
#Display result
cv2.imshow('image',imArray_H)
cv2.waitKey(0)
cv2.destroyAllWindows()
w2d("test1.png",'db1',10)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With