Wed, 02 Dec 2020 12:54:43 -0500
windowsize parameter
55
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
1 | |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
2 | ############################################# |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
3 | # Utilities to work with colourmapped images |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
4 | ############################################# |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
5 | |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
6 | module ColourTools |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
7 | |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
8 | using ColorTypes: Gray |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
9 | |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
10 | # Our exports |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
11 | |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
12 | export grayimg, |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
13 | mapped_img, |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
14 | clip |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
15 | |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
16 | # Clip image values to allowed range |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
17 | clip = x -> min(max(x, 0.0), 1.0) |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
18 | |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
19 | # Tell that raw image data is grayscale |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
20 | grayimg = im -> Gray.(clip.(im)) |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
21 | |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
22 | # Apply a colourmap (vector of RGB objects) to raw image data |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
23 | function mapped_img(im, cmap) |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
24 | l = length(cmap) |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
25 | apply = t -> cmap[1+round(UInt8, clip(t) * (l-1))] |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
26 | return apply.(im) |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
27 | end |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
28 | |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
29 | end |
198108ecdab7
Oops, the ColourTools.jl file was missing.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
30 |