This repository has been archived on 2021-02-05. You can view files and clone it, but cannot push or open issues or pull requests.
ipcv/julia_scripts/point.jl
Nguyễn Anh Khoa a43837539e init
2019-05-14 22:37:19 +07:00

36 lines
796 B
Julia

using Images
using FileIO
using Colors
function transform(img, what, params...)
if length(params) < 2
error("Transform requires two parameter (a, b)")
end
a, b = params
out = zeros(eltype(img), size(img))
if what == "linear"
out = a .* img .+ b
elseif what == "log"
out = a .* log.(1 .+ img) .+ b
elseif what == "exp"
out = a .* exp.(img) .+ b
elseif what == "pow"
if length(params) < 3
error("Power transform requires three parameter (a, b, gamma)")
end
gamma = params[3]
out = a .* (img .^ gamma) .+ b
else
error("What the hell man?")
end
# TODO: Scale to 255
out
end
if abspath(PROGRAM_FILE) == @__FILE__
what = ARGS[1]
img = Gray.(load(ARGS[2]))
out = transform(img, what, ARGS[3:end]...)
save("point.png", out)
end