detect grayscale image in python opencv

Solutions on MaxInterview for detect grayscale image in python opencv by the best coders in the world

showing results for - "detect grayscale image in python opencv"
Giovanni
24 Aug 2019
1from scipy.misc import imread, imsave, imresize
2image = imread(f_name)
3if(len(image.shape)<3):
4      print 'gray'
5elif len(image.shape)==3:
6      print 'Color(RGB)'
7else:
8      print 'others'
9
Kamala
06 Feb 2020
1import cv2
2file = "myFile.jpj"
3
4
5image = cv2.imread(file)
6if image.any() != None:
7  if(len(image.shape)<2):
8        print ('grayscale')
9  elif len(image.shape)==3:
10        print ('Colored')
11else:
12  print("cannot find image")  
13