(1) | a1 = enter the message; | (2) | N = length (a1) 8; %Length calculates the message length in bits | (3) | Binarystring = dec2bin (a1, 8); %Message in bits | (4) | I = Read image; %Insert Image in I variable | (5) | [r, c] = size (I); %r and c give the row and column of the image | (6) | X = zeros (r, c); %Initialize a temporary matrix, X, to ZERO | (7) | Let K = 1; %Initialize a variable K | (8) | Let a = 1; %Initialize a variable a | (9) | Repeat L = 1: r %Repeat L = 1 to r | (10) | Repeat m = 1: c %Repeat L = 1 to c | (11) | A = get 2nd bit of I, (I (L, m), 2); %A is the 2nd bit of I | (12) | Q = I (L, m) +1; %Q is the next pixel of the image I | (13) | B = get 2nd bit of Q, (Q, 2); %B is the 2nd bit of Q | (14) | If (K < N) | (15) | M1 = binarystring (a); %M1 is the first message bit | (16) | M2 = binarystring (a + 1); %M2 is the second message bit | (17) | if ((A==0) && (B==0)) | (18) | if ((M1==0) && (M2==0)) | (19) | X (L, m) = I (L, m); %No change in pixel value and drop I in X | (20) | end | (21) | if ((M1==0) && (M2==1)) | (22) | X (L, m) = I (L, m) +1; %Pixel value is incremented by 1 | (23) | end | (24) | if ((M1==1) && (M2==0)) | (25) | X (L, m) = I (L, m) −1; %Pixel value is decremented by 1 | (26) | end | (27) | if ((M1==1) && (M2==1)) | (28) | X (L, m) = I (L, m) +2; %Pixel value is incremented by 1 | (29) | end | (30) | end | (31) | if ((A==0) && (B==1)) | (32) | if ((M1==0) && (M2==0)) | (33) | X (L, m) = I (L, m) −1; | (34) | end | (35) | if ((M1==0) && (M2==1)) | (36) | X (L, m) = I (L, m); | (37) | end | (38) | if ((M1==1) && (M2==0)) | (39) | X (L, m) = I (L, m) +2; | (40) | end | (41) | if ((M1==1) && (M2==1)) | (42) | X (L, m) = I (L, m) +1; | (43) | end | (44) | end | (45) | if ((A==1) && (B==0)) | (46) | if ((M1==0) && (M2==0)) | (47) | X (L, m) = I (L, m) +1; | (48) | end | (49) | if ((M1==0) && (M2==1)) | (50) | X (L, m)=I (L, m) +2; | (51) | end | (52) | if ((M1==1) && (M2==0)) | (53) X (L, m) = I (L, m); | (54) | end | (55) | if ((M1==1) && (M2==1)) | (56) | X (L, m) = I (L, m) −1; | (57) | end | (58) | end | (59) | if ((A==1) && (B==1)) | (60) | if ((M1==0) && (M2==0)) | (61) | X (L, m) = I (L, m) +2; | (62) | end | (63) | if ((M1==0) && (M2==1)) | (64) | X (L, m) = I (L, m) −1; | (65) | end | (66) | if ((M1==1) && (M2==0)) | (67) | X (L, m) = I (L, m) +1; | (68) | end | (69) | if ((M1==1) && (M2==1)) | (70) | X (L, m) = I (L, m); | (71) | end | (72) | end | (73) | K = K + 2; | (74) | a = a + 2; | (75) | else | (76) | X (L, m) = I (L, m); | (77) | end | (78) | end | (79) | end | (80) | Convert X matrix to an image, that is, stego.tif |
|