I'm using scikit-images's function greycomatrix
, to which I want to give as input one of the components obtained from wavelet transform after haar filtering.
import pywt
import cv2
from skimage.feature import greycomatrix
original = cv2.imread('img.jpg', cv2.IMREAD_GRAYSCALE)
coeffs2 = pywt.dwt2(original, 'haar')
LL, (LH, HL, HH) = coeffs2
cv2.imshow('image', HH)
gCoMat = greycomatrix(HH, [2], [0], 256, symmetric=True, normed=True)
If I pass HH
to greycomatrix
I get this error:
ValueError: Float images are not supported by greycomatrix. Convert the image to an unsigned integer type.
I tried to convert the image using this code:
from skimage import util
im = util.img_as_ubyte(HH)
im /= 32
gCoMat = greycomatrix(im, [2], [0], 256, symmetric=True, normed=True)
But I got this error:
raise ValueError("Images of type float must be between -1 and 1.") ValueError: Images of type float must be between -1 and 1.