Selected conversion from PNG to TXT
-
- Posts: 6
- Joined: 2016-07-27T02:39:49-07:00
- Authentication code: 1151
Selected conversion from PNG to TXT
Hi
i need to convert from PNG to TXT
but i don't need to convert all the image
i need to know only the information releated to the white pixel
i already perform something with a double DO LOOP using another library but it takes some minute (about 5) because the image it's quite big
is there some other way using Imagemagick ?
maybe compiling some batch file...
thank to everyone
i need to convert from PNG to TXT
but i don't need to convert all the image
i need to know only the information releated to the white pixel
i already perform something with a double DO LOOP using another library but it takes some minute (about 5) because the image it's quite big
is there some other way using Imagemagick ?
maybe compiling some batch file...
thank to everyone
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Selected conversion from PNG to TXT
How do you convert "from PNG to TXT"? That sounds like OCR (optical character recognition), which IM doesn't do. A program called tesseract can do that.
IM can be useful for preparing an image for OCR.
Without seeing your image, further advice is difficult.
IM can be useful for preparing an image for OCR.
Without seeing your image, further advice is difficult.
snibgo's IM pages: im.snibgo.com
-
- Posts: 6
- Joined: 2016-07-27T02:39:49-07:00
- Authentication code: 1151
Re: Selected conversion from PNG to TXT
more easy
if you run -convert c:\image.png c:\image_out.txt
in the text file you will find for each pixel the releated color
but i don0t need all the pixel, just the white pixel
is not an ocr application
i just need to know where are located the white pixels in the image
thanks
if you run -convert c:\image.png c:\image_out.txt
in the text file you will find for each pixel the releated color
but i don0t need all the pixel, just the white pixel
is not an ocr application
i just need to know where are located the white pixels in the image
thanks
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Selected conversion from PNG to TXT
Okay, you want the locations of all the white pixels.
Code: Select all
convert in.png +transparent White sparse-color:
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Selected conversion from PNG to TXT
Snibgo: Should I suggest that sparse-color: be changed to output as list rather than a string?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Selected conversion from PNG to TXT
Well, it's a pain having to split it into lines.
coders\txt.c function WriteTXTImage() once had code to test for an attribute that was supposed to insert '\n' characters. But that code has since been removed.
I think it's dangerous to change IM so it always breaks into lines. But adding an option to tell it to do so would be useful.
coders\txt.c function WriteTXTImage() once had code to test for an attribute that was supposed to insert '\n' characters. But that code has since been removed.
I think it's dangerous to change IM so it always breaks into lines. But adding an option to tell it to do so would be useful.
snibgo's IM pages: im.snibgo.com
Re: Selected conversion from PNG to TXT
To get a list of the white pixels:
Code: Select all
magick image.png txt:- | grep white
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Selected conversion from PNG to TXT
Yes, provided the input is fully opaque. If it has transparency, "white" is written as "srgba(255,255,255,1)".glenrp wrote:magick image.png txt:- | grep white
snibgo's IM pages: im.snibgo.com
-
- Posts: 6
- Joined: 2016-07-27T02:39:49-07:00
- Authentication code: 1151
Re: Selected conversion from PNG to TXT
thanks for the reply
just some question
is this code write the output to some files?
i don't think that "grep" is for Windows, i read somewhere to use find, is necessary to declare the output file?
thanks again
just some question
Code: Select all
convert in.png +transparent White sparse-color:
Code: Select all
image.png txt:- | grep white
thanks again
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Selected conversion from PNG to TXT
Use redirect:
or
Search google for "grep for windows"
http://gnuwin32.sourceforge.net/packages/grep.htm
http://www.wingrep.com/
http://www.wingrep.com/download.htm
Lots of results.
Code: Select all
convert in.png +transparent White sparse-color: > textfile.txt
Code: Select all
convert image.png txt:- | grep "white" > textfile.txt
Search google for "grep for windows"
http://gnuwin32.sourceforge.net/packages/grep.htm
http://www.wingrep.com/
http://www.wingrep.com/download.htm
Lots of results.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Selected conversion from PNG to TXT
Or:
The Microsoft program is called "findstr". So:
or
This is far slower than the previous method.
Code: Select all
convert in.png +transparent White sparse-color:textfile.txt
The Microsoft program is called "findstr". So:
Code: Select all
convert in.png txt:- | findstr white
Code: Select all
convert in.png txt:- | findstr white >textfile.txt
snibgo's IM pages: im.snibgo.com
-
- Posts: 6
- Joined: 2016-07-27T02:39:49-07:00
- Authentication code: 1151
Re: Selected conversion from PNG to TXT
Thanks again
just last question
is it possibile to revert the output to the text file but just one information to each line?
thanks again
just last question
is it possibile to revert the output to the text file but just one information to each line?
thanks again
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Selected conversion from PNG to TXT
In unix, you can do
Code: Select all
convert in.png +transparent White sparse-color: | tr " " "\n"