如何更改RGBA图像的单个像素?

问题描述 投票:1回答:1

在下面的代码中,我试图使第一个像素的红色分量为零。


julia> image1 = load("background1.png");

julia> x = image1[1].r
0.776N0f8

julia> image1[1].r = 0
ERROR: type RGBA is immutable

原来朱莉娅的RGBA类型是不可变的。有没有办法可以改变图像的各个像素(R,G和B组件)?

image-processing julia
1个回答
4
投票

只需制作一个新的RGB。这样做很便宜:

image1 = load("background1.png")
x = image1[1]
image1[1] = RGB(0,x.g,x.b)
© www.soinside.com 2019 - 2024. All rights reserved.