just a quick question: I am loading a black and white image and then replacing the black and/or white pixels with other colors. The problem is when I visualize the edited image there are some black pixels, like noise, around the white segments.
Input image:
Here is how I iterate through the pixels:
img1_black[np.where((img1_black == [0, 0, 0]).all(axis=2))] = [0, 255, 0]
cv2.imshow("Result4", img1_black)
second method of iterating:
img1_black_pixels_mask = np.all(mask_1 == [0, 0, 0], axis=-1)
img1_non_black_pixels_mask = np.any(mask_1 != [0, 0, 0], axis=-1)
img1_black[img1_black_pixels_mask] = [0, 0, 255]
img1_black[img1_non_black_pixels_mask] = [0, 255, 0]
plt.imshow(img1_black)
plt.show()
First Output image
Second Output image