How to create 2D Gray image from 3D colored image?
Show older comments
I've been trying to create a 2D matrix using the Average of RGB values from each pixel in a 3D matrix.
for i = 1:m
for j = 1:n
gray(i,j) = double((A(i,j,1) + A(i,j,2) + A(i,j,3))/3);
%%gray(i,j) = round(gray(i,j)/255);
end
end
imshow(gray, []);
This only shows a red image with some greens in it. It is possible that it still is trying to print using RGB values maybe?
IF I uncomment this: "gray(i,j) = round(gray(i,j)/255);" , I get a black image.
All I need is a simple direction. What am I doing wrong? The image should be grayscale form the averages of RGB values.
Accepted Answer
More Answers (0)
Categories
Find more on Images in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!