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.
564 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
592 GDB gets version error when attempting to debug with the Presense SDK (IDE)
593 Uncaught (inpromise) Error on Electron: An object could not be cloned
567 Understanding How to Configure Google API Key
865 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.