I have more than 20 images that I want to classify based on pixel correlation. I am able to perform all the procedures but the problem is just saving the image into the corresponding class.
Suppose that the pixel correlation values are[0.48, 0.20, 0.57, 0.53, 0.06, 0.52, 0.55, 0.57, 0.51, 0.49, ..., 0.25]
And I want to use each index of the above values based on some thresholds to classify the images into Normal, Abnormal and Ambiguous classes. With this snippet below, I achieved the following results however, The saved images are in an unsupported format
for filename in os.listdir(folder):
if filename.endswith('.jpg'):
img = cv2.imread(os.path.join(folder, filename))
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
r = []
for correlation in range(len(correlation_matrices)):
symmetry = correlation_matrices[correlation][0,1]
r.append(symmetry)
#print(r)
threshold1 = 0.45
threshold2 = 0.35
for index in range(len(r)):
if (rounded_value[index] >= threshold1):
print('Normal Image')
cv2.imwrite('./uniform_luminance/Normal' + str(index) + '.jpg', img[index])
elif ((rounded_value[index] < threshold1) and rounded_value[index] >= threshold2):
print('Ambiguous Image')
cv2.imwrite('./ambiguous_luminance/Ambiguous' + str(index) + '.jpg', img[index])
elif (rounded_value[index] < threshold2):
print('Abnormal Image')
cv2.imwrite('./non_uniform_luminance/Abnormal' + str(index) + '.jpg', img[index])
I achieved the following
The saved images are not similar to the input images however classified based on the thresholds
While the input images as follows