GNUPLOT 中的调色板映射表面视图或热图帮助

发布于 2025-01-15 15:08:25 字数 502 浏览 1 评论 0原文

我有一个从图像派生的平均 RGB 值的数据集。该图像的尺寸为 1729 x 981,我使用 imagemagick 对每个 170x98 像素部分进行平均,并输出包含数据的 CSV。这给了我 153 条线,代表横向 17 个部分,向下 9 个部分。

我想要实现但失败的是,基本上创建一个热图,或者图像的托盘映射表面视图,并使用 GNUPLOT 在 17 x 9 部分显示平均数据。

我的假设是我的数据格式不正确。但我对gnupolot也知之甚少。所以就是这样。

这是我正在使用的数据集。
https://www.dropbox.com/s/1mfhgkrdbo5xdrj/RNST_SDI_20220303_145749.DPX_DATA.csv?dl=0

非常感谢任何帮助。

I have a data set of average RGB values derived from an image. The image is 1729 x 981 and I've used imagemagick to average each 170x98 pixel section and output a CSV with the data. this gives me 153 lines representing the 17 sections across and 9 down.

What I'm trying to achieve, and failing at, is creating basically a heat map, or pallet mapped surface view of the image with the average data shown across the 17 x 9 sections using GNUPLOT.

My assumption is that my data is formatted incorrectly. But I also know very little about gnupolot. So there's that.

Here is the data set I'm using.
https://www.dropbox.com/s/1mfhgkrdbo5xdrj/RNST_SDI_20220303_145749.DPX_DATA.csv?dl=0

Any help is greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

过度放纵 2025-01-22 15:08:25

我将把我的评论改写为初步答案。

您想要的命令的形式是 plot DATA using x:y:R:G:B with rgbimage 但从您的描述中并不完全清楚如何导出 R/G/B 分量。您链接的文件的第 2/3/4 列中的值范围大致包含 450 - 550 范围内的值。通常颜色分量的范围为 0.0 - 1.0 或 0 - 255。出于说明目的,我将将您的值转换为 0.0-1.0 范围内的数字并显示绘图命令。

我们将从行号导出 x 和 y 分量,忽略第 1 列的内容,并将第 2/3/4 列缩放到 0-1 范围。您没有说明您希望如何用像素坐标、标题等标记结果,因此我将所有内容保留为默认值。

 set datafile separator comma       # it's a csv file
 set rgbmax 1.0                     # color components in the range 0-1
 conv(C) = (column(C)-450.)/100. 
 plot 'DPX_DATA.csv' using (int($0)%17) : (int($0)/17) : (conv(2)) : (conv(3)) : (conv(4)) with rgbimage

输入图片这里的描述

扩展答案

有几种方法可以从命令行将附加参数传递到 gnuplot 中。不幸的是,我不熟悉 bash 脚本,所以我无法帮助构建您在评论中显示的命令行。我能做的是展示如何从 gnuplot 内部读取环境变量 NAME:

name = system("printenv NAME")
infile = name . ".csv"
outfile = name . "_RGB_AVGs.png"
set term png
set output outfile
plot infile using ... with rgbimage


  

I will rephrase my comment as a preliminary answer.

The form of the command you want is plot DATA using x:y:R:G:B with rgbimage but it is not entirely clear from your description how to derive the R/G/B components. The range of values in columns 2/3/4 of the file you linked to contain values roughly in the range 450 - 550. Usually the color components either run from 0.0 - 1.0 or from 0 - 255. For the purpose of illustration I will convert yours into numbers in the range 0.0-1.0 and show the plot command.

We will derive the x and y components from the line number, ignore the content of column 1, and scale columns 2/3/4 to the range 0-1. You don't say how you want the result marked up with pixel coordinates, titles, or the like so I just leave everything to default.

 set datafile separator comma       # it's a csv file
 set rgbmax 1.0                     # color components in the range 0-1
 conv(C) = (column(C)-450.)/100. 
 plot 'DPX_DATA.csv' using (int($0)%17) : (int($0)/17) : (conv(2)) : (conv(3)) : (conv(4)) with rgbimage

enter image description here

Expanded answer

There are several ways to pass additional parameters into gnuplot from the command line. Unfortunately I am not conversant with bash scripting so I can't help with construction of the command line as you show it in your comment. What I can do is show how to read an environmental variable NAME from inside gnuplot:

name = system("printenv NAME")
infile = name . ".csv"
outfile = name . "_RGB_AVGs.png"
set term png
set output outfile
plot infile using ... with rgbimage


  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文