I want to save binary.jpg image as txt on Python!!! Masters, please cut me some slack!

Asked 2 years ago, Updated 2 years ago, 76 views

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

2022-09-22 18:23

1 Answers

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.


2022-09-22 18:23

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.