Skip to content

Commit

Permalink
README updated with usage and file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
omkarprabhu-98 committed Apr 14, 2018
1 parent 72ab9a4 commit fb4ca08
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 76 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
frames
small1.avi
small1.avi
em_small.avi
45 changes: 41 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Data Communications (CO250): Mini-Project
# Data Communications (CO250): Mini-Project

**Title:**

Expand Down Expand Up @@ -46,10 +46,47 @@ Ramadhan J. Mstafa, Khaled M. Elleithy, "A highly secure video steganography usi
[View Paper](http://ieeexplore.ieee.org/document/6845191/)


## Usage

Run the following files in order
1. `main.m` : In the `frames` directory the following would be present
* `framesRGB` : RGB frames of the video small.mp4
* `framesY` : srambled Y components for RGB frames
* `framesU` : srambled U components for RGB frames
* `framesV` : srambled V components for RGB frames

2. `embed_message.m` : The binary image `message.png` will be embedded into the scrambled Y, U, V components.

3. `combine_frames.m` : In the directory `frames\embeddedFramesRGB`, the embedded RGB frames will be created.

4. `frames_to_video.m` : Video named `em_small.avi` will be created from the embedded RGB frames.


## File Structure

* Introduction.md - Explains theoretical aspects of the mini project.
* `Introduction.md` - Explains theoretical aspects of the mini project.

* `Design.md` - Explains design aspects of the mini project.

* `main.m` - Main module of the implementation.

* `construct_frames.m` - Construct RGB frames from the video and get their Y, U, V components. Save them in the mentioned location.

* `embed_message.m` - Applying (7, 4) Hamming Code to the message and embed the same into the scrambled Y, U, V frames.

* `combine_frames.m` - Combine the embedded Y, U, V frames into their embedded RGB frame.

* `frames_to_video.m` - Construct the video from the embedded RGB frames.

* `scramble.m` - Scrambles all the Y, U, V frames given their directory based on a key.

* `unscramble.m` - Unscrambles all the Y, U, V frames given their directory based on a key.

* `yuv2rgb.m` - Converts Y, U, V components into a single RGB frame.

* `rgb2yuv.m` - Converts a RGB frame to its Y, U, V components.

* `small.mp4` - Video used to embed message into.

* Design.md - Explains design aspects of the mini project.
* `message.png` - Binary image to be sent after embedding it into small.mp4 video and retreived at the other end.

* main.m - Main module of the implementation.
13 changes: 6 additions & 7 deletions construct_frames.m
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
% Construct frames from video and store in respective directories
function construct_frames(video, workingDir, frameLocationRGB, frameLocationY, frameLocationU, frameLocationV)

i = 1;
%=== Convert each video frame into different formats and store them ===%
while hasFrame(video)
% Read frame from the video %
% read frame from the video %
img = readFrame(video);
% Get YCbCr format from inbuilt function %
% YCbCr = rgb2ycbcr(img);
% Get YUV format from function defined in rgb2yuv.m %

% get YUV format from function defined in rgb2yuv.m %
% each frame's Y, U, V component to be stored separately %
[Y, U, V] = rgb2yuv(img);
% Naming for each frame %

% maming for each frame %
filename = [sprintf('%d',i) '.bmp'];

%=== Store the frames in their respective directories ===%
fullname = fullfile(workingDir,frameLocationRGB,filename);
imwrite(img,fullname);
% fullname = fullfile(workingDir,'imagesYCbCr',filename);
% imwrite(YCbCr,fullname);
fullname = fullfile(workingDir,frameLocationY,filename);
imwrite(Y,fullname);
fullname = fullfile(workingDir,frameLocationU,filename);
Expand Down
16 changes: 8 additions & 8 deletions frames_to_video.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%=== Set directory of frames ===%
workingDir = 'frames';

%=== get embedded RGB frames ===%
%=== Get embedded RGB frames ===%
imageNames = dir(fullfile(workingDir,'embeddedFramesRGB','*.bmp'));
imageNames = {imageNames.name}';
% for ii = 1:length(imageNames)
Expand All @@ -12,27 +12,27 @@
video1 = VideoReader('small.mp4');

%=== Set output video writer object ===%
outputVideo = VideoWriter('small1.avi', 'Uncompressed AVI');
outputVideo = VideoWriter('em_small.avi', 'Uncompressed AVI');
% set lossless compression
ouputVideo.LosslessCompression = true;
% Set same frame rate
% Set same frame rate as original video
outputVideo.FrameRate = video1.FrameRate
open(outputVideo);

%=== Frames to Video ===%
for ii = 1:length(imageNames)
% Put frames in the video
% read a RGB frame
img = imread(fullfile(workingDir,'embeddedFramesRGB',[sprintf('%d',ii) '.bmp']));
% put the frame in the video writer object
writeVideo(outputVideo,img)
end
close(outputVideo);


%=== Check if the frames after video formation ===%
%=== are same as the frames before =====%


%=== Check if the frames after video formation %
% are same as the frames before =====%
video = VideoReader('small1.avi');
video = VideoReader('em_small.avi');
i = 1;

count = 0;
Expand Down
9 changes: 4 additions & 5 deletions main.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@
workingDir = 'frames';
mkdir(workingDir);
mkdir(workingDir,'framesRGB');
mkdir(workingDir,'framesYCbCr');
mkdir(workingDir,'framesY');
mkdir(workingDir,'framesU');
mkdir(workingDir,'framesV');

%=== Get video reader obj for the video ===%
video = VideoReader('small.mp4');

% construct frames from the video reader object
% store them in these directories
%=== construct frames from the video reader object ===%
%=== store them in these directories ===%
construct_frames(video, workingDir, 'framesRGB', 'framesY', 'framesU', 'framesV');

%=== Get no of frames of the video ===%
numOfFrames = floor(video.FrameRate*video.Duration) - 1;
disp(numOfFrames);

% Fix a key %
%=== Fix a key ===%
key = 5;

% scamble the video frames
%=== scamble the video frames ===%
scramble(key, workingDir, 'framesY', 'framesU', 'framesV');
49 changes: 0 additions & 49 deletions receiver_constructFrames.m

This file was deleted.

Binary file removed reconstructed.mp4
Binary file not shown.
2 changes: 1 addition & 1 deletion rgb2yuv.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
R = RGB(:,:,1);
G = RGB(:,:,2);
B = RGB(:,:,3);
% Conversion formula
% Conversion formula RGB to YUV
Y = 0.299 * R + 0.587 * G + 0.114 * B;
U = (-0.14713 * R )- (0.28886 * G) + (0.436 * B);
V = 0.615 * R - 0.51499 * G - 0.10001 * B;
Expand Down
2 changes: 1 addition & 1 deletion yuv2rgb.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%yuv2rgb Convert Y, U, V components of a frame to a RGB frame
function [RGB] = yuv2rgb( Y, U, V )
% Conversion formula
% Conversion formula YUV to RGB
R = Y + 1.139834576 * V;
G = Y -.3946460533 * U -.58060 * V;
B = Y + 2.032111938 * U;
Expand Down

0 comments on commit fb4ca08

Please sign in to comment.