Siyun He commited on
Commit
f7d9130
·
1 Parent(s): 47fc75d

update results

Browse files
Files changed (3) hide show
  1. .DS_Store +0 -0
  2. classification.py +2 -3
  3. results.csv +1 -1
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
classification.py CHANGED
@@ -34,7 +34,7 @@ def compute_glcm(image_path, ispath=True):
34
  img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
35
  else:
36
  img = image_path
37
- # compute the GLCM properties. Distance = 2, and 4 angles: 0, 45, 90, 135
38
  glcm = graycomatrix(img, [3], [0, np.pi/4, np.pi/2, 3*np.pi/4], 256, symmetric=True, normed=True)
39
  # extract the properties
40
  contrast = graycoprops(glcm, 'contrast')
@@ -42,7 +42,6 @@ def compute_glcm(image_path, ispath=True):
42
  energy = graycoprops(glcm, 'energy')
43
  homogeneity = graycoprops(glcm, 'homogeneity')
44
  # return the feature vector
45
- # return [contrast[0][0], correlation[0][0], energy[0][0], homogeneity[0][0]]
46
  # Flatten the arrays first
47
  contrast_flat = contrast.flatten()
48
  correlation_flat = correlation.flatten()
@@ -239,7 +238,7 @@ if __name__ == '__main__':
239
  # Evaluate each classifier on the tesing set.
240
  # Compare the results.
241
  # Save the results to a CSV file.
242
- results = pd.DataFrame({'GLCM': [accuracy_score(y_test_glcm, y_pred_glcm)], 'LBP': [accuracy_score(y_test_lbp, y_pred_lbp)]})
243
  # Add the precision to the results
244
  results['GLCM_precision'] = precision_score(y_test_glcm, y_pred_glcm, average='weighted')
245
  results['LBP_precision'] = precision_score(y_test_lbp, y_pred_lbp, average='weighted')
 
34
  img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
35
  else:
36
  img = image_path
37
+ # compute the GLCM properties. Distance = 3, and 4 angles: 0, 45, 90, 135
38
  glcm = graycomatrix(img, [3], [0, np.pi/4, np.pi/2, 3*np.pi/4], 256, symmetric=True, normed=True)
39
  # extract the properties
40
  contrast = graycoprops(glcm, 'contrast')
 
42
  energy = graycoprops(glcm, 'energy')
43
  homogeneity = graycoprops(glcm, 'homogeneity')
44
  # return the feature vector
 
45
  # Flatten the arrays first
46
  contrast_flat = contrast.flatten()
47
  correlation_flat = correlation.flatten()
 
238
  # Evaluate each classifier on the tesing set.
239
  # Compare the results.
240
  # Save the results to a CSV file.
241
+ results = pd.DataFrame({'GLCM_accuracy': [accuracy_score(y_test_glcm, y_pred_glcm)], 'LBP_accuracy': [accuracy_score(y_test_lbp, y_pred_lbp)]})
242
  # Add the precision to the results
243
  results['GLCM_precision'] = precision_score(y_test_glcm, y_pred_glcm, average='weighted')
244
  results['LBP_precision'] = precision_score(y_test_lbp, y_pred_lbp, average='weighted')
results.csv CHANGED
@@ -1,2 +1,2 @@
1
- GLCM,LBP,GLCM_precision,LBP_precision
2
  0.9333333333333333,0.9333333333333333,0.9411764705882353,0.9411764705882353
 
1
+ GLCM_accuracy,LBP_accuracy,GLCM_precision,LBP_precision
2
  0.9333333333333333,0.9333333333333333,0.9411764705882353,0.9411764705882353