grayscale image average without matlab function

4 visualizaciones (últimos 30 días)
lech king
lech king el 8 de Oct. de 2020
Respondida: Ameer Hamza el 8 de Oct. de 2020
Hi
I want to calculate the average of 3x3 cells of a matrix that contains the values of a grayscale image, which is a variable type is unit8
But for example, 2 cells have a value of 200, the sum of 2 of which is 400, but due to the Limitations of unit8 255 is calculated.
when use
pic=im2unit16(pic)
or
pic=unit16(pic)
then use imshow the result is a blank page
Thank you for your help

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 8 de Oct. de 2020
First convert to uint16 (or double. Average the values and convert back to uint8
img = imread('pears.png');
r = img(:,:,1);
g = img(:,:,1);
b = img(:,:,1);
r = uint16(r);
g = uint16(g);
b = uint16(b);
img_gray = (r+g+b)/3;
imshow(uint8(img_gray))

Más respuestas (0)

Categorías

Más información sobre Images en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by