Inverting black and white on a bitmap is not working
You can use a bitwise-not to invert the image. In general, you want to avoid iterating through each pixel as it is very slow.
Original
Result
Here are two methods to invert an image. Using the built in cv2.bitwise_not()
function or just subtracting 255. It's implemented in Python but the same idea can be used in Java.
import cv2
image = cv2.imread('1.png')
result = 255 - image
alternative_result = cv2.bitwise_not(image)
cv2.imshow('image', image)
cv2.imshow('result', result)
cv2.imshow('alternative_result', alternative_result)
cv2.waitKey(0)