text table color values to image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
supermax
Posts: 6
Joined: 2017-05-10T09:42:36-07:00
Authentication code: 1151

text table color values to image

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: text table color values to image

Post 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
supermax
Posts: 6
Joined: 2017-05-10T09:42:36-07:00
Authentication code: 1151

Re: text table color values to image

Post by supermax »

I can' find how to convert my table in a format useful for netpbm
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: text table color values to image

Post 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.
Post Reply