I had use otsu's method for mask the cloud. In this case, the mask is red. When I run the code, the graphs display the red mask but when i try saving it to folder , the mask turn to blue. Can anyone help what I've done wrong?

 def show_mask(mask, img_array, title='', mask_color=(255, 0, 0)):

            display_image = img_array.copy()
            display_image[mask != 0] = mask_color

            path1="D:Datasets/satellite2/croppedred"

            plt.imshow(display_image)
            cv2.imwrite(os.path.join(path1,img),display_image)
            #display_image.save(os.path.join(path1,img))
            plt.title(title)
            plt.axis('off')
            plt.show()  
show_mask(mask_otsu_clean, img_array, title='Otsu grayscale thresholding with morphological cleanup')

1 Answers

1
EdChum On Best Solutions

OpenCV treats the colour channel order of images by default to be BGR and not RGB this is why you see a blue colour mask.

So you need to change your mask to this

mask_color = (0, 0, 255)

then it will apply the correct colour values to the correct colour channel