gpt4 book ai didi

image - 在 Julia 中从 `M` x `N` x 3 数组生成 HSV 图像

转载 作者:行者123 更新时间:2023-12-01 15:54:41 25 4
gpt4 key购买 nike

我有一个 M by N by 3 浮点实数数组,我想将其解释为图像的 HSV channel 。我想生成并导出图像。

根据函数文档,

colorim(A, [colorspace])

Creates a 2d color image from an AbstractArray, auto-detecting which of the first or last dimension encodes the color and choosing between "horizontal-" and "vertical-major" accordingly. colorspace defaults to "RGB" but could also be e.g. "Lab" or "HSV".

我首先测试了 RGB 情况:

using Images
imwrite(colorim(rand(Float64, 200, 200, 3), "RGB"), "Image.PNG")

产生以下内容:

enter image description here

但是,当我根据文档将“RGB”替换为“HSV”时,我收到一条错误消息。

将数组解释和导出为 HSV 数据的正确语法是什么?

最佳答案

using Images, Color
B = permutedims(A, [3,1,2]) # put color first
C = reinterpret(HSV{Float64}, B)

关于image - 在 Julia 中从 `M` x `N` x 3 数组生成 HSV 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28635900/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com