Page 1 of 1

text table color values to image

Posted: 2017-05-10T10:12:32-07:00
by supermax
Hi, this is my first post.
Debian 8, imagemagick gui do not work.
I need to compute ndvi from a jpg photo.
https://it.wikipedia.org/wiki/Normalize ... tion_Index
I converted jpg in txt by terminal commands:
convert filtrorosso.jpg filtrorosso.txt
sed -e 's/ //g' -e 's/(//g' -e 's/)//g' -e 's/:/,/g' -e 's/#/,/g' filtrorosso.txt>filtrorosso2.txt
then used filtrorosso2.txt by R-cran to evaluate colors etc.
The image obtained is still a 1280,1024,255,srgb but now I need to convert a table color values to an image
I show you the first ten lines of the table to convert
0,0,255,82,12
1,0,255,85,15
2,0,255,87,17
3,0,255,88,18
4,0,255,85,15
5,0,255,83,13
6,0,255,81,13
7,0,255,81,15
8,0,255,80,17
9,0,255,77,15
10,0,255,73,11

The first two colons are the coordinate the last three are the color values
I meen to create a txt file and then use convert to make a jpg or similar.
Can you help me?

Thanke you in advance.

Re: text table color values to image

Posted: 2017-05-10T10:44:10-07:00
by fmw42
Send the list of color triplet values (only) to NetPBM PPM format. See http://netpbm.sourceforge.net/doc/ppm.html. From there you can convert the PPM format to any other such as JPG. For example

Code: Select all

echo "P3 $columns $rows $maxvalue $color_triplet_list" | convert - result.jpg

Re: text table color values to image

Posted: 2017-05-12T04:43:43-07:00
by supermax
I can' find how to convert my table in a format useful for netpbm

Re: text table color values to image

Posted: 2017-05-12T09:41:04-07:00
by fmw42
You have to tell it how many rows and how many columns you want that correspond to the number of color triplet values you have. Remove the coordinates and just provide the r,g,b values as triplets. Looks like you have a 1D colorable. So you can make it into a 1D image (either 1 row or 1 column) of length equal to the number of triplets. Or if the number is conducive, you can make it M rows by N columns if the total number is NxM.