How do I convert a 3D RGB image to a grayscale image using the intensity formula (intensity=0.2989*red + 0.5870*green + 0.1140*blue)?
Show older comments
Here is part of the script, and I believe my use of the cat function is incorrect but I'm not sure how else to convert the RGB image to grayscale (Side question: Is a grayscale image 2D?):
red=crystal(:,:,1);
green=crystal(:,:,2);
blue=crystal(:,:,3);
red_new(:,:,:)=0.2989*red + 0.5870*green + 0.1140*blue;
green_new(:,:,:)=0.2989*red + 0.5870*green + 0.1140*blue;
blue_new(:,:,:)=0.2989*red + 0.5870*green + 0.1140*blue;
crystal_new=cat(2,crystal_red,crystal_green,crystal_blue);
Thank you! I've been trying various approaches and none seem to be working.
Accepted Answer
More Answers (0)
Categories
Find more on Color and Styling 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!