How can i use convert or other command to extract data from my image into a required form. I will use the same data in filters and get result in exactly same manner. I will also have to convert it back to image. Are there any commands to generate pixel data (1 pixel) each line for gray scale 8bit image. For example:
0,0 56
0,1 33
0,2 98
0,3 59
.
.
.
.
1279,959 72
What I'm getting with regular command "convert image.jpg image.txt" is really bugging me. The result is something like below:
# ImageMagick pixel enumeration: 1280,960,65535,srgb
0,0: (514,514,514) #020202 srgb(2,2,2)
1,0: (6939,6939,6939) #1B1B1B srgb(27,27,27)
2,0: (10280,10280,10280) #282828 srgb(40,40,40)
3,0: (8738,8738,8738) #222222 srgb(34,34,34)
4,0: (10023,10023,10023) #272727 srgb(39,39,39)
5,0: (16962,16962,16962) #424242 grey26
6,0: (23901,23901,23901) #5D5D5D srgb(93,93,93)
7,0: (26728,26728,26728) #686868 srgb(104,104,104)
8,0: (16705,16705,16705) #414141 srgb(65,65,65)
9,0: (18761,18761,18761) #494949 srgb(73,73,73)
Extract image in data form for image processing
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Extract image in data form for image processing
When your external software reads "txt:" format, you can ignore the "#" onwards. When you write it, you needn't write the "#" onwards.
An alternative is to write the IM image as "-compress None pnm:", which is one text number per pixel, so the files are smaller.
Another alternative is to write your own process module in C. Then you can write whatever format you want.
An alternative is to write the IM image as "-compress None pnm:", which is one text number per pixel, so the files are smaller.
Another alternative is to write your own process module in C. Then you can write whatever format you want.
snibgo's IM pages: im.snibgo.com
Re: Extract image in data form for image processing
Thank you so much for your reply. I was able to successfully extract data through this arguments "-compress None pnm:", this worked smoothly but now i dont know how to convert it back to image from same format?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Extract image in data form for image processing
IM can read the PNM file. For example, from an image file toes.png, I create a text file...
... then I edit the text file as I want (eg to change pixel values), then convert it back to a PNG:
Code: Select all
magick toes.png -compress None xyz.pnm
Code: Select all
magick xyz.pnm abc.png
snibgo's IM pages: im.snibgo.com
Re: Extract image in data form for image processing
Thank you so much. I'm able to generate it now. Although I want to know how does it generates, top-to-bottom or bottom-to-top?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Extract image in data form for image processing
What about left to right and right to left. You can get all combinations using -rotate 180, -flip, -flop, -transpose, -transverse.
For example bottom-right to top-left would be -rotate 180
For example bottom-right to top-left would be -rotate 180
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Extract image in data form for image processing
Within the PNM file, the first row of number is the first rows of pixels. The last number in the file is the bottom-right pixel in the image.haider87 wrote:Although I want to know how does it generates, top-to-bottom or bottom-to-top?
Does that answer the question?
snibgo's IM pages: im.snibgo.com
Re: Extract image in data form for image processing
Thank you so much. Its a great application