Compare commits
No commits in common. "1e844218ea4c580275ae8153b4b95c235d40904d" and "39202630d8605d86d1db73861c41ce510fa89aba" have entirely different histories.
1e844218ea
...
39202630d8
@ -1,61 +0,0 @@
|
|||||||
import numpy as np
|
|
||||||
import cv2
|
|
||||||
import os
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
|
|
||||||
DATASET_PATH = "C:\\Users\\tomse\\Documents\\Dataset\\"
|
|
||||||
DATASET_FOLDERS_LEN = len(os.listdir(DATASET_PATH))
|
|
||||||
EARLY_BREAK = 3
|
|
||||||
|
|
||||||
sift = cv2.SIFT.create(enable_precise_upscale=True)
|
|
||||||
|
|
||||||
## Create 2D lists ##
|
|
||||||
max_magnitudes = [[] for x in range(DATASET_FOLDERS_LEN)]
|
|
||||||
avg_magnitudes = [[] for x in range(DATASET_FOLDERS_LEN)]
|
|
||||||
counts = [[] for x in range(DATASET_FOLDERS_LEN)]
|
|
||||||
|
|
||||||
## Create other variables ##
|
|
||||||
labels = ['' for x in range(DATASET_FOLDERS_LEN)]
|
|
||||||
i = 0
|
|
||||||
|
|
||||||
for folder in os.listdir(DATASET_PATH):
|
|
||||||
if EARLY_BREAK:
|
|
||||||
print("Step %d/%d processing %s:"%(i+1, EARLY_BREAK, folder))
|
|
||||||
else:
|
|
||||||
print("Step %d/%d processing %s:"%(i+1, DATASET_FOLDERS_LEN, folder))
|
|
||||||
|
|
||||||
for file in os.listdir(DATASET_PATH + folder):
|
|
||||||
## Load an image ##
|
|
||||||
path = DATASET_PATH + folder + "\\" + file
|
|
||||||
full_image = cv2.imread(path, 0)
|
|
||||||
image = cv2.resize(full_image, (0, 0), fx=0.25, fy=0.25)
|
|
||||||
|
|
||||||
## Detect keypoints ##
|
|
||||||
kp = sift.detect(image, None)
|
|
||||||
|
|
||||||
## Average and Max size ##
|
|
||||||
magnitudes = [keypoint.size for keypoint in kp]
|
|
||||||
max_magnitudes[i].append(np.amax(magnitudes))
|
|
||||||
avg_magnitudes[i].append(np.sum(magnitudes)/len(kp))
|
|
||||||
|
|
||||||
## Number of keypoints ##
|
|
||||||
counts[i].append(len(kp))
|
|
||||||
|
|
||||||
## Store labels ##
|
|
||||||
labels[i] = folder
|
|
||||||
|
|
||||||
## Increment folder ##
|
|
||||||
i += 1
|
|
||||||
|
|
||||||
if(i == EARLY_BREAK):
|
|
||||||
break
|
|
||||||
|
|
||||||
print("Done!")
|
|
||||||
|
|
||||||
## Plots ##
|
|
||||||
fig, ax = plt.subplots()
|
|
||||||
for i in range(DATASET_FOLDERS_LEN):
|
|
||||||
ax.scatter(avg_magnitudes[i], max_magnitudes[i],label=labels[i], alpha=0.7)
|
|
||||||
ax.legend()
|
|
||||||
ax.grid(True)
|
|
||||||
plt.show()
|
|
Loading…
Reference in New Issue
Block a user