重现包含该色彩调色板的图像(IVIS机器)。

huangapple go评论65阅读模式
英文:

Reproduce color palette from an image containing that color palette (IVIS machine)

问题

I would like to know if that is possible to reproduce a color palette from an image.

Here is an example. Pages 1 and 3 show a rainbow palette in the figure legend.

The software is proprietary and has very little room for customization. I would like to regenerate the legend by R (or any other programming language, e.g. python) but retain the scale/ range of the colors.

I recognize that some color picker tools are available. However, the resolution of the palette is quite low, and often 3-4 colors are displayed in the same row. I am not sure which color I should pick in the raster image.

英文:

I would like to know if that is possible to reproduce a color palette from an image.

Here is an example. Pages 1 and 3 show a rainbow palette in the figure legend.

The software is proprietary and has very little room for customization. I would like to regenerate the legend by R (or any other programming language, e.g. python) but retain the scale/ range of the colors.

I recognize that some color picker tools are available. However, the resolution of the palette is quite low, and often 3-4 colors are displayed in the same row. I am not sure which color I should pick in the raster image.

答案1

得分: 1

Base R有一个rainbow调色板,类似于链接的PDF中所示。

一个更好的选择可能是viridispackage中的turbo颜色映射,它在可见光谱中更渐变过渡。

这个PDF是关于R中颜色的一个很好的通用参考,可能会帮助您构建您想要复制的渐变。

ggplot2中,您可以使用scale_gradient (link) 来创建这些调色板。

library(ggplot2)
library(scales)

ggplot(mtcars, aes(factor(cyl), disp, fill = mpg)) +
  geom_col() +
  scale_fill_gradientn(colors = c(muted('red'), 'red', 'yellow1'))

重现包含该色彩调色板的图像(IVIS机器)。<!-- -->

<sup>于2023-04-19创建,使用 reprex v2.0.2</sup>

英文:

Base R has a rainbow palette, which is similar to what is shown in the linked PDF

A better option might be the turbo color map in the viridis package, which transitions more gradually across the visible spectrum.

This PDF is a great general reference to colors in R, and may help you construct the gradient you're aiming to replicate.

In ggplot2, you can create these sorts of palettes using scale_gradient (link).

library(ggplot2)
library(scales)

  ggplot(mtcars, aes(factor(cyl), disp, fill = mpg)) +
  geom_col() +
  scale_fill_gradientn(colors = c(muted(&#39;red&#39;), &#39;red&#39;, &#39;yellow1&#39;))

重现包含该色彩调色板的图像(IVIS机器)。<!-- -->

<sup>Created on 2023-04-19 with reprex v2.0.2</sup>

答案2

得分: 0

你可以使用OpenCV(cv2)库并将颜色数据导出为直方图。还可以在图像的特定区域应用掩码,以提取该部分的颜色数据。

示例/文档可在这里找到:Histograms - 1 : Find, Plot, Analyze,还有一个可能更适合您的示例,展示如何创建2D直方图:Histograms - 3 : 2D Histograms

希望对您有帮助!

英文:

You can use OpenCV (cv2) library and export the color data as a histogram. It's also possible to apply a mask to a certain area of the image to extract the color data from that part.

For examples/documentation you can find more here: Histograms - 1 : Find, Plot, Analyze and this one might suite you a bit more where it shows how to create 2D histograms: Histograms - 3 : 2D Histograms

Hope this helps!

huangapple
  • 本文由 发表于 2023年4月20日 01:47:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76057458.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定