将 RGB 光谱绘制为二维颜色矩阵?

发布于 2024-09-27 23:40:31 字数 80 浏览 5 评论 0 原文

关于如何将 RGB 颜色空间绘制为二维矩阵,有什么建议吗?我需要对正在发生的事情进行理论上的描述;代码示例或伪代码会有所帮助,但不是必需的。谢谢!

Any suggestions on how I might go about plotting the RGB color space as a 2-D matrix? I need a theoretical description of what's going on; a code sample or pseudocode would be helpful but is not required. Thanks!

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

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

发布评论

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

评论(4

狼性发作 2024-10-04 23:40:31

如果您想在 2D 网格中表示 RGB 空间中的每种颜色,可能无法避免结果中的不连续性/尖锐边界。但某些映射技术看起来会比其他技术更好。

来自 Possilywrong.wordpress.com 帖子 的示例allRGB:希尔伯特曲线和随机生成树

  • 通过2维(12阶)希尔伯特曲线遍历图像的像素,同时通过3维(12阶)希尔伯特曲线遍历RGB颜色立方体-维(8阶)希尔伯特曲线,依次为每个像素分配相应的颜色 hilbert RGB 3D->2D

  • "宽度优先遍历像素的随机生成树,按希尔伯特曲线顺序分配颜色。" 随机生成树的宽度优先遍历像素,按希尔伯特曲线顺序分配颜色。

另请查看 allrgb.com, "allRGB 的目标很简单:为每种 RGB 颜色创建一个像素的图像 (16777216);没有一种颜色缺失,也没有一种颜色出现两次。”

If you want to represent every color in RGB space in a 2D grid, it may be impossible to avoid discontinuities / sharp borders in the result. But some mapping techniques will look better than others.

Examples from Possiblywrong.wordpress.com post allRGB: Hilbert curves and random spanning trees:

  • Traverse the pixels of the image via a 2-dimensional (order 12) Hilbert curve, while at the same time traversing the RGB color cube via a 3-dimensional (order 8) Hilbert curve, assigning each pixel in turn the corresponding color hilbert RGB 3D->2D

  • "Breadth-first traversal of random spanning tree of pixels, assigning colors in Hilbert curve order." Breadth-first traversal of random spanning tree of pixels, assigning colors in Hilbert curve order.

Also check out allrgb.com, "The objective of allRGB is simple: To create images with one pixel for every RGB color (16777216); not one color missing, and not one color twice."

没企图 2024-10-04 23:40:31

如果您不想丢失任何信息,则需要使用三维。如果您可能会丢失一些维度信息,那就很容易了。只需这样做:

// or HSV
int [256*256][256] colorMatrix;
for (int r = 0; r < 256; r++) {
    for (int r = 0; r < 256; r++) {
        for (int r = 0; r < 256; r++) {
            colorMatrix[256*r+g][b] = color(r, g, b);
        }
    }
}

If you don't want to lose any information, you will need to use three dimension. If you can lose some dimensional information, then it's easy. Just do this:

// or HSV
int [256*256][256] colorMatrix;
for (int r = 0; r < 256; r++) {
    for (int r = 0; r < 256; r++) {
        for (int r = 0; r < 256; r++) {
            colorMatrix[256*r+g][b] = color(r, g, b);
        }
    }
}
蒲公英的约定 2024-10-04 23:40:31

对于 2D 来说并没有一个好的答案,因为你确实需要 3 维。当然,您可以将 3D 空间投影到 2D 上,但要保留有意义的信息量,您几乎需要提供正常的 3D 操作,以便您可以看到从各种不同角度等查看的投影。

There isn't really a good answer for 2D, because you really need 3 dimensions. Of course, you can project a 3D space onto 2D, but to retain a meaningful amount of information you nearly need to provide the normal 3D manipulation, so you can see the projection viewed from various different angles and such.

久光 2024-10-04 23:40:31

以下是我尝试的一些实验,这些实验基于将色调与角度以及亮度和饱和度与距图像中心的距离相匹配。我找不到同时避免不连续性、抖动和波纹的方法(原始图像链接):

在此处输入图像描述

Here are some experiments I tried based on matching hue to angles and lightness and saturation to distances from the centre of the image. I could not find a way to avoid discontinuities, dithering and ripples at the same time (original image link):

enter image description here

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