Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #2024 > unrolled thread

Extract RGB values from image

Started byIngo Thies <ingo.thies@gmx.de>
First post2013-09-09 15:18 +0200
Last post2013-09-16 09:02 +0200
Articles 6 — 2 participants

Back to article view | Back to comp.graphics.apps.gnuplot


Contents

  Extract RGB values from image Ingo Thies <ingo.thies@gmx.de> - 2013-09-09 15:18 +0200
    Re: Extract RGB values from image sfeam <sfeam@users.sourceforge.net> - 2013-09-09 10:18 -0700
      Re: Extract RGB values from image Ingo Thies <ingo.thies@gmx.de> - 2013-09-11 11:39 +0200
        Re: Extract RGB values from image sfeam <sfeam@users.sourceforge.net> - 2013-09-11 11:08 -0700
          Re: Extract RGB values from image Ingo Thies <ingo.thies@gmx.de> - 2013-09-11 21:36 +0200
            Re: Extract RGB values from image Ingo Thies <ingo.thies@gmx.de> - 2013-09-16 09:02 +0200

#2024 — Extract RGB values from image

FromIngo Thies <ingo.thies@gmx.de>
Date2013-09-09 15:18 +0200
SubjectExtract RGB values from image
Message-ID<b9605mF1vhuU1@mid.individual.net>
Hi all,

I am trying to extract RGB values from images via binary input and "set
table":

set table 'testimage.asc'
plot 'someimage.jpg' binary filetype=jpg with rgbimage
unset table

However, gnuplot refuses to write out the RGB values, and instead I only
get something like

# x y type
 0  276  i
 1  276  i
 2  276  i
 3  276  i
 4  276  i
 5  276  i
 6  276  i
 7  276  i
 8  276  i
...

Is there a way to write out the RGB values (maybe as hex strings) for
each pixel?

Best wishes,

Ingo

[toc] | [next] | [standalone]


#2025

Fromsfeam <sfeam@users.sourceforge.net>
Date2013-09-09 10:18 -0700
Message-ID<l0kvu1$51d$1@dont-email.me>
In reply to#2024
Ingo Thies wrote:

> Hi all,
> 
> I am trying to extract RGB values from images via binary input and "set
> table":
> 
> set table 'testimage.asc'
> plot 'someimage.jpg' binary filetype=jpg with rgbimage
> unset table
> 
> However, gnuplot refuses to write out the RGB values, and instead I only
> get something like
> 
> # x y type
>  0  276  i
>  1  276  i
>  2  276  i

Please report the version of gnuplot being used.

The output I get here using current 4.6 is:

# Curve 0 of 1, 46080 points
# Curve title: "'r3d_example2.jpeg' binary filetype=jpeg"
# x y  red green blue alpha type
 0  191    0    0    0  255  i
 1  191    0    0    0  255  i
 2  191    0    0    0  255  i


Version 4.4 produces instead the warning:
"Tabular output of rgbimage plot style not fully implemented"

So I'm guessing the version you have is older yet?


	Ethan



>  3  276  i
>  4  276  i
>  5  276  i
>  6  276  i
>  7  276  i
>  8  276  i
> ...
> 
> Is there a way to write out the RGB values (maybe as hex strings) for
> each pixel?
> 
> Best wishes,
> 
> Ingo

[toc] | [prev] | [next] | [standalone]


#2027

FromIngo Thies <ingo.thies@gmx.de>
Date2013-09-11 11:39 +0200
Message-ID<b9as34F2blbU1@mid.individual.net>
In reply to#2025
On 09.09.2013 19:18, sfeam wrote:

> Please report the version of gnuplot being used.

Version 4.4.3 and 4.6.0

4.4.3 just returns the "i"s, 4.6.0 returns a warning

Warning: empty z range [0:0], adjusting to [-1:1]

and a table like this:

# Surface 0 of 1 surfaces

# Curve title: "ffile binary filetype=png"
# IsoCurve 0, 3871488 points
# x y z type
 0  1703  0 i
 1  1703  0 i
 2  1703  0 i
 3  1703  0 i
...

The third column (not present in 4.4) only contains zeroes. So maybe

splot ffile binary filetype=png with rgbimage

is not the correct plotting command. So which command did you use?


Best wishes,

Ingo

[toc] | [prev] | [next] | [standalone]


#2028

Fromsfeam <sfeam@users.sourceforge.net>
Date2013-09-11 11:08 -0700
Message-ID<l0qbid$44p$1@dont-email.me>
In reply to#2027
Ingo Thies wrote:

> On 09.09.2013 19:18, sfeam wrote:
> 
>> Please report the version of gnuplot being used.
> 
> Version 4.4.3 and 4.6.0
> 
> 4.4.3 just returns the "i"s, 4.6.0 returns a warning

OK.  I see the same as you do with 4.6.0.
However starting with version 4.6.1 I see the desired output

[10] gnuplot_4.6.0 rgbdump.bug | head -8

# Curve 0 of 1, 46080 points
# Curve title: "'r3d_example2.jpeg'  binary filetype=jpg"
# x y type
 0  191  i
 1  191  i
 2  191  i
 3  191  i


[11] gnuplot_4.6.1 rgbdump.bug | head -8

# Curve 0 of 1, 46080 points
# Curve title: "'r3d_example2.jpeg'  binary filetype=jpg"
# x y  red green blue alpha type
 0  191    0    0    0  255  i
 1  191    0    0    0  255  i
 2  191    0    0    0  255  i
 3  191    0    0    0  255  i

A possible work-around for older versions is to use the plot style
"with xyerrorbars":

[12] gnuplot_4.4.3
gnuplot> set table
gnuplot> set out 'foo.443'
gnuplot> plot 'r3d_example2.jpeg' binary filetype=jpg using 1:2:3:4 with xyerrorbars
gnuplot> !head foo.443 

# Curve 0 of 1, 46271 points
# Curve title: "'r3d_example2.jpeg' binary filetype=jpg using 1:2:3:4"
# x y xlow xhigh ylow yhigh type
 0  191  0  0  0  255  i
 1  191  0  0  0  255  i
 2  191  0  0  0  255  i
 3  191  0  0  0  255  i
 4  191  0  0  0  255  i


Notes:
I don't know why it counts 46271 points instead of 46080 points
The mapping of the extra columns onto R/G/B may vary with different
gnuplot versions.  In the case of version 4.4.3, the original picture
can be reconstructed from the tabular dump using

gnuplot_4.4.3
gnuplot> plot 'foo.443' using 1:2:($3*256*256 + $4*256 + $5) with points lc rgb variable

	Ethan

[toc] | [prev] | [next] | [standalone]


#2029

FromIngo Thies <ingo.thies@gmx.de>
Date2013-09-11 21:36 +0200
Message-ID<b9bv2fF9mrjU1@mid.individual.net>
In reply to#2028
Am 11.09.13 20:08, schrieb sfeam:
> Ingo Thies wrote:
> 
>> On 09.09.2013 19:18, sfeam wrote:
>>
>>> Please report the version of gnuplot being used.
>>
>> Version 4.4.3 and 4.6.0
>>
>> 4.4.3 just returns the "i"s, 4.6.0 returns a warning
> 
> OK.  I see the same as you do with 4.6.0.
> However starting with version 4.6.1 I see the desired output

I tried the same with gnuplot 4.6.3 on my Mac and got the following
error message:

Tabular output of this 3D plot style not implemented

I guess that some library is missing or any other problem that can only
be solved with developer's knowledge. Obviously, RGB extraction with
gnuplot is far from being trivial and stable, but seems to depend on
third-party libraries which are present in some system and missing in
others.

So I tend to give up since I have found another (however less
convenient) way by using GIMP. It can write images in .pnm or similar
files which also contain the RGB triples.

However, if you have a simple solution to this problem, please let me
know. Again, is something wrong with the following plotting command?

splot 'someimage.png' binary filetype=png with rgbimage

> [10] gnuplot_4.6.0 rgbdump.bug | head -8

In which environment are you performing this command? Where can I find
the file rgbdump.bug?

Ingo

[toc] | [prev] | [next] | [standalone]


#2036

FromIngo Thies <ingo.thies@gmx.de>
Date2013-09-16 09:02 +0200
Message-ID<b9noonFmjf5U1@mid.individual.net>
In reply to#2029
On 11.09.2013 21:36, Ingo Thies wrote:

> splot 'someimage.png' binary filetype=png with rgbimage

It seems to work with "plot" instead of "splot". However, I got to a
comparably useful result with convert (imagemagick) & Co. But thanks so far.

Ingo

[toc] | [prev] | [standalone]


Back to top | Article view | comp.graphics.apps.gnuplot


csiph-web