-
Notifications
You must be signed in to change notification settings - Fork 5
/
rule_8.m
38 lines (35 loc) · 1.29 KB
/
rule_8.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
30
31
32
33
34
35
36
37
38
function [encoded_pixel_decimal] = rule_8(pixel_value,Type)
encoded_pixel=[];
pixel_value_bin=dec2bin(pixel_value,8);
switch Type
case 'Encryption'
for i=1:2:8
a=pixel_value_bin(i:i+1);
switch a
case '00'
encoded_pixel = [encoded_pixel '01'];
case '01'
encoded_pixel = [encoded_pixel '11'];
case '10'
encoded_pixel = [encoded_pixel '10'];
case '11'
encoded_pixel = [encoded_pixel '00'];
end
end
case 'Decryption'
for i=1:2:8
a=pixel_value_bin(i:i+1);
switch a
case '01'
encoded_pixel = [encoded_pixel '00'];
case '11'
encoded_pixel = [encoded_pixel '01'];
case '10'
encoded_pixel = [encoded_pixel '10'];
case '00'
encoded_pixel = [encoded_pixel '11'];
end
end
end
encoded_pixel_decimal=bin2dec(encoded_pixel);
end