When you have a grayscale image, it is quantized to one byte.
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 would like to do it with a color image such as the mandrill)
I have problems with Clipping on an image, someone could help me.

using Images, TestImages
img = TestImage("mandrill")
img2 = Gray.(img) #grayscale image from color image

the format of the images are a type of Normalized integer, between 0 and 1, so to convert to values between 0 and 255, we just have to multiply:

img3 = 255 .* img2
img4 = convert.(Float64,img3) # to transform the array of colors to array of Float64

Knowing about the implicit types used in the images.jl package, you can actually extract directly the integer value, without converting to a floating number:

img3 = broadcast(x->Int(x.val.i),img2) #applies the function over the entire image

this works because:

Gray is a struct with val as a field of type Normed number

a Normed Number is a struct with i as the integer value, and because is a N0f8 type, is normalized with 8 bits, so the max value of that integer is 255 (what you are looking for, using the Mandrill example from TestImages)

So, the fist solution is general, the second solution is more specific and fast, you choose .

Also, remember to always put a minimal working example, the people canât help you if they donât understand what your code is like, i think what you have based on former questions you asked here.

PD: i donât work with images in julia, but is fun!

Clipping = establishes limits of the quantification between 0 and 255, this is something in matlab (so they expressed it to me)

example in matlab

im = imread (âpout.tifâ);
imhsow (im)
im = double (im); % the data type was changed
[ren, col] = size (im); % number of rows and columns
im2 = zeros (ren, col);
k = 100;
k = 100;
for i = 1: re
for j = 1: col
im2 (i, j) = im (i, j) + k;
end
end

something like this or similar I would like to do it in matlab, step by step, could someone help me?

I see a problem with the overflow, but in theory, you can easily sum said number to the image, this is the matlab algorithm transformed to julia

using Images, TestImages
img = TestImage("mandrill")
im = Gray.(img)
im = float64(img2) #im = double(im)
(ren, col) = size(im)
img2 = zeros(ren,col)
k = 100/255
for i = 1:re
for j = 1:col
im [i, j] = im[i, j]+k
end
end

Respecting the clipping, i really donÂ´t know, iâm not a professional, even an amateur, in that area.

The error message is clear: you didnât define img2 before using it. Programming is dependent on context, and itâs hard to help you if we donât know the exact sequence of commands youâre using. Please try to produce a minimal example: How to create a Minimal, Reproducible Example - Help Center - Stack Overflow