How to make a Clipping of an image in Julia

how to make a Clipping of an image in Julia

When you have a grayscale image, it is quantized to one byte.
(I would like to do it with a color image such as the mandrill)

That means that only 255 bts can be quantified and can not be exceeded or have negative values.
Clipping = set limits of the quantification between 0 and 255
yes x <0 yes x> 255
x == 0 x == 255

I think that’s a great question. There’s probably a “one-line” way to do it, but I did it in two lines.

Suppose a is your image matrix:

a = [-230, 1, 260, 5]
a = map(x -> x > 255 ? 255 : x, a)
a = map(x -> x < 0 ? 0 : x, a)

map takes a function (in this case, an anonymous function) and applies it to the container passed as second argument (a).