-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExtractImage.m
29 lines (26 loc) · 922 Bytes
/
ExtractImage.m
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
function [bwImage] = ExtractImage(embeddedImage)
%ExtractImage extracts a b&w image that has been embedded within a colour
%image
%Inputs: embeddedImage = a 3D array of uint8 values that contain a
% hidden b&w image
%Outputs: bwImage = a 2D array of uint8 values of the black and white
% image embeded inside the color image.
%Author: W. J. See
%find no of rows and cols in embedded image
[r,c,~] = size(embeddedImage);
%cycle through rows
for i=1:r
%cycle through columns
for j=1:c
%check if sum of rgb values is even
if mod(sum(embeddedImage(i,j,:)),2) == 0
%if rgb sum is even, assign black pixel
bwImage(i,j) = uint8(0);
%else, sum of rgb values must be odd
else
%if rgb sum is odd, assign white pixel
bwImage(i,j) = uint8(255);
end
end
end
end