#Attempting grayscaling with cv2 becomes redscaling?

3 messages · Page 1 of 1 (latest)

covert steppe
#

Hello, I'm working on pre-processing my images and wanted to apply gray scaling. This is my code:

test_path = "C:\cvpr_emotic\mscoco\preprocessingtest\*.jpg"

images = [cv2.imread(image) for image in glob.glob(test_path)]

fig=plt.figure(figsize=(8, 4))

rows, cols = 2, 3

for j in range(0, cols*rows):
  fig.add_subplot(rows, cols, j+1)
  images[j] = cv2.cvtColor(images[j], cv2.COLOR_BGR2GRAY)
  plt.imshow(images[j])
  plt.axis('off')
plt.show()

Which result into the picture below. Anyone knows how to fix it? Converting the color to RGB, HSV, YUV etc works perfectly fine, it's just gray that doesn't work properly. Everything I've done to the images is in the code.

obsidian drum
#

You can add cmap='gray' to the imshow the default is higher contrast color maps. It’s weird my default is usually purple/yellow

covert steppe