Hello! I am Ha Soo who is studying Python. <
I implemented the original image as a binary image through opencv and completed saving it. (JPG)
But the problem is that I want to save this image as a binary text file with a value of 0,1 for each pixel.
The code I used is
file = open('1400.jpg', 'rb' )
data = file.read()
print(type(data))
file.close()
file2 = open('test.txt', 'wb')
file2.write(data)
file.close()
The txt file was saved when I created the code and ran it, but when I opened it with a happy heart, I found that
When I saw the Iran execution window, I checked... Instead of 0,1,0,1, there is only an alien word called Seungji-미므흐ㅏ/
If there's something wrong with the code up there or how you use it to convert an image to a text format, I'd appreciate it if you could leave comments.k.
python binary opencv open write
That's not the problem.
You can just open the image file with a hex editor, not a text editor.
One hexadecimal number is four binary numbers, so you can calculate it and look at it as a binary number.
© 2024 OneMinuteCode. All rights reserved.