Skip to content

Latest commit

 

History

History
85 lines (70 loc) · 1.79 KB

read-gim.org

File metadata and controls

85 lines (70 loc) · 1.79 KB
using Pkg
Pkg.activate("./juliadeps/46f4f6fa-a20d-11ea-19f5-bb6450b41198")
Pkg.instantiate()
using Images
using PyPlot
PyPlot.rc("figure", figsize=(8,4))
PyPlot.rc("axes", grid=true)
function mapchannels(f, gim)
    mapslices(channelview(gim); dims = (2,3)) do channel
        f(channel)
    end |> x -> colorview(base_color_type(eltype(gim)), x)
end
function adjustchannels(gim)
    mapchannels(gim) do channel
        adjust_histogram(channel, LinearStretching())
    end
end
function loadgim(filename)
    open(filename, "r") do io
        w = read(io, Int32)
        h = read(io, Int32)
        c = 3
        data = Array{Float32}(undef, c, h, w)
        read!(io, data)
        return colorview(RGB, data)
    end
end
function plotchannels(v :: Vector{C}) where C <: Color3
    plot(comp1.(v), color = :C3)
    plot(comp2.(v), color = :C2)
    plot(comp3.(v), color = :C0)
end
gim1 = loadgim("sgims/bunny.gim")
gim2 = loadgim("res/object.gim")
figure()
plotchannels(gim1[200,:])
figure()
plotchannels(gim2[200,:])