-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtractImageLSB.m
More file actions
39 lines (34 loc) · 1.08 KB
/
ExtractImageLSB.m
File metadata and controls
39 lines (34 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function lsb = ExtractImageLSB(image)
% Function ExtractImageLSB extracts the least significant bits from an
% image array of uint8 values
% Input:
% array: A 3D array of uint8 values representing a RGB image
% Output:
% lsb = A 3D array of uint8 values, which contains the LSB for each
% corresponding entry in the input
%
% Author: Henry Huang
row = size(image,1);
col = size(image,2); % find size of rows and columns
lsb = uint8(zeros(size(image))); % initialise originial lsb array
% for i = 1:row
% for j = 1:col
% for k = 1:3 % Nested loops to iterate through rows, cols and layers
% if mod(image(i,j,k),2) == 0 % Modulo function with respect to 2
% lsb(i,j,k) = 0; % set value as 0 if remainder is 0
% else
% lsb(i,j,k) = 1; % else set 1
% end
% end
% end
% end
for i = 1:row
for j = 1:col
for k = 1:3 % Nested loops to iterate through rows, cols and layers
lsb(i,j,k) = mod(image(i,j,k),2);
% lsb = mod(image,2);
end
end
end
lsb = uint8(lsb);
end