I am using mahotas library to do texture analysis (GLCM) on a satellite image (250 x 200 pixels). GLCM calculations are carried out within a window size. So, for two adjacent positions of the sliding window we need to compute two co-occurrence matrices from scratch. I have read that I can set step size as well in order to avoid computing GLCM on overlapping areas. I have provided the code below.
#Compute haralick features
def haralick_feature(image):
haralick = mahotas.features.haralick(image, True)
return haralick
img = 'SAR_image.tif'
win_s=32 #window size
step=32 #step size
rows = img.shape[0]
cols = img.shape[1]
array = np.zeros((rows,cols), dtype= object)
harList = []
for i in range(0, rows-win_s-1, step):
print 'Row number: ', r
for j in range(0, cols-win_s-1, step):
harList.append(haralick_feature(image))
harImages = np.array(harList)
harImages_mean = harImages.mean(axis=1)
For the code above, I have set the window and step size to 32. When the code finishes, I get an image with dimensions 6 x 8 (instead of 250 x 200), it makes sense as the step size has been set to 32.
So, my question is: By setting a step size (to avoid computation in overlapping regions as well as the code gets faster) can I somehow derive the GLCM results for the whole image with dimensions 250 x 200 instead of having a subset of it (6 x 8 dimensions)? Or I have no option but looping over the image with the normal way (without setting a step size)?