import cv2
im_gray = cv2.imread('grayscale_image.png', cv2.IMREAD_GRAYSCALE)
from scipy.misc import imread, imsave, imresize
image = imread(f_name)
if(len(image.shape)<3):
print 'gray'
elif len(image.shape)==3:
print 'Color(RGB)'
else:
print 'others'
import Image
def is_grey_scale(img_path):
img = Image.open(img_path).convert('RGB')
w, h = img.size
for i in range(w):
for j in range(h):
r, g, b = img.getpixel((i,j))
if r != g != b:
return False
return True
import cv2
file = "myFile.jpj"
image = cv2.imread(file)
if image.any() != None:
if(len(image.shape)<2):
print ('grayscale')
elif len(image.shape)==3:
print ('Colored')
else:
print("cannot find image")
im_gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)