Skip to content

Commit 17b19ab

Browse files
committed
some f0
1 parent 5fd24cb commit 17b19ab

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

docs/Project.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
[deps]
2+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
23
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
34
DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365"
45
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
56
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
67
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
8+
ImageShow = "4e3cecfd-b093-5904-9786-8bbb286a6a31"
9+
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
710
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
11+
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
12+
Metal = "dde4c033-4e86-420c-a63e-0dd931031962"
813
Trace = "afc56b53-c9a9-482a-a956-d1d800e05558"
914

1015
[compat]

src/materials/tonemap.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
using Colors, Statistics
22

3-
luminosity(c::RGB{T}) where {T} = (max(c.r, c.g, c.b) + min(c.r, c.g, c.b)) / 2.0
3+
luminosity(c::RGB{T}) where {T} = (max(c.r, c.g, c.b) + min(c.r, c.g, c.b)) / 2.0f0
44

55
function lum_max(rgb_m)
6-
lum_max = 0.0
6+
lum_max = 0.0f0
77
for pix in rgb_m
88
(lum_max > luminosity(pix)) || (lum_max = luminosity(pix))
99
end
1010
lum_max
1111
end
1212

13-
function avg_lum(rgb_m, δ::Number=1e-10)
14-
cumsum = 0.0
13+
function avg_lum(rgb_m, δ::Number=1f-10)
14+
cumsum = 0.0f0
1515
for pix in rgb_m
1616
cumsum += log10+ luminosity(pix))
1717
end
@@ -20,13 +20,13 @@ end
2020

2121
function normalize_image(
2222
rgb_m,
23-
a::Float64=0.18,
23+
a::Float32=0.18f0,
2424
lum::Union{Number,Nothing}=nothing,
25-
δ::Number=1e-10
25+
δ::Number=1f-10
2626
)
2727

28-
(isnothing(lum) || lum 0.0) && (lum = avg_lum(rgb_m, δ))
29-
return rgb_m .* a .* (1.0 / lum)
28+
(isnothing(lum) || lum 0.0f0) && (lum = avg_lum(rgb_m, δ))
29+
return rgb_m .* a .* (1.0f0 / lum)
3030
end
3131

3232
function clamp_image(img::AbstractMatrix{T}) where {T}
@@ -35,7 +35,7 @@ function clamp_image(img::AbstractMatrix{T}) where {T}
3535
end
3636
end
3737

38-
function γ_correction(img::AbstractMatrix{T}, γ::Float64=1.0, k::Float64=1.0) where T
38+
function γ_correction(img::AbstractMatrix{T}, γ::Float32=1.0f0, k::Float32=1.0f0) where T
3939
return map(img) do c
4040
return T(
4141
floor(255 * c.r^(1 / γ)),
@@ -46,8 +46,8 @@ function γ_correction(img::AbstractMatrix{T}, γ::Float64=1.0, k::Float64=1.0)
4646
end
4747

4848
function tone_mapping(img;
49-
a::Float64=0.18,
50-
γ::Float64=1.0,
49+
a::Float32=0.18f0,
50+
γ::Float32=1.0f0,
5151
lum::Union{Number,Nothing}=nothing
5252
)
5353
img = normalize_image(img, a, lum)

0 commit comments

Comments
 (0)