Pseudocode
PROCEDURE channel_swap(image)
FOR x = 0 .. width DO
FOR y = 0 .. height DO
c <- pixel(x, y)
tmp <- c_0
c_0 <- c_1
c_0 <- tmp
pixel(x, y) <- c
END FOR
END FOR
END PROCEDURE
Description
Loop through each pixel in the image and retrieve its value. Perfrom a swap of the two channels (eg, using an intermediary) and then set the (now swapped) channels back into the image at the same location.
Related Concepts
-
Swap using a temporary value
Acknowledgements
Adapted from Pseudocode produced for COMP120 by Dr. Micheal Scott.