MATLAB: LSB insertion on RGB image

digital image processingimage analysisimage processinglsb

I would like to know how one would
  1. Check the value of the LSB for each channel (R,G,B)
  2. Change the value (1->0 or 0->1)
Using 24-bit image ( 8 bit for each channel)

Best Answer

See this:
m=magic(5)
lowestBits = rem(m, 2)
m =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
lowestBits =
1 0 1 0 1
1 1 1 0 0
0 0 1 0 0
0 0 1 1 1
1 0 1 0 1
So you'd do
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Get LSB's of each pixel.
redLsb = rem(redChannel, 2);
greenLsb = rem(greenChannel, 2);
blueLsb = rem(blueChannel, 2);