Kyliroco commited on
Commit
21a3fdd
·
verified ·
1 Parent(s): 3317587

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +67 -0
README.md CHANGED
@@ -1,3 +1,70 @@
1
  ---
2
  license: cc-by-nc-sa-4.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: cc-by-nc-sa-4.0
3
  ---
4
+ # DocQT - Improving Document Forgery Localization Robustness via Diverse JPEG Quantization-Tables
5
+
6
+ Repository containing JPEG quantization tables used for the Real-QT protocol.
7
+ Dataset name: DocQT.
8
+ Only header-extracted quantization matrices are provided.
9
+
10
+ ## Available quantization tables
11
+
12
+ - Luminance tables: `quantification_luminance.json`
13
+ - Number of tables: 859
14
+ - Chrominance tables: `quantification_chrominance.json`
15
+ - Number of tables: 294
16
+
17
+ ## File format
18
+
19
+ Both files are stored in JSON for better portability and long-term compatibility.
20
+
21
+ - Root object: a list of quantization tables
22
+ - One table: a flat list of 64 integers
23
+ - Table values: integers
24
+
25
+ In other words, each file follows this structure:
26
+
27
+ - list[table]
28
+ - table = list[64 integer values]
29
+
30
+ ## Example: use quantization tables with Pillow JPEG compression
31
+
32
+ ```python
33
+ import json
34
+ from pathlib import Path
35
+ from PIL import Image
36
+
37
+
38
+ def load_quantization_tables(base_dir: str = ".") -> tuple[list, list]:
39
+ base_path = Path(base_dir)
40
+
41
+ luminance_tables = json.loads(
42
+ (base_path / "quantification_luminance.json").read_text(encoding="utf-8")
43
+ )
44
+ chrominance_tables = json.loads(
45
+ (base_path / "quantification_chrominance.json").read_text(encoding="utf-8")
46
+ )
47
+
48
+ return luminance_tables, chrominance_tables
49
+
50
+ luminance_tables, chrominance_tables = load_quantization_tables(".")
51
+
52
+ # Choose the table indices you want to use for compression.
53
+ luma_idx = 0
54
+ chroma_idx = 0
55
+
56
+ luma_qtable = luminance_tables[luma_idx]
57
+ chroma_qtable = chrominance_tables[chroma_idx]
58
+
59
+ with Image.open("input.png") as image:
60
+ image = image.convert("RGB")
61
+ image.save(
62
+ "output_custom_qtables.jpg",
63
+ format="JPEG",
64
+ qtables=[luma_qtable, chroma_qtable],
65
+ subsampling="4:2:0",
66
+ optimize=True,
67
+ )
68
+
69
+ # Note: avoid passing a quality value if you want to keep your custom qtables as-is.
70
+ ```