I am trying to convert an RGB image to YUV space and then I am trying to add color thresholds to create a binary image.
I am doing this as below:
img = cv2.cvtColor(img, cv2.COLOR_BGR2YUV)
b_channel = cv2.cvtColor(img, cv2.COLOR_RGB2Lab)[:, :, 2]
l_channel = cv2.cvtColor(img, cv2.COLOR_RGB2LUV)[:, :, 0]
s_channel = cv2.cvtColor(img, cv2.COLOR_BGR2HLS)[:, :, 2]
s_binary = np.zeros_like(s_channel)
s_binary[(s_channel > s_thresh_min) & (s_channel <= s_thresh_max)] = 1
b_binary = np.zeros_like(b_channel)
b_binary[(b_channel > b_thresh_min) & (b_channel <= b_thresh_max)] = 1
l_binary = np.zeros_like(l_channel)
l_binary[(l_channel > l_thresh_min) & (l_channel <= l_thresh_max)] = 1
combined_binary = np.zeros_like(b_binary)
combined_binary[(l_binary == 1) | (b_binary == 1) | (s_binary == 1)] = 1
f, ax1 = plt.subplots(1, 1, figsize=(10, 5))
ax1.imshow(combined_binary)
This all works well and I can see the binary image on the screen.
However, when I try to save it on the disk using cv2.imwrite, I get a black image.
cv2.imwrite(file_name, combined_binary)
I am really confused why this change between the imshow and imwrite.
Any hints?
Thanks


combined_binary? what isfilenameextension? iscombined_binaryof type np.uint8`?