Open ErenKarabey opened 12 months ago
Images are pulled by cv2.imread()
and are always in the format BGR with shape (y_dim, x_dim, 3)
. If an image is gray image, than all of the values for three colors channels will be same for all pixels. This is not the case when any non-gray color is in the picture. Therefore, this code differentiates between color and gray images.
def colorOrgray(image) -> bool:
'''
Given a BGR image (3 channels) split into 3
channels and check whether they are the same.
If they are the equivalent, it is a image consisting
of only gray tones (1). Else, it is a proper color
image (0).
'''
b,g,r = cv2.split(image)
return np.all(b == g) and np.all(g == r)
Color images have mostly the same format in terms of the figure text and most of them needs to be segmented for the final data set.
However, it might create standardization issues for the final dataset as, most images are gray-scale.