Skip to content
Snippets Groups Projects
Commit a5389d2c authored by Taburet Théo's avatar Taburet Théo
Browse files

Few corrections...

parent 32e5370b
Branches
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
#Import depencies
from NS.sampling import BIL as Sampler
import os
import rawpy
import matplotlib.pyplot as plt
```
%% Cell type:markdown id: tags:
# Embedding
This notebook is a toy example which perform a cover source switching from ISO100 to ISO200 using the rights *(a, b)* for the database. The sampling can be done using different methods : MVG, Cholesky and Rejection-Sampling.
%% Cell type:code id: tags:
``` python
cwd = os.getcwd()
cover_path = cwd+'/ISO100/EYED5607.DNG'
cover_name = os.path.basename(cover_path)
raw_cover = rawpy.imread(cover_path)
```
%% Cell type:markdown id: tags:
## 1 Sampling of undecimated DCT coefficients
Available sampling strategies :
* Using MVG/Cholesky over 4 lattices
* Using MVG/Cholesky to preserve intra correlations only
* Using MVG/Cholesky to sample under independance hypothesis of DCT coefficients
%% Cell type:markdown id: tags:
### 1.1.a Using MVG/Cholesky over 4 lattices
The two lines were used to obtain the result of the **Table I** and row **'J-Cov-NS'**.
| PE (%)/<br>JPEG QF | J-Cov-NS |
| :--- | :----: |
| 100 | 42.9 |
| 95 | 41.2 |
| 85 | 41.2 |
| 75 | 41.6 |
%% Cell type:code id: tags:
``` python
#sampler = Sampler.MVG(cover = raw_cover, seed = 1234) #MVG
#sampler = Sampler.Cholesky(cover = raw_cover, seed = 1234) #Cholesky
```
%% Cell type:markdown id: tags:
### 1.1.b Using MVG/Cholesky to preserve intra correlations only
To obtain the result of the **Table I** and row **'Intra-block correlations only'**.
| PE (%)/<br>JPEG QF |Intra-block<br>correlations only |
| :--- | :----: |
| 100 | 0.0 |
| 95 | 0.2 |
| 85 | 15.8 |
| 75 | 25.2 |
%% Cell type:code id: tags:
``` python
#sampler = Sampler.MVG(cover = raw_cover, seed = 1234, strategy = "Intra-only") #MVG
sampler = Sampler.Cholesky(cover = raw_cover, seed = 1234, strategy = "Intra-only") #Cholesky
```
%% Cell type:markdown id: tags:
### 1.1.c Using MVG/Cholesky to sample under independance hypothesis of DCT coefficients
Used to confirm the results obtained by Tomáš Denemark, Patrick Bas, and Jessica Fridrich in the paper called *'Natural Steganography in JPEG Compressed Images'* published in *'Electronic Imaging 2018'* and shown in the article at **Table I** and row **'Independent embedding'**.
| PE (%)/<br>JPEG QF |Independent<br>embedding |
| :--- | :----: |
| 100 | 0.0 |
| 95 | 0.5 |
| 85 | 10.8 |
| 75 | 27.0 |
%% Cell type:code id: tags:
``` python
#sampler = Sampler.MVG(cover = raw_cover, seed = 1234, strategy = "Independant") #MVG
#sampler = Sampler.Cholesky(cover = raw_cover, seed = 1234, strategy = "Independant") #Cholesky
```
%% Cell type:markdown id: tags:
### 1.2 Quantization and full-frame cover's splitting
This code generate a quantized full-frame version of the undecimated DCT version of the stego and split into *512x512* quantized arrays.
%% Cell type:code id: tags:
``` python
stego, crops = sampler.computeStego().getStego(Qf = 100, crop_size = (512, 512))
```
%% Cell type:markdown id: tags:
## 2 Sampling of quantized DCT coefficients
%% Cell type:markdown id: tags:
### 2.a Pseudo-embedding
Available sampling strategies :
* Pseudo-embedding
Details at section **II.C.1** and **Figure 1**, and performance of this embedding shown in the article at **Table I** and row **'Pseudo embedding'**.
| PE (%)/<br>JPEG QF |Pseudo<br>embedding |
| :--- | :----: |
| 100 | 40.2 |
| 95 | 40.9 |
| 85 | 41.9 |
| 75 | 41.3 |
%% Cell type:code id: tags:
``` python
#Pseudo-embedding
sampler = Sampler.Sampler(cover = raw_cover, seed = 1234, strategy = "Pseudo") #Pseudo-embedding
#sampler = Sampler.Sampler(cover = raw_cover, seed = 1234, strategy = "Pseudo") #Pseudo-embedding
sampler = Sampler.Sampler(cover = raw_cover, seed = 1234, strategy = "Pseudo-spatial") #Pseudo-embedding spatial
```
%% Cell type:markdown id: tags:
### 2.b Rejection sampling
Available sampling strategies :
* Using rejection sampling over 4 lattices
* Using rejection sampling to preserve intra correlations only
* Using rejection sampling to sample under independance hypothesis of DCT coefficients
%% Cell type:code id: tags:
``` python
#RJ over 4-Lattices
#sampler = Sampler.RJ(cover = raw_cover, Qf = 100, K = 1, seed = 1234) #RJ - 4 lattices
```
%% Cell type:code id: tags:
``` python
#RJ : intra-only
#sampler = Sampler.RJ(cover = raw_cover, Qf = 100, K = 1, seed = 1234, strategy = "Intra-only") #RJ - intra
```
%% Cell type:code id: tags:
``` python
#RJ : independant
#sampler = Sampler.RJ(cover = raw_cover, Qf = 100, K = 1, seed = 1234, strategy = "Independant") #RJ - independant
```
%% Cell type:markdown id: tags:
## Quantize and crop :
%% Cell type:code id: tags:
``` python
stego, crops = sampler.computeStego().getStego(crop_size = (512, 512))
```
%% Output
[array([[-1121, -132, -125, ..., -47, -31, -16],
[ -132, -182, -172, ..., -67, -44, -23],
[ -124, -172, -163, ..., -62, -40, -22],
...,
[ -72, -100, -94, ..., -46, -30, -15],
[ -50, -69, -63, ..., -31, -20, -10],
[ -26, -35, -33, ..., -16, -10, -4]], dtype=int32), array([[-1086, -82, -78, ..., -34, -24, -12],
[ -82, -113, -107, ..., -46, -32, -16],
[ -78, -108, -101, ..., -42, -29, -15],
...,
[ -53, -72, -66, ..., -19, -13, -6],
[ -36, -50, -45, ..., -14, -8, -5],
[ -19, -27, -24, ..., -7, -4, -2]], dtype=int32), array([[-1069, -59, -55, ..., -38, -27, -13],
[ -58, -82, -76, ..., -53, -38, -19],
[ -54, -76, -73, ..., -49, -35, -19],
...,
[ -25, -36, -33, ..., -45, -31, -17],
[ -19, -26, -22, ..., -30, -20, -10],
[ -8, -13, -13, ..., -15, -11, -5]], dtype=int32), array([[-1074, -67, -66, ..., -81, -56, -28],
[ -67, -93, -90, ..., -111, -76, -39],
[ -64, -90, -87, ..., -101, -70, -35],
...,
[ -59, -83, -78, ..., -60, -44, -24],
[ -39, -56, -55, ..., -41, -30, -17],
[ -20, -29, -28, ..., -21, -15, -8]], dtype=int32), array([[-1129, -141, -133, ..., -69, -46, -23],
[ -140, -193, -180, ..., -97, -66, -34],
[ -128, -175, -163, ..., -93, -66, -33],
...,
[ -81, -114, -109, ..., -56, -39, -19],
[ -56, -79, -74, ..., -37, -27, -15],
[ -28, -40, -39, ..., -20, -15, -9]], dtype=int32), array([[-1112, -120, -114, ..., -57, -41, -18],
[ -121, -169, -159, ..., -81, -54, -24],
[ -118, -161, -150, ..., -73, -49, -22],
...,
[ -67, -93, -89, ..., 6, 6, 0],
[ -46, -65, -62, ..., 7, 10, 8],
[ -24, -33, -29, ..., 7, 4, 7]], dtype=int32), array([[-1098, -100, -97, ..., -86, -59, -30],
[ -99, -140, -134, ..., -118, -81, -41],
[ -87, -128, -127, ..., -110, -76, -39],
...,
[ 0, -11, -6, ..., -66, -45, -24],
[ 3, 3, 2, ..., -43, -30, -16],
[ 2, 4, 0, ..., -21, -16, -8]], dtype=int32), array([[-1134, -149, -139, ..., -86, -59, -30],
[ -149, -206, -193, ..., -119, -82, -42],
[ -141, -195, -184, ..., -111, -77, -40],
...,
[ -85, -118, -111, ..., -70, -49, -25],
[ -59, -82, -76, ..., -48, -35, -18],
[ -29, -42, -40, ..., -24, -17, -9]], dtype=int32), array([[-1135, -151, -143, ..., -59, -39, -18],
[ -151, -209, -197, ..., -83, -54, -25],
[ -142, -197, -185, ..., -77, -52, -25],
...,
[ -85, -119, -112, ..., -47, -31, -14],
[ -59, -82, -77, ..., -35, -24, -12],
[ -30, -41, -39, ..., -20, -14, -8]], dtype=int32), array([[-1118, -127, -118, ..., -57, -36, -17],
[ -127, -175, -164, ..., -79, -51, -24],
[ -119, -165, -155, ..., -75, -50, -23],
...,
[ -69, -96, -90, ..., -26, -18, -9],
[ -47, -66, -62, ..., -19, -12, -7],
[ -24, -34, -32, ..., -9, -6, -3]], dtype=int32), array([[-1093, -93, -87, ..., -25, -15, -8],
[ -93, -128, -120, ..., -35, -23, -12],
[ -87, -121, -115, ..., -32, -22, -13],
...,
[ -36, -50, -46, ..., -15, -11, -7],
[ -26, -34, -33, ..., -10, -8, -5],
[ -12, -16, -16, ..., -4, -4, -2]], dtype=int32), array([[-1057, -44, -43, ..., -59, -41, -20],
[ -44, -61, -58, ..., -82, -56, -28],
[ -44, -59, -55, ..., -78, -54, -28],
...,
[ -20, -29, -27, ..., -63, -42, -21],
[ -15, -21, -19, ..., -43, -28, -14],
[ -7, -11, -11, ..., -22, -14, -7]], dtype=int32), array([[-1099, -103, -100, ..., -77, -55, -30],
[ -103, -144, -137, ..., -106, -75, -40],
[ -98, -136, -127, ..., -101, -72, -38],
...,
[ -77, -105, -97, ..., -68, -47, -24],
[ -52, -71, -65, ..., -47, -33, -17],
[ -26, -35, -32, ..., -24, -16, -8]], dtype=int32), array([[-1130, -145, -140, ..., -70, -52, -27],
[ -143, -202, -194, ..., -96, -71, -38],
[ -134, -189, -182, ..., -92, -67, -36],
...,
[ -87, -121, -114, ..., -48, -35, -21],
[ -60, -83, -78, ..., -34, -24, -15],
[ -30, -42, -40, ..., -18, -14, -7]], dtype=int32), array([[-1111, -118, -108, ..., 3, 3, 1],
[ -119, -165, -154, ..., -3, -1, -4],
[ -115, -160, -151, ..., 0, 0, -3],
...,
[ -71, -104, -103, ..., -51, -35, -19],
[ -51, -73, -74, ..., -34, -23, -13],
[ -26, -37, -36, ..., -20, -13, -7]], dtype=int32), array([[-1030, -3, -5, ..., -83, -58, -29],
[ -4, -5, -4, ..., -116, -79, -39],
[ 0, 2, 16, ..., -108, -72, -38],
...,
[ -67, -92, -87, ..., -68, -47, -24],
[ -45, -64, -60, ..., -47, -33, -16],
[ -23, -33, -32, ..., -24, -17, -8]], dtype=int32), array([[-1134, -150, -142, ..., -87, -62, -33],
[ -149, -207, -196, ..., -120, -86, -46],
[ -139, -194, -184, ..., -114, -84, -43],
...,
[ -87, -120, -114, ..., -62, -44, -24],
[ -60, -83, -78, ..., -43, -30, -16],
[ -31, -42, -40, ..., -22, -15, -8]], dtype=int32), array([[-1133, -149, -141, ..., -67, -46, -22],
[ -148, -206, -196, ..., -95, -65, -33],
[ -140, -195, -184, ..., -93, -64, -33],
...,
[ -81, -114, -110, ..., -61, -42, -22],
[ -56, -79, -76, ..., -42, -29, -15],
[ -29, -41, -39, ..., -21, -15, -8]], dtype=int32), array([[-1113, -121, -115, ..., -34, -23, -11],
[ -121, -170, -160, ..., -48, -33, -18],
[ -114, -160, -149, ..., -46, -32, -16],
...,
[ -68, -95, -90, ..., -23, -18, -9],
[ -47, -65, -62, ..., -17, -14, -7],
[ -24, -33, -31, ..., -8, -7, -4]], dtype=int32), array([[-1069, -61, -58, ..., -18, -13, -7],
[ -61, -86, -80, ..., -26, -18, -9],
[ -57, -80, -74, ..., -24, -16, -9],
...,
[ -32, -43, -41, ..., -14, -11, -5],
[ -23, -29, -28, ..., -10, -9, -5],
[ -11, -13, -13, ..., -5, -4, -3]], dtype=int32), array([[-1049, -33, -34, ..., -78, -52, -26],
[ -32, -46, -45, ..., -108, -72, -35],
[ -31, -43, -39, ..., -100, -67, -33],
...,
[ -18, -25, -24, ..., -67, -46, -24],
[ -13, -17, -16, ..., -46, -32, -17],
[ -6, -9, -8, ..., -23, -16, -8]], dtype=int32), array([[-1120, -129, -118, ..., -87, -60, -30],
[ -130, -177, -161, ..., -120, -83, -42],
[ -121, -164, -147, ..., -113, -78, -40],
...,
[ -86, -119, -112, ..., -66, -45, -23],
[ -59, -81, -77, ..., -46, -31, -17],
[ -30, -41, -39, ..., -24, -16, -9]], dtype=int32), array([[-1137, -154, -145, ..., -63, -47, -28],
[ -153, -213, -200, ..., -88, -67, -40],
[ -145, -200, -189, ..., -85, -65, -39],
...,
[ -85, -118, -111, ..., -22, -22, -17],
[ -58, -81, -76, ..., -9, -13, -10],
[ -30, -42, -39, ..., -4, -4, -3]], dtype=int32), array([[-1117, -129, -125, ..., -67, -44, -23],
[ -127, -182, -176, ..., -93, -61, -30],
[ -123, -173, -167, ..., -85, -55, -29],
...,
[ -31, -47, -43, ..., -60, -39, -18],
[ -19, -25, -24, ..., -39, -28, -13],
[ -8, -7, -9, ..., -19, -13, -8]], dtype=int32), array([[-1112, -119, -113, ..., -87, -60, -31],
[ -117, -160, -155, ..., -121, -83, -42],
[ -110, -152, -145, ..., -114, -78, -40],
...,
[ -67, -91, -87, ..., -68, -46, -24],
[ -45, -64, -62, ..., -47, -32, -16],
[ -26, -38, -34, ..., -24, -16, -8]], dtype=int32), array([[-1137, -154, -145, ..., -77, -55, -30],
[ -154, -213, -200, ..., -108, -77, -42],
[ -145, -201, -189, ..., -101, -72, -39],
...,
[ -86, -120, -113, ..., -67, -47, -25],
[ -60, -83, -79, ..., -46, -32, -17],
[ -30, -42, -39, ..., -23, -17, -9]], dtype=int32), array([[-1130, -146, -141, ..., -76, -53, -27],
[ -143, -203, -196, ..., -107, -74, -38],
[ -134, -190, -184, ..., -102, -70, -35],
...,
[ -85, -117, -110, ..., -61, -42, -21],
[ -58, -81, -77, ..., -43, -29, -15],
[ -29, -41, -39, ..., -22, -15, -7]], dtype=int32), array([[-1113, -121, -114, ..., -32, -23, -11],
[ -121, -167, -158, ..., -46, -32, -16],
[ -114, -157, -149, ..., -43, -29, -14],
...,
[ -68, -94, -90, ..., -27, -19, -10],
[ -48, -65, -62, ..., -20, -14, -7],
[ -24, -33, -31, ..., -11, -7, -3]], dtype=int32), array([[-1066, -54, -53, ..., -19, -15, -6],
[ -56, -76, -72, ..., -27, -17, -6],
[ -52, -72, -68, ..., -25, -16, -7],
...,
[ -35, -47, -45, ..., -16, -10, -4],
[ -25, -33, -31, ..., -12, -8, -4],
[ -13, -16, -15, ..., -7, -5, -3]], dtype=int32), array([[-1048, -31, -29, ..., -85, -59, -30],
[ -30, -42, -40, ..., -118, -82, -42],
[ -30, -40, -38, ..., -112, -77, -40],
...,
[ -21, -32, -30, ..., -63, -45, -25],
[ -15, -22, -22, ..., -44, -31, -17],
[ -8, -11, -11, ..., -22, -16, -8]], dtype=int32), array([[-1135, -151, -142, ..., -85, -58, -30],
[ -151, -209, -197, ..., -117, -81, -41],
[ -142, -197, -185, ..., -111, -76, -39],
...,
[ -83, -117, -111, ..., -58, -41, -21],
[ -58, -81, -76, ..., -42, -28, -14],
[ -29, -41, -39, ..., -22, -15, -7]], dtype=int32), array([[-1134, -150, -141, ..., -19, -20, -15],
[ -150, -208, -196, ..., -25, -27, -23],
[ -142, -196, -184, ..., -16, -20, -18],
...,
[ -77, -107, -102, ..., 0, 8, 10],
[ -54, -75, -72, ..., 7, 13, 9],
[ -27, -39, -36, ..., 5, 2, 2]], dtype=int32), array([[-1060, -46, -47, ..., -70, -45, -24],
[ -45, -67, -67, ..., -96, -64, -32],
[ -39, -58, -65, ..., -91, -62, -32],
...,
[ 12, 5, -1, ..., -50, -31, -15],
[ 22, 15, 6, ..., -32, -20, -7],
[ -1, 0, 1, ..., -16, -10, -3]], dtype=int32), array([[-1114, -121, -113, ..., -85, -58, -30],
[ -119, -165, -152, ..., -119, -81, -41],
[ -113, -154, -140, ..., -112, -77, -38],
...,
[ -48, -63, -61, ..., -66, -46, -23],
[ -26, -38, -37, ..., -46, -32, -16],
[ -19, -24, -24, ..., -23, -16, -8]], dtype=int32), array([[-1134, -150, -142, ..., -85, -60, -30],
[ -150, -208, -196, ..., -119, -82, -42],
[ -141, -196, -186, ..., -112, -77, -40],
...,
[ -79, -107, -95, ..., -67, -47, -24],
[ -58, -78, -74, ..., -47, -32, -17],
[ -27, -39, -34, ..., -24, -16, -8]], dtype=int32), array([[-1132, -148, -140, ..., -78, -53, -26],
[ -148, -207, -195, ..., -108, -73, -36],
[ -141, -196, -185, ..., -101, -68, -34],
...,
[ -86, -119, -113, ..., -66, -45, -23],
[ -60, -83, -78, ..., -45, -31, -15],
[ -31, -42, -40, ..., -23, -15, -7]], dtype=int32), array([[-1113, -121, -113, ..., -35, -24, -13],
[ -120, -168, -158, ..., -50, -35, -19],
[ -112, -157, -148, ..., -46, -32, -17],
...,
[ -71, -98, -92, ..., -35, -23, -12],
[ -49, -68, -65, ..., -24, -15, -8],
[ -25, -35, -33, ..., -13, -8, -4]], dtype=int32), array([[-1072, -63, -59, ..., -21, -15, -8],
[ -63, -86, -81, ..., -30, -20, -10],
[ -59, -80, -75, ..., -29, -19, -9],
...,
[ -45, -61, -57, ..., -25, -15, -8],
[ -31, -42, -39, ..., -15, -9, -7],
[ -15, -22, -20, ..., -9, -7, -3]], dtype=int32), array([[-1054, -39, -37, ..., -80, -58, -31],
[ -39, -56, -52, ..., -110, -80, -44],
[ -36, -51, -47, ..., -104, -76, -41],
...,
[ -32, -44, -41, ..., -68, -47, -24],
[ -23, -32, -30, ..., -47, -32, -17],
[ -11, -16, -14, ..., -24, -16, -8]], dtype=int32), array([[-1132, -148, -141, ..., -76, -52, -27],
[ -147, -205, -195, ..., -106, -73, -39],
[ -139, -193, -184, ..., -101, -69, -36],
...,
[ -86, -120, -113, ..., -67, -46, -23],
[ -60, -83, -78, ..., -46, -32, -16],
[ -30, -42, -39, ..., -24, -16, -8]], dtype=int32), array([[-1125, -138, -130, ..., 4, -1, 1],
[ -138, -192, -180, ..., 13, -2, -4],
[ -130, -180, -169, ..., 12, 3, -2],
...,
[ -86, -119, -112, ..., -67, -47, -24],
[ -59, -82, -77, ..., -46, -33, -17],
[ -30, -42, -40, ..., -23, -16, -9]], dtype=int32), array([[-1028, 1, 3, ..., -53, -36, -18],
[ 1, 3, 7, ..., -68, -50, -28],
[ 11, 11, 16, ..., -55, -36, -28],
...,
[ -86, -120, -113, ..., -68, -47, -24],
[ -60, -83, -78, ..., -47, -33, -16],
[ -30, -42, -39, ..., -25, -16, -8]], dtype=int32), array([[-1093, -90, -88, ..., -85, -58, -28],
[ -91, -126, -119, ..., -118, -80, -39],
[ -80, -115, -103, ..., -111, -75, -37],
...,
[ -86, -119, -113, ..., -66, -46, -23],
[ -59, -82, -77, ..., -45, -31, -16],
[ -30, -42, -40, ..., -23, -16, -8]], dtype=int32), array([[-1123, -131, -109, ..., -86, -59, -30],
[ -136, -180, -157, ..., -119, -82, -42],
[ -132, -175, -158, ..., -113, -78, -39],
...,
[ -85, -119, -113, ..., -68, -47, -24],
[ -58, -81, -78, ..., -47, -33, -17],
[ -30, -42, -40, ..., -24, -16, -8]], dtype=int32), array([[-1136, -153, -144, ..., -83, -56, -28],
[ -152, -212, -200, ..., -115, -78, -39],
[ -144, -200, -188, ..., -107, -73, -37],
...,
[ -87, -121, -113, ..., -68, -47, -24],
[ -60, -83, -78, ..., -47, -33, -16],
[ -30, -42, -40, ..., -24, -16, -8]], dtype=int32), array([[-1116, -125, -118, ..., -44, -29, -16],
[ -125, -174, -164, ..., -62, -41, -21],
[ -118, -163, -154, ..., -57, -37, -21],
...,
[ -73, -101, -95, ..., -49, -36, -19],
[ -50, -70, -66, ..., -35, -26, -13],
[ -25, -36, -33, ..., -18, -13, -7]], dtype=int32), array([[-1084, -79, -72, ..., -30, -22, -12],
[ -79, -106, -100, ..., -43, -30, -16],
[ -75, -101, -96, ..., -40, -28, -15],
...,
[ -62, -85, -79, ..., -34, -24, -13],
[ -43, -58, -54, ..., -23, -16, -7],
[ -22, -29, -27, ..., -12, -8, -3]], dtype=int32), array([[-1065, -54, -50, ..., -86, -59, -30],
[ -55, -75, -70, ..., -120, -83, -42],
[ -51, -70, -67, ..., -113, -78, -40],
...,
[ -41, -60, -55, ..., -67, -47, -24],
[ -27, -38, -36, ..., -47, -32, -17],
[ -14, -19, -19, ..., -24, -17, -9]], dtype=int32), array([[-1135, -152, -143, ..., -86, -60, -30],
[ -152, -211, -198, ..., -119, -82, -41],
[ -143, -198, -187, ..., -112, -77, -39],
...,
[ -86, -120, -113, ..., -68, -47, -24],
[ -59, -82, -78, ..., -47, -32, -16],
[ -30, -42, -40, ..., -24, -16, -8]], dtype=int32), array([[-1135, -152, -143, ..., -86, -60, -30],
[ -151, -210, -198, ..., -120, -83, -42],
[ -142, -198, -186, ..., -113, -78, -39],
...,
[ -87, -120, -113, ..., -68, -47, -24],
[ -60, -83, -78, ..., -47, -32, -16],
[ -30, -42, -40, ..., -24, -16, -8]], dtype=int32), array([[-1136, -152, -143, ..., -87, -59, -30],
[ -152, -211, -199, ..., -120, -82, -42],
[ -143, -199, -188, ..., -112, -77, -40],
...,
[ -86, -119, -112, ..., -68, -47, -24],
[ -59, -82, -77, ..., -47, -32, -16],
[ -30, -42, -40, ..., -25, -17, -9]], dtype=int32), array([[-1135, -152, -144, ..., -86, -59, -30],
[ -152, -211, -199, ..., -120, -82, -42],
[ -144, -199, -187, ..., -113, -78, -40],
...,
[ -87, -120, -113, ..., -68, -47, -24],
[ -60, -83, -78, ..., -47, -33, -17],
[ -31, -42, -40, ..., -24, -17, -8]], dtype=int32), array([[-1136, -153, -144, ..., -87, -60, -30],
[ -153, -212, -199, ..., -120, -83, -42],
[ -144, -199, -187, ..., -113, -78, -40],
...,
[ -87, -121, -113, ..., -69, -47, -24],
[ -60, -83, -78, ..., -47, -33, -17],
[ -31, -43, -40, ..., -24, -17, -9]], dtype=int32), array([[-1136, -153, -144, ..., -87, -60, -30],
[ -153, -211, -199, ..., -121, -83, -43],
[ -144, -199, -187, ..., -114, -79, -40],
...,
[ -88, -122, -114, ..., -68, -46, -23],
[ -60, -84, -79, ..., -46, -31, -16],
[ -31, -43, -40, ..., -24, -16, -8]], dtype=int32)]
%% Cell type:code id: tags:
``` python
```
......
......@@ -48,6 +48,8 @@ class Sampler():
self.Embedding_independant()
elif(self.strategy == "Pseudo"):
self.Embedding_pseudo()
elif(self.strategy == "Pseudo-spatial"):
self.Embedding_pseudo_spatial()
return self
......@@ -237,6 +239,12 @@ class Sampler():
return self.stego
def getStego(self, Qf = 100, crop_size = (0, 0)):
if(self.strategy == "Pseudo-spatial"):
self.stego_quantized = (self.stego/256).astype(dtype=np.uint8)
if(crop_size != (0, 0) and len(list(crop_size)) == 2):
s_i, s_j = self.stego.shape[0]//crop_size[0], self.stego.shape[1]//crop_size[1]
return self.stego_quantized, [ self.stego_quantized[crop_size[0]*i:crop_size[0]*(i+1), crop_size[1]*j:crop_size[1]*(j+1)] for i, j in itertools.product(range(s_i), range(s_j)) ]
else :
Q_Y = np.load('Q_Y.npy')[Qf-1]
self.stego_quantized = compute_jpeg_from_dct(compute_dct_domain(self.stego), Q_Y)[8:-16,16:-8]
......@@ -244,7 +252,7 @@ class Sampler():
s_i, s_j = self.stego.shape[0]//crop_size[0], self.stego.shape[1]//crop_size[1]
return self.stego_quantized, [ self.stego_quantized[crop_size[0]*i:crop_size[0]*(i+1), crop_size[1]*j:crop_size[1]*(j+1)] for i, j in itertools.product(range(s_i), range(s_j)) ]
else:
return self.stego_quantized
return self.stego_quantized, self.stego_quantized
class MVG(Sampler):
def __init__(self, cover, seed, strategy = "4-Lattices"):
......
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment