def testImage(image_list): global arr1 global flag arr1.clear() for index in range(len(image_list)): img = io.imread(image_list[index], as_grey=True) infile = cv2.imread(image_list[index]) infile = infile[:, :, 0] hues = (np.array(infile) / 255.) * 179 outimageHSV = np.array([[[b, 255, 255] for b in a] for a in hues]).astype(int) outimageHSV = np.uint8(outimageHSV) outimageBGR = cv2.cvtColor(outimageHSV, cv2.COLOR_HSV2BGR) rgb = io.imread(image_list[index]) lab = color.rgb2lab(rgb) outimageBGR = lab for i in range(outimageBGR.shape[0]): for j in range(outimageBGR.shape[1]): sum = 0 for k in range(outimageBGR.shape[2]): sum = sum + outimageBGR[i][j][k] sum = sum / (3 * 255) if (i < img.shape[0] and j < img.shape[1]): img[i][j] = sum S = preprocessing.MinMaxScaler((0, 19)).fit_transform(img).astype(int) Grauwertmatrix = feature.greycomatrix( S, [1, 2, 3], [0, np.pi / 4, np.pi / 2, 3 * np.pi / 4], levels=20, symmetric=False, normed=True) arr1.append(feature.greycoprops(Grauwertmatrix, 'contrast')) arr1.append(feature.greycoprops(Grauwertmatrix, 'correlation')) arr1.append(feature.greycoprops(Grauwertmatrix, 'homogeneity')) arr1.append(feature.greycoprops(Grauwertmatrix, 'ASM')) arr1.append(feature.greycoprops(Grauwertmatrix, 'energy')) arr1.append(feature.greycoprops(Grauwertmatrix, 'dissimilarity')) arr1.append(Features.sumOfSquares(Grauwertmatrix)) arr1.append(Features.sumAverage(Grauwertmatrix)) arr1.append(Features.sumVariance(Grauwertmatrix)) arr1.append(Features.Entropy(Grauwertmatrix)) arr1.append(Features.sumEntropy(Grauwertmatrix)) arr1.append(Features.differenceVariance(Grauwertmatrix)) arr1.append(Features.differenceEntropy(Grauwertmatrix)) arr1.append(Features.informationMeasureOfCorelation1(Grauwertmatrix)) arr1.append(Features.informationMeasureOfCorelation2(Grauwertmatrix)) flag = 1
def pr(): print('\n') print("Contrast : %f" % (np.mean(ContrastStats))) print("Energy : %f" % (np.mean(Energy))) print("Dissimilarity : %f" % (np.mean(Dissimilarity))) print("Correlation : %f" % (np.mean(CorrelationtStats))) print("Homogeneity : %f" % (np.mean(ASMStats))) print("Sum of Squares : %f" % (np.mean(Features.sumOfSquares(Grauwertmatrix)))) print("Sum Average : %f" % (np.mean(Features.sumAverage(Grauwertmatrix)))) print("Sum Variance : %f" % (np.mean(Features.sumVariance(Grauwertmatrix)))) print("Sum Entropy : %f" % (np.mean(Features.sumEntropy(Grauwertmatrix)))) print("Entropy : %f" % (np.mean(Features.Entropy(Grauwertmatrix)))) print("Difference Variance : %f" % (np.mean(Features.differenceVariance(Grauwertmatrix)))) print("Difference Entropy : %f" % (np.mean(Features.differenceEntropy(Grauwertmatrix)))) print("Information measure of corelation1: %f" % (np.mean(Features.informationMeasureOfCorelation1(Grauwertmatrix)))) print("Information measure of corelation2: %f" % (np.mean(Features.informationMeasureOfCorelation2(Grauwertmatrix))))