-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The difference between PDWT and Matlab's DWT2 function. #7
Comments
If I remember correctly Matlab uses a different extension mode by default. PDWT always uses the periodic extension mode. Probably that's the cause of the discrepancy. I just tried with C = imread('ngc6543a.jpg');
I1 = C(:, :, 1);
imwrite(I1, "ngc6543a_gray.tif")
[LL,LH,HL,HH] = dwt2(I1,'haar', 'mode', 'ppd');
save("LL.mat", LL) and on the other hand with the python wrapper to PDWT: from tifffile import imread
from pycudwt import Wavelets
from scipy.io import loadmat
test_img = imread("ngc6543a_gray.tif")
W = Wavelets(test_img, "haar", 1)
W.forward()
LL = loadmat("LL.mat")["LL"] # result from matlab
print(np.max(np.abs(W.coeffs[0] - LL))) # 1e-13 which gives exactly the same result for the approximation coefficient. |
Hi! @pierrepaleo |
I have one more question. I have multiple GPUs. Can PDWT choose which specific GPU to perform cuda computation on? In addition, what do the memisonhost, do_separable, and do_cycle_spinning parameters in the Wavelets constructor represent? I look forward to your reply. |
IIRC there is no explicit GPU choice parameter in the As for parameters:
Hope this helps! |
I tried to reproduce the 2D discrete wavelet transform in Matlab and PDWT, and then plotted a histogram of the cA parameter. The results are shown in the figure below, with red representing the result from Matlab and blue representing the result from PDWT. I would like to know what could be the possible reasons for this situation?

This is my C++ code.
Wavelets w(img_f,rows,cols,"haar",1,1,1,0,0,2); w.forward(); w.get_coeff(LL, 0); //....change LL(float *) to LL(cv::Mat) cv::Mat hist_cA; const int bin = 256; float range[] = {0,255}; const float* histRange[] = {range}; cv::normalize(LL,LL,0,255,cv::NORM_MINMAX,-1); cv::calcHist(&LL,1,0,cv::Mat(),hist_cA,1,&bin,histRange,true);
This is the Matlab code.
[LL,LH,HL,HH] = dwt2(I1,'haar'); hist_cA = imhist(mat2gray(LL));
The text was updated successfully, but these errors were encountered: