Info

This question is closed. Reopen it to edit or answer.

Switching Pixel Colors in an Image

1 view (last 30 days)
William
William on 20 Nov 2013
Closed: MATLAB Answer Bot on 20 Aug 2021
The question is how can I take an image file thats already loaded, scan through each pixel on all rows and columns and replace the amount of red with the number of blue ones, the green with the number of red ones, and the blue with the old green ones. What way would there be to do this?

Answers (1)

Image Analyst
Image Analyst on 21 Nov 2013
Try this:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Recombine separate color channels into a single, true color RGB image.
rgbImageNew = cat(3, blueChannel, redChannel, greenChannel);
imshow(rgbImageNew);

Community Treasure Hunt

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

Start Hunting!