assert image.max() < levels. It says that the maximum value of the image intensity must be less than the number of grey levels.
Because the SAR image is really big, i want to reduce the calculation time by reducing the levels to 8.
Even if i remove the parameter 'level=8' when using greycomatrix, still gives me the same error
My code is the following:
from skimage.feature import greycomatrix, greycoprops
import numpy as np
from skimage import data
import rasterio
path = 'C:\Users\GLCM_implementation\glasgow.tif'
with rasterio.open(path, 'r') as src:
import_file = src.read()
img = import_file[0,:,:] #i need only the two dimentions (height, width)
print img.shape
#calculate the GLCM specifying the distance, direction(4 directions) and number of grey levels
GLCM = greycomatrix(img, [1], [0, np.pi/4, np.pi/2, 3*np.pi/4],levels=8, symmetric=False, normed=True)
#list(GLCM[:,:,0,2])
#Calculate texture statistics
contrast = greycoprops(GLCM, 'contrast')
dissimilarity = greycoprops(GLCM, 'dissimilarity')
homogeneity = greycoprops(GLCM, 'homogeneity')
energy = greycoprops(GLCM, 'energy')
correlation = greycoprops(GLCM, 'correlation')
ASM = greycoprops(GLCM, 'ASM')
Error message:
101 image = np.ascontiguousarray(image) 102 assert image.min() >= 0 --> 103 assert image.max() < levels 104 image = image.astype(np.uint8) 105 distances = np.ascontiguousarray(distances, dtype=np.float64) AssertionError:
I would appreciate any help.
Thank you in advance
Ioannis
--
You received this message because you are subscribed to the Google Groups "scikit-image" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image+unsubscribe@googlegroups.com.
To post to this group, send email to scikit...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/scikit-image/520f5f2b-4750-4b56-a40b-28b938b750d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com.
AssertionError Traceback (most recent call last) <ipython-input-16-ca616e8222fb> in <module>() 22 23 for j in xrange(img.shape[1] ): ---> 24 glcm = greycomatrix(rescale, [1], [0], symmetric = True, normed = True ) 25 26 testraster1[i,j] = greycoprops(glcm, 'contrast') C:\Anaconda2\lib\site-packages\skimage\feature\texture.pyc in greycomatrix(image, distances, angles, levels, symmetric, normed)
101 image = np.ascontiguousarray(image)
102 assert image.min() >= 0
--> 103 assert image.max() < levels
104 image = image.astype(np.uint8)
105 distances = np.ascontiguousarray(distances, dtype=np.float64)
AssertionError:
It seems that i am allowed only to use an 8-bit image for the GLCM calculation.
So, does this code in scikit-image work only for 8-bit images? is there another way to solve my problem?
I will keep trying to find a solution but if you have an idea on how to solve this problem, please tell me
Thank you in advance
Ioannis
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image+unsubscribe@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/scikit-image/978af8fd-0dfa-47ca-9e16-4a4ccccb4bc3%40googlegroups.com.