MATLAB: Part color part black and white grayscale color images I have a grayscale image. I want to change some pixels to colored pixels. How do I do that? thanks Best Answer You need to convert the grayscale to equivalent (gray-toned) RGB image, after which you can add color to the image.newRGBimage = YourGrayImage(:,:,[1 1 1]); %a fast way of copying the image to three color planesnewRGBimage(:,[1 end], 1) = 255; %draw a red left and right border Related SolutionsMATLAB: Separate the red part of imge A naive approach would be to extract "red" colors from the image:I = imread('peppers.png');R = I(:,:,1);G = I(:,:,2);B = I(:,:,3);% Here I am naively defining "red" as the red layer being greater than% some threshold and the blue and green layers being less than that thresholdthold = 100;mask = R>thold & G<thold & B<thold;R(~mask) = 255;G(~mask) = 255;B(~mask) = 255;J = cat(3,R,G,B);figure; montage(cat(4,I,J),'Size',[1 2]);More advanced approaches exists (google "image segmentation"). For instance, see the MATLAB example for color-based segmentation using k-means clustering. MATLAB: Rotate part of an image https://www.mathworks.com/help/images/ref/imrotate.html Related QuestionHow to crop a interest part imageBlack pixels to whiteExtraction of part of image
Best Answer