🙆
各画素のRGB値をヒストグラムで表示する
各画素のRGB値をヒストグラムで表示します。
対象画像
ソースコード
using Images
using Plots
image = load("image.png")
width, height = size(image)
reds = []
greens = []
blues = []
for y ∈ 1:height, x ∈ 1:width
push!(reds, image[x, y].r * 255 |> Int)
push!(greens, image[x, y].g * 255 |> Int)
push!(blues, image[x, y].b * 255 |> Int)
end
red_histo = histogram(reds, label="Reds of images", lc=:red)
green_histo = histogram(greens, label="Greens of images", lc=:green)
blue_histo = histogram(blues, label="Blues of images", lc=:blue)
plot(red_histo, green_histo, blue_histo)
savefig("rgb.png")
Discussion