How to create an image by replacing each pixel with mean RGB value.

 Risposta accettata

Specify the dimension to the mean function. It will create a grayscale image
img = im2double(imread('peacock.jpg'));
img_mean = mean(img, 3);
fig = figure();
subplot(1, 2, 1);
imshow(img);
subplot(1, 2, 2);
imshow(img_mean);

3 Commenti

Thank you! Would you by any chance know how to do these others?
(done)use the mean (average) of each color component (RGB) of the respective pixel for the value of each pixel;
for the value of each pixel, use the mean power of each color component (RGB) of the pixel in question;
use the variance of each color component (RGB) of the respective pixel for the value of each pixel.
You can calculate these other images using their formula. For example
img = im2double(imread('peacock.jpg'));
img_mean = mean(img, 3);
img_power = rms(img, 3);
img_var = var(img, 1, 3);
fig = figure();
subplot(2, 2, 1);
imshow(img);
subplot(2, 2, 2);
imshow(img_mean);
subplot(2, 2, 3);
imshow(img_power);
subplot(2, 2, 4);
imshow(img_var);

Accedi per commentare.

Più risposte (0)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by