Converting threshold image to binary data [closed]
I have a 19x19 image which have already been thresholded. now i need to read every pixel and determine if its black than output it as 1, if its white than output it as 0. please help ASAP. any help would be much appreciate.
Edited:
I need to output the binary to a text file
why don't you threshold it to [0.1] in the 1st place ?
http://docs.opencv.org/java/org/opencv/imgproc/Imgproc.html#threshold(org.opencv.core.Mat,%20org.opencv.core.Mat,%20double,%20double,%20int)
What do you mean? does it directly threshold it to binary?
if you put 1 for 'maxValue' there, yes.
i did this:
Imgproc.threshold(picture1, picture2, 127, 1, THRESH_BINARY);
but then how do i save the text file?
sorry for the lack of details. i actually need to convert the threshold image as a binary value and save it to a text file
byte[] pixels = new bytes[19*19]; mat.get(0,0,pixels); then use a filestream or such to save the pixels
(why on gods earth do you need a txt file ?)
thank you. i will try that. i need the binary value for my own neural network text recognition input.