From 861242b3e73b95dc12f28f856cd2f4be969fbbd6 Mon Sep 17 00:00:00 2001 From: Jose Garcia Date: Wed, 22 Jul 2026 20:04:52 +0100 Subject: [PATCH] spectralforensics --- README.md | 270 +++++------------- pyproject.toml | 35 +-- spectralforensics.egg-info/PKG-INFO | 186 +++++++++++- spectralforensics.egg-info/SOURCES.txt | 3 - spectralforensics.egg-info/requires.txt | 4 +- spectralforensics.egg-info/top_level.txt | 2 +- spectralforensics/__init__.py | 4 - spectralforensics/dataset.py | 32 --- spectralforensics/features.py | 44 --- src/spectralforensics.egg-info/PKG-INFO | 187 ++++++++++++ src/spectralforensics.egg-info/SOURCES.txt | 15 + .../dependency_links.txt | 1 + src/spectralforensics.egg-info/requires.txt | 6 + src/spectralforensics.egg-info/top_level.txt | 1 + src/spectralforensics/__init__.py | 3 + .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 253 bytes .../__pycache__/__init__.cpython-314.pyc | Bin 0 -> 255 bytes .../__pycache__/dataset.cpython-312.pyc | Bin 0 -> 2197 bytes .../__pycache__/dataset.cpython-314.pyc | Bin 0 -> 2279 bytes .../__pycache__/features.cpython-312.pyc | Bin 0 -> 10962 bytes .../__pycache__/features.cpython-314.pyc | Bin 0 -> 11787 bytes src/spectralforensics/dataset.py | 28 ++ src/spectralforensics/features.py | 148 ++++++++++ 23 files changed, 666 insertions(+), 303 deletions(-) delete mode 100644 spectralforensics/__init__.py delete mode 100644 spectralforensics/dataset.py delete mode 100644 spectralforensics/features.py create mode 100644 src/spectralforensics.egg-info/PKG-INFO create mode 100644 src/spectralforensics.egg-info/SOURCES.txt create mode 100644 src/spectralforensics.egg-info/dependency_links.txt create mode 100644 src/spectralforensics.egg-info/requires.txt create mode 100644 src/spectralforensics.egg-info/top_level.txt create mode 100644 src/spectralforensics/__init__.py create mode 100644 src/spectralforensics/__pycache__/__init__.cpython-312.pyc create mode 100644 src/spectralforensics/__pycache__/__init__.cpython-314.pyc create mode 100644 src/spectralforensics/__pycache__/dataset.cpython-312.pyc create mode 100644 src/spectralforensics/__pycache__/dataset.cpython-314.pyc create mode 100644 src/spectralforensics/__pycache__/features.cpython-312.pyc create mode 100644 src/spectralforensics/__pycache__/features.cpython-314.pyc create mode 100644 src/spectralforensics/dataset.py create mode 100644 src/spectralforensics/features.py diff --git a/README.md b/README.md index 2fdbf28..c971871 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -SpectralForensics +\# SpectralForensics -SpectralForensics is an open-source Python library for image forensic analysis using Fast Fourier Transform (FFT) and frequency-domain feature extraction. +SpectralForensics is an open-source Python library for image forensic analysis using \*\*Fast Fourier Transform (FFT)\*\* and frequency-domain feature extraction. @@ -10,7 +10,7 @@ The library was designed to support research in digital image forensics, synthet -Features +\## Features @@ -18,17 +18,17 @@ SpectralForensics extracts a set of interpretable spectral descriptors from imag -Spectral Entropy +\- Spectral Entropy -Anisotropy +\- Anisotropy -Dominant Frequency +\- Dominant Frequency -Energy Density +\- Energy Density -High Frequency Ratio +\- High Frequency Ratio -Mean Spectral Energy +\- Mean Spectral Energy @@ -36,105 +36,115 @@ These descriptors can be used for: -AI-generated image detection +\- AI-generated image detection -Deepfake forensics +\- Deepfake forensics -Diffusion model fingerprinting +\- Diffusion model fingerprinting -Frequency-domain analysis +\- Frequency-domain analysis -Explainable machine learning pipelines +\- Explainable machine learning pipelines -Installation -Local installation + +\## Installation + + + +\### Local installation + + + +```bash py -m pip install -e . -Future PyPI installation + + + + +\\### Future PyPI installation + + pip install spectralforensics -Supported Image Formats -The library currently supports: + +\\## Quick Start -JPG - -JPEG - -PNG - -BMP - -TIFF - -WEBP +\\### Extract Features from a Single Image -Additional formats can easily be added. +```python + +from spectralforensics import extract\\\_spectral\\\_features -Quick Start - -Extract features from a single image - -from spectralforensics import extract\_spectral\_features - - - -features = extract\_spectral\_features( - - "image.jpg" - -) +features = extract\\\_spectral\\\_features("image.jpg") print(features) +``` -Example output: + +\### Example Output +```python + { - "filename": "image.jpg", +\ "filename": "image.jpg", - "spectral\_entropy": 2.31, +\ "spectral\\\_entropy": 2.31, - "anisotropy": 0.021, +\ "anisotropy": 0.021, - "dominant\_frequency": 12.7, +\ "dominant\\\_frequency": 12.7, - "energy\_density": 58210.3, +\ "energy\\\_density": 58210.3, - "high\_frequency\_ratio": 0.000091, +\ "high\\\_frequency\\\_ratio": 0.000091, - "mean\_energy": 58210.3 +\ "mean\\\_energy": 58210.3 } -Extract features from an entire folder - -from spectralforensics import extract\_features\_from\_folder +``` -df = extract\_features\_from\_folder( +\--- - folder\_path="dataset", - output\_csv="results.csv" + +\### Extract Features from an Entire Folder + + + +```python + +from spectralforensics import extract\\\_features\\\_from\\\_folder + + + +df = extract\\\_features\\\_from\\\_folder( + +\ folder\\\_path="dataset", + +\ output\\\_csv="results.csv" ) @@ -142,151 +152,21 @@ df = extract\_features\_from\_folder( print(df.head()) +``` -Example output: +\### Example Output -filename spectral\_entropy anisotropy dominant\_frequency energy\_density high\_frequency\_ratio -real\_001.jpg 1.21 0.012 11.0 91327 0.000037 +| filename | spectral\_entropy | anisotropy | dominant\_frequency | energy\_density | high\_frequency\_ratio | -dalle\_001.png 2.50 0.034 16.0 68150 0.000177 +|-----------|----------------|------------|-------------------|----------------|---------------------| -flux\_001.jpg 2.51 0.019 6.0 61004 0.000064 +| real\_001.jpg | 1.21 | 0.012 | 11.0 | 91327 | 0.000037 | -Spectral Features +| dalle\_001.png | 2.50 | 0.034 | 16.0 | 68150 | 0.000177 | -Spectral Entropy - - - -Measures the randomness of the spectral energy distribution. - - - -Higher values generally indicate a more dispersed frequency distribution. - - - -Anisotropy - - - -Measures directional imbalance of spectral energy. - - - -Can reveal artificial directional patterns introduced by generative models. - - - -Dominant Frequency - - - -Represents the strongest non-DC frequency component in the Fourier spectrum. - - - -Energy Density - - - -Measures the amount of spectral energy normalized by image size. - - - -High Frequency Ratio - - - -Measures the proportion of energy located in high-frequency regions. - - - -Useful for detecting residual artefacts and synthetic textures. - - - -Scientific Background - - - -Diffusion-based generative models such as: - - - -Stable Diffusion - -FLUX - -DALL·E - -Midjourney - - - -generate images through iterative denoising processes. - - - -Although visually realistic, these models may introduce latent frequency-domain artefacts that remain detectable through Fourier analysis. - - - -SpectralForensics aims to provide an explainable framework for investigating these spectral fingerprints and supporting synthetic media detection research. - - - -Research Applications - - - -Potential applications include: - - - -Digital Image Forensics - -Deepfake Detection - -AI-Generated Content Verification - -Synthetic Media Analysis - -Explainable AI (XAI) - -Frequency-Domain Machine Learning - -Cybersecurity Research - -Roadmap - - - -Future planned features: - - - -Radial Distribution Analysis - -Spectral Heatmaps - -Average FFT Fingerprints - -Statistical Validation (t-test, ANOVA, Mann–Whitney) - -Random Forest Classification - -SVM Classification - -XGBoost Classification - -Diffusion Model Attribution - -Batch Processing Pipelines - -S +| flux\_001.jpg | 2.51 | 0.019 | 6.0 | 61004 | 0.000064 | diff --git a/pyproject.toml b/pyproject.toml index c33d3f6..ced86e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,34 +1,37 @@ [build-system] -requires = ["setuptools>=61.0"] +requires = ["setuptools>=68", "wheel"] build-backend = "setuptools.build_meta" [project] name = "spectralforensics" version = "0.1.0" -description = "Spectral feature extraction for image forensic analysis using FFT" +description = "Explainable spectral forensic analysis" readme = "README.md" requires-python = ">=3.10" authors = [ - {name = "Jose Garcia"} + { name = "José Garcia" }, + { name = "Patricio Rodrigues" }, + { name = "Carlos Grilo" }, + { name = "Rolando Miragaia" } +] + +maintainers = [ + { name = "José Garcia", email = "2023144112@my.ipleiria.pt" } ] dependencies = [ "numpy", + "pillow", "pandas", - "pillow" + "scipy", + "matplotlib", + "scikit-image" ] -keywords = [ - "fft", - "image forensics", - "deepfake detection", - "frequency analysis", - "spectral fingerprints" -] +[tool.setuptools] +package-dir = {"" = "src"} -classifiers = [ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent" -] \ No newline at end of file +[tool.setuptools.packages.find] +where = ["src"] +include = ["spectralforensics*"] \ No newline at end of file diff --git a/spectralforensics.egg-info/PKG-INFO b/spectralforensics.egg-info/PKG-INFO index bc79886..622c28c 100644 --- a/spectralforensics.egg-info/PKG-INFO +++ b/spectralforensics.egg-info/PKG-INFO @@ -1,14 +1,186 @@ Metadata-Version: 2.4 Name: spectralforensics Version: 0.1.0 -Summary: Spectral feature extraction for image forensic analysis using FFT -Author: Jose Garcia -Keywords: fft,image forensics,deepfake detection,frequency analysis,spectral fingerprints -Classifier: Programming Language :: Python :: 3 -Classifier: License :: OSI Approved :: MIT License -Classifier: Operating System :: OS Independent +Summary: Explainable spectral forensic analysis +Author: José Garcia, Patricio Rodrigues, Carlos Grilo, Rolando Miragaia +Maintainer-email: José Garcia <2023144112@my.ipleiria.pt> Requires-Python: >=3.10 Description-Content-Type: text/markdown Requires-Dist: numpy -Requires-Dist: pandas Requires-Dist: pillow +Requires-Dist: pandas +Requires-Dist: scipy +Requires-Dist: matplotlib + +\# SpectralForensics + + + +SpectralForensics is an open-source Python library for image forensic analysis using \*\*Fast Fourier Transform (FFT)\*\* and frequency-domain feature extraction. + + + +The library was designed to support research in digital image forensics, synthetic media detection, diffusion model analysis, and explainable artificial intelligence (XAI). + + + +\## Features + + + +SpectralForensics extracts a set of interpretable spectral descriptors from images: + + + +\- Spectral Entropy + +\- Anisotropy + +\- Dominant Frequency + +\- Energy Density + +\- High Frequency Ratio + +\- Mean Spectral Energy + + + +These descriptors can be used for: + + + +\- AI-generated image detection + +\- Deepfake forensics + +\- Diffusion model fingerprinting + +\- Frequency-domain analysis + +\- Explainable machine learning pipelines + + + +\## Installation + + + +\### Local installation + + + +```bash + +py -m pip install -e . + + + + + +\\### Future PyPI installation + + + +pip install spectralforensics + + + + + +\\## Quick Start + + + +\\### Extract Features from a Single Image + + + +```python + +from spectralforensics import extract\\\_spectral\\\_features + + + +features = extract\\\_spectral\\\_features("image.jpg") + + + +print(features) + +``` + + + +\### Example Output + + + +```python + +{ + +\ "filename": "image.jpg", + +\ "spectral\\\_entropy": 2.31, + +\ "anisotropy": 0.021, + +\ "dominant\\\_frequency": 12.7, + +\ "energy\\\_density": 58210.3, + +\ "high\\\_frequency\\\_ratio": 0.000091, + +\ "mean\\\_energy": 58210.3 + +} + +``` + + + +\--- + + + +\### Extract Features from an Entire Folder + + + +```python + +from spectralforensics import extract\\\_features\\\_from\\\_folder + + + +df = extract\\\_features\\\_from\\\_folder( + +\ folder\\\_path="dataset", + +\ output\\\_csv="results.csv" + +) + + + +print(df.head()) + +``` + + + +\### Example Output + + + +| filename | spectral\_entropy | anisotropy | dominant\_frequency | energy\_density | high\_frequency\_ratio | + +|-----------|----------------|------------|-------------------|----------------|---------------------| + +| real\_001.jpg | 1.21 | 0.012 | 11.0 | 91327 | 0.000037 | + +| dalle\_001.png | 2.50 | 0.034 | 16.0 | 68150 | 0.000177 | + +| flux\_001.jpg | 2.51 | 0.019 | 6.0 | 61004 | 0.000064 | + diff --git a/spectralforensics.egg-info/SOURCES.txt b/spectralforensics.egg-info/SOURCES.txt index 1c64013..dd7ba28 100644 --- a/spectralforensics.egg-info/SOURCES.txt +++ b/spectralforensics.egg-info/SOURCES.txt @@ -1,8 +1,5 @@ README.md pyproject.toml -spectralforensics/__init__.py -spectralforensics/dataset.py -spectralforensics/features.py spectralforensics.egg-info/PKG-INFO spectralforensics.egg-info/SOURCES.txt spectralforensics.egg-info/dependency_links.txt diff --git a/spectralforensics.egg-info/requires.txt b/spectralforensics.egg-info/requires.txt index 04ca854..a4e1c1e 100644 --- a/spectralforensics.egg-info/requires.txt +++ b/spectralforensics.egg-info/requires.txt @@ -1,3 +1,5 @@ numpy -pandas pillow +pandas +scipy +matplotlib diff --git a/spectralforensics.egg-info/top_level.txt b/spectralforensics.egg-info/top_level.txt index e48e3a1..8b13789 100644 --- a/spectralforensics.egg-info/top_level.txt +++ b/spectralforensics.egg-info/top_level.txt @@ -1 +1 @@ -spectralforensics + diff --git a/spectralforensics/__init__.py b/spectralforensics/__init__.py deleted file mode 100644 index c186524..0000000 --- a/spectralforensics/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from .features import extract_spectral_features -from .dataset import extract_features_from_folder - -__version__ = "0.1.0" \ No newline at end of file diff --git a/spectralforensics/dataset.py b/spectralforensics/dataset.py deleted file mode 100644 index 3e28b57..0000000 --- a/spectralforensics/dataset.py +++ /dev/null @@ -1,32 +0,0 @@ -from pathlib import Path -import pandas as pd -from .features import extract_spectral_features -SUPPORTED_EXTENSIONS = {".jpg", ".jpeg", ".png", ".bmp", ".tif", ".tiff", ".webp"} - -def extract_features_from_folder(folder_path,output_csv=None,image_size=(512, 512),high_freq_threshold=0.65): - folder_path = Path(folder_path) - if not folder_path.exists(): - raise FileNotFoundError(f"Folder not found: {folder_path}") - image_files = [ - file for file in folder_path.iterdir() - if file.suffix.lower() in SUPPORTED_EXTENSIONS - ] - results = [] - for image_file in image_files: - try: - features = extract_spectral_features( - image_file, - image_size=image_size, - high_freq_threshold=high_freq_threshold - ) - results.append(features) - except Exception as e: - results.append({ - "filename": image_file.name, - "path": str(image_file), - "error": str(e) - }) - df = pd.DataFrame(results) - if output_csv: - df.to_csv(output_csv, index=False, encoding="utf-8-sig") - return df \ No newline at end of file diff --git a/spectralforensics/features.py b/spectralforensics/features.py deleted file mode 100644 index bda667e..0000000 --- a/spectralforensics/features.py +++ /dev/null @@ -1,44 +0,0 @@ -from pathlib import Path -import numpy as np -from PIL import Image - - -def extract_spectral_features(image_path,image_size=(512, 512), high_freq_threshold=0.65, center_exclusion=5): - image_path = Path(image_path) - img = Image.open(image_path).convert("L") - img = img.resize(image_size) - img_array = np.array(img, dtype=np.float32) / 255.0 - fft = np.fft.fft2(img_array) - fft_shift = np.fft.fftshift(fft) - magnitude = np.abs(fft_shift) - energy = magnitude ** 2 - total_energy = np.sum(energy) + 1e-12 - mean_energy = np.mean(energy) - probability = energy / total_energy - spectral_entropy = -np.sum(probability * np.log2(probability + 1e-12)) - h, w = energy.shape - cy, cx = h // 2, w // 2 - y, x = np.indices((h, w)) - radius = np.sqrt((x - cx) ** 2 + (y - cy) ** 2) - horizontal_energy = np.sum(energy[cy - 2:cy + 3, :]) - vertical_energy = np.sum(energy[:, cx - 2:cx + 3]) - anisotropy = abs(horizontal_energy - vertical_energy) / (horizontal_energy + vertical_energy + 1e-12) - energy_no_center = energy.copy() - energy_no_center[cy - center_exclusion:cy + center_exclusion + 1,cx - center_exclusion:cx + center_exclusion + 1] = 0 - dominant_position = np.unravel_index(np.argmax(energy_no_center),energy_no_center.shape) - dominant_frequency = radius[dominant_position] - energy_density = total_energy / (h * w) - max_radius = np.max(radius) - high_freq_mask = radius > (high_freq_threshold * max_radius) - high_frequency_energy = np.sum(energy[high_freq_mask]) - high_frequency_ratio = high_frequency_energy / total_energy - return { - "filename": image_path.name, - "path": str(image_path), - "spectral_entropy": float(spectral_entropy), - "anisotropy": float(anisotropy), - "dominant_frequency": float(dominant_frequency), - "energy_density": float(energy_density), - "high_frequency_ratio": float(high_frequency_ratio), - "mean_energy": float(mean_energy) - } \ No newline at end of file diff --git a/src/spectralforensics.egg-info/PKG-INFO b/src/spectralforensics.egg-info/PKG-INFO new file mode 100644 index 0000000..5ed4716 --- /dev/null +++ b/src/spectralforensics.egg-info/PKG-INFO @@ -0,0 +1,187 @@ +Metadata-Version: 2.4 +Name: spectralforensics +Version: 0.1.0 +Summary: Explainable spectral forensic analysis +Author: José Garcia, Patricio Rodrigues, Carlos Grilo, Rolando Miragaia +Maintainer-email: José Garcia <2023144112@my.ipleiria.pt> +Requires-Python: >=3.10 +Description-Content-Type: text/markdown +Requires-Dist: numpy +Requires-Dist: pillow +Requires-Dist: pandas +Requires-Dist: scipy +Requires-Dist: matplotlib +Requires-Dist: scikit-image + +\# SpectralForensics + + + +SpectralForensics is an open-source Python library for image forensic analysis using \*\*Fast Fourier Transform (FFT)\*\* and frequency-domain feature extraction. + + + +The library was designed to support research in digital image forensics, synthetic media detection, diffusion model analysis, and explainable artificial intelligence (XAI). + + + +\## Features + + + +SpectralForensics extracts a set of interpretable spectral descriptors from images: + + + +\- Spectral Entropy + +\- Anisotropy + +\- Dominant Frequency + +\- Energy Density + +\- High Frequency Ratio + +\- Mean Spectral Energy + + + +These descriptors can be used for: + + + +\- AI-generated image detection + +\- Deepfake forensics + +\- Diffusion model fingerprinting + +\- Frequency-domain analysis + +\- Explainable machine learning pipelines + + + +\## Installation + + + +\### Local installation + + + +```bash + +py -m pip install -e . + + + + + +\\### Future PyPI installation + + + +pip install spectralforensics + + + + + +\\## Quick Start + + + +\\### Extract Features from a Single Image + + + +```python + +from spectralforensics import extract\\\_spectral\\\_features + + + +features = extract\\\_spectral\\\_features("image.jpg") + + + +print(features) + +``` + + + +\### Example Output + + + +```python + +{ + +\ "filename": "image.jpg", + +\ "spectral\\\_entropy": 2.31, + +\ "anisotropy": 0.021, + +\ "dominant\\\_frequency": 12.7, + +\ "energy\\\_density": 58210.3, + +\ "high\\\_frequency\\\_ratio": 0.000091, + +\ "mean\\\_energy": 58210.3 + +} + +``` + + + +\--- + + + +\### Extract Features from an Entire Folder + + + +```python + +from spectralforensics import extract\\\_features\\\_from\\\_folder + + + +df = extract\\\_features\\\_from\\\_folder( + +\ folder\\\_path="dataset", + +\ output\\\_csv="results.csv" + +) + + + +print(df.head()) + +``` + + + +\### Example Output + + + +| filename | spectral\_entropy | anisotropy | dominant\_frequency | energy\_density | high\_frequency\_ratio | + +|-----------|----------------|------------|-------------------|----------------|---------------------| + +| real\_001.jpg | 1.21 | 0.012 | 11.0 | 91327 | 0.000037 | + +| dalle\_001.png | 2.50 | 0.034 | 16.0 | 68150 | 0.000177 | + +| flux\_001.jpg | 2.51 | 0.019 | 6.0 | 61004 | 0.000064 | + diff --git a/src/spectralforensics.egg-info/SOURCES.txt b/src/spectralforensics.egg-info/SOURCES.txt new file mode 100644 index 0000000..266539e --- /dev/null +++ b/src/spectralforensics.egg-info/SOURCES.txt @@ -0,0 +1,15 @@ +README.md +pyproject.toml +spectralforensics.egg-info/PKG-INFO +spectralforensics.egg-info/SOURCES.txt +spectralforensics.egg-info/dependency_links.txt +spectralforensics.egg-info/requires.txt +spectralforensics.egg-info/top_level.txt +src/spectralforensics/__init__.py +src/spectralforensics/dataset.py +src/spectralforensics/features.py +src/spectralforensics.egg-info/PKG-INFO +src/spectralforensics.egg-info/SOURCES.txt +src/spectralforensics.egg-info/dependency_links.txt +src/spectralforensics.egg-info/requires.txt +src/spectralforensics.egg-info/top_level.txt \ No newline at end of file diff --git a/src/spectralforensics.egg-info/dependency_links.txt b/src/spectralforensics.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/src/spectralforensics.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/src/spectralforensics.egg-info/requires.txt b/src/spectralforensics.egg-info/requires.txt new file mode 100644 index 0000000..31ffe60 --- /dev/null +++ b/src/spectralforensics.egg-info/requires.txt @@ -0,0 +1,6 @@ +numpy +pillow +pandas +scipy +matplotlib +scikit-image diff --git a/src/spectralforensics.egg-info/top_level.txt b/src/spectralforensics.egg-info/top_level.txt new file mode 100644 index 0000000..e48e3a1 --- /dev/null +++ b/src/spectralforensics.egg-info/top_level.txt @@ -0,0 +1 @@ +spectralforensics diff --git a/src/spectralforensics/__init__.py b/src/spectralforensics/__init__.py new file mode 100644 index 0000000..78f4077 --- /dev/null +++ b/src/spectralforensics/__init__.py @@ -0,0 +1,3 @@ +from .dataset import extract_features + +__all__ = ["extract_features"] \ No newline at end of file diff --git a/src/spectralforensics/__pycache__/__init__.cpython-312.pyc b/src/spectralforensics/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b6bd92b2c54f3a0dd7716eea05ffea7f8e4dc186 GIT binary patch literal 253 zcmX@j%ge<81ltVav)qC7V-N=hn4pZ$VnD`ph7^Vr#vF!R#wbQch7_iB#weyrW=)ot zj6g|E##;iZ6(vQ9$tCe=sfi_}MXAL_%s>f0P3BwdDTyVC#i=D=fm`hH@rgM(@$oAe zK7)+^ zi)eg&W?p7Ve7s&k>Fs0zl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lSPO2%jO G!~TD?*b6iO literal 0 HcmV?d00001 diff --git a/src/spectralforensics/__pycache__/features.cpython-312.pyc b/src/spectralforensics/__pycache__/features.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ec91699fbe1924c6bdb53b5bd08316d76b4d0511 GIT binary patch literal 10962 zcmcIpeM}qKcDIeO0ULq|25f9>AmJ-4B;g}K5)wlA43LlA7ZSq8YnTCS{6S{M1lVhm zR$a+a|5)-@K)bJD)v62KNK4d6$y1-yL`s!J-D+n#mh7E+)hD(8Z2#KrTeVXEY0n*d zJVWG?-M4ub%sKbmd(S!d+}}NS?wxzQ>0HQ z2n9SdLCT*JLkB$>V5s22GFC!(==tgFl;@Zj;Xe!hfB)Q!N5QDE5dV{Op$iy;Bqg$t z>J!zkclXVgYGtbED_hjQ-j~@Y_3#!-oJ{4Bd-uyyi6gQl|HC?@^Fq{K{~@*9f+>}1 zy=4+7Q>0@`q>|SvaWZ|N`yz!hg`N!U2)$%+1tJ#KLtJgL7Kz()#&U=pl(VR!vWVPp zZXlP)OO*^z(h#a}Zf2bdWTf$eatY(7S>ZgSCGr-My5g7VWy;>;bMi2I=Q#Rq2j&u$jAtrnL|=9h0aDvCR1cq=xmbZ5-01Fyd;WO zpfX&7%-+LNE16CLHp8XiGE_>KS1@luWhu_8@Z_l6L*h^=Dx1+LyvYzL*&ESLdDy1V z*(zz0DY7B!3S?{WAP2HnIkLzlJPK({zhKVns9;S)4Incr5!YFT!lO*_R@S%6o=P05 zNXA$4Yy~o^A|`vzkU69!HCCCDCf#{_3$#JO;=E6dhiV;fXnvY<;6RM9i zGa3st`l%j;op16dsdblE*8kV5GGu+-tDoslC37%6MklHiN1xi!5H3SyGXCORRsqIO zO6_GT?I+>tU4C0omNJ^*1I(^?LM_%_ri^O%;4Tf;*EG~9G{D$1YN&;ItVRdW!H+bk z2G!yjIstYRaqpHrmpDc3X-OtiR4t(oRcBh`5?;b}$d2kT9>Vpg1g~F=Rxxr73JV>w zW{E>~$w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b%2EL-cUU{_=eP@ENz4n74+xEWtM^$$Ib@hK5RT$$n z_pfhU=k4zRsBMnT`i=9k@)oYV<4MBjzcj=Gv{aq%wb5qRPJQQ7A`fru$rn*P-Lz4VnrLvvTfZmGcSVaq0(ZW}> zMb5ugf_*Q@RrS4WW+&&l;dwSdbHg-O$;6z9bE0VY7U*164`Q8|fX>Px4PL;GBQZxC z=V;>{$3$m$7pvRYjzO+^kR5%W{a}F`U0~@YZgh#OS_XYpXRtbW{-{#*YWg%F>eY;5 z875$&Y79(Nq$Y7I@N$y%E`G04jcTrIfP^#ySO({bpZfys#>6D7rlc{opb{Td$$&fe|0G|MV69{rjo!@F7#YzNz0Q=<)H==b1{L z*0Td4|H3kL78(dy7luZXNAP@l+Ox3S1ZN|BmnEK26{px@dR~+_!7&m}pmY=E4$O;3 zTA@g)@&~B}IHm^SL?j+_@vG#vin@;-`876{a{?}CLO!ya+JYj!IHH~K_&!UmR)4E1 g`xjNww<`0$s=7H<_qVFLZ&lSl>P9r`{i25d1A7g+(*OVf literal 0 HcmV?d00001 diff --git a/src/spectralforensics/__pycache__/features.cpython-314.pyc b/src/spectralforensics/__pycache__/features.cpython-314.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8e66905775f5fa2d7e316c4951be5d78f7383b8f GIT binary patch literal 11787 zcmcIqYfKy0o*x^q0h@;b12#4`5S}5tAv_WsLU;xUaeD_sTwH?(Fc^C>V~0myS!q8w zyC0fXszTCU1yzwsqg<7C(@l2oU2P&oN-E{5 zbGlhxggGUiY_qfitIhZhO;s!5QYUSmr3t8{jjY-hiP{t{Yn8A&Y%c49!|5R?E{%52 z5l$}K>vAl(snsYM2FMAQhjNn}2*mE7SLV~A(xV~|{!-xYd!`tz#3DgN^ue*VXr06? zh=c#&sRDIUj1ui_iL_*xFsTKQTo)Y|x(3Rei;GmvWkJ?}qpeU~O#HAMOT z4=xwQEQ0oO+yaZIWh@&CiBh=!kf~4jgF%VgZt0$WT?s&Nd-c1&f#dy)I zv|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XVyI(XwGH1{g2KbiV?ifJ%0C(XeI zGc&cwEN=#Mip^EJi`A2 D+t5m0 literal 0 HcmV?d00001 diff --git a/src/spectralforensics/dataset.py b/src/spectralforensics/dataset.py new file mode 100644 index 0000000..aee69d9 --- /dev/null +++ b/src/spectralforensics/dataset.py @@ -0,0 +1,28 @@ +from pathlib import Path +import pandas as pd +from .features import extract_features as extract_image_features +from tqdm import tqdm + +support_ext = {".jpg", ".jpeg", ".png", ".bmp", ".tif", ".tiff", ".webp"} + +def extract_features(path, output_csv=None, image_size=(255, 255), high_freq_threshold=0.65, output="all", show_progress=True): + path = Path(path) + if not path.exists(): + raise FileNotFoundError(f"Path not found: {path}") + if path.is_file(): + if path.suffix.lower() not in support_ext: + raise ValueError(f"Unsupported image format: {path.suffix}") + return extract_image_features(path, image_size=image_size, high_freq_threshold=high_freq_threshold, output=output) + image_files = [file for file in path.iterdir() if file.is_file() and file.suffix.lower() in support_ext] + iterator = (tqdm(image_files,total=len(image_files),desc="Extracting features",unit="image") if show_progress else image_files) + results = [] + for image_file in iterator: + try: + features = extract_image_features(image_file, image_size=image_size, high_freq_threshold=high_freq_threshold, output=output) + results.append(features) + except Exception as e: + results.append({"filename": image_file.name, "path": str(image_file), "error": str(e)}) + df = pd.DataFrame(results) + if output_csv: + df.to_csv(output_csv, index=False, encoding="utf-8-sig") + return df \ No newline at end of file diff --git a/src/spectralforensics/features.py b/src/spectralforensics/features.py new file mode 100644 index 0000000..d50388f --- /dev/null +++ b/src/spectralforensics/features.py @@ -0,0 +1,148 @@ +from pathlib import Path +import numpy as np +from PIL import Image +from scipy.ndimage import median_filter, sobel, uniform_filter +from skimage.filters.rank import entropy +from skimage.morphology import disk + + +def extract_features(image_path, image_size=(255, 255), high_freq_threshold=0.65, center_exclusion=5, output="all"): + image_path = Path(image_path) + output = str(output).lower() + valid_outputs = {"all", "spectral", "spatial", "residual", "quantitative", "visual"} + if output not in valid_outputs: + raise ValueError("output must be one of: 'all', 'spectral', 'spatial', 'residual', 'quantitative', 'visual'") + if not image_path.exists(): + raise FileNotFoundError(f"Image not found: {image_path}") + if not image_path.is_file(): + raise ValueError(f"Expected an image file: {image_path}") + image = Image.open(image_path).convert("L") + image = image.resize(image_size) + img_array = np.asarray(image, dtype=np.float32) / np.float32(255.0) + filename_lower = image_path.name.lower() + if "gen" in filename_lower: + target = "0" + elif "real" in filename_lower: + target = "1" + else: + target = None + results = {"filename": image_path.name,"path": str(image_path),"target": target} + calculate_spectral = output in {"all", "spectral", "quantitative", "visual"} + calculate_spatial = output in {"all", "spatial", "quantitative", "visual"} + calculate_residual = output in {"all", "residual", "quantitative", "visual"} + return_spectral_values = output in {"all", "spectral", "quantitative"} + return_spatial_values = output in {"all", "spatial", "quantitative"} + return_residual_values = output in {"all", "residual", "quantitative"} + return_visual_maps = output in {"all", "visual"} + if calculate_spectral: + fft = np.fft.fft2(img_array) + fft_shift = np.fft.fftshift(fft) + magnitude = np.abs(fft_shift).astype(np.float32) + energy = np.square(magnitude, dtype=np.float32) + total_energy = float(np.sum(energy, dtype=np.float64)) + 1e-12 + height, width = energy.shape + center_y = height // 2 + center_x = width // 2 + y_indices, x_indices = np.indices((height, width), dtype=np.float32) + radius = np.sqrt((x_indices - center_x) ** 2 + (y_indices - center_y) ** 2).astype(np.float32) + if return_spectral_values: + probability = energy / total_energy + spectral_entropy = -np.sum(probability * np.log2(probability + 1e-12), dtype=np.float64) + horizontal_energy = np.sum(energy[max(0, center_y - 2):min(height, center_y + 3), :], dtype=np.float64) + vertical_energy = np.sum(energy[:, max(0, center_x - 2):min(width, center_x + 3)], dtype=np.float64) + anisotropy = abs(horizontal_energy - vertical_energy) / (horizontal_energy + vertical_energy + 1e-12) + energy_no_center = energy.copy() + y_start = max(0, center_y - center_exclusion) + y_end = min(height, center_y + center_exclusion + 1) + x_start = max(0, center_x - center_exclusion) + x_end = min(width, center_x + center_exclusion + 1) + energy_no_center[y_start:y_end, x_start:x_end] = 0 + dominant_position = np.unravel_index(np.argmax(energy_no_center), energy_no_center.shape) + dominant_frequency = radius[dominant_position] + energy_density = total_energy / (height * width) + maximum_radius = np.max(radius) + high_frequency_mask = radius > high_freq_threshold * maximum_radius + high_frequency_energy = np.sum(energy[high_frequency_mask], dtype=np.float64) + high_frequency_ratio = high_frequency_energy / total_energy + mean_energy = np.mean(energy, dtype=np.float64) + results.update({ + "spectral_entropy": float(spectral_entropy), + "anisotropy": float(anisotropy), + "dominant_frequency": float(dominant_frequency), + "energy_density": float(energy_density), + "high_frequency_ratio": float(high_frequency_ratio), + "mean_energy": float(mean_energy)}) + del probability + del energy_no_center + if return_visual_maps: + fft_spectrum_raw = np.log1p(magnitude) + fft_minimum = fft_spectrum_raw.min() + fft_maximum = fft_spectrum_raw.max() + fft_spectrum = (255.0 * (fft_spectrum_raw - fft_minimum) / (fft_maximum - fft_minimum + 1e-12)).astype(np.uint8) + results["fft_spectrum"] = fft_spectrum + del fft_spectrum_raw + del fft + del fft_shift + del magnitude + del energy + del radius + del y_indices + del x_indices + if calculate_spatial: + gradient_x = sobel(img_array, axis=1, mode="reflect").astype(np.float32) + gradient_y = sobel(img_array, axis=0, mode="reflect").astype(np.float32) + gradient_raw = np.sqrt(gradient_x ** 2 + gradient_y ** 2).astype(np.float32) + local_mean = uniform_filter(img_array, size=7, mode="reflect").astype(np.float32) + local_squared_mean = uniform_filter(np.square(img_array, dtype=np.float32), size=7, mode="reflect").astype(np.float32) + local_variance_raw = np.maximum(local_squared_mean - local_mean ** 2, 0).astype(np.float32) + image_uint8 = (img_array * 255).astype(np.uint8) + local_entropy_raw = entropy(image_uint8, footprint=disk(3)).astype(np.float32) + if return_spatial_values: + results.update({ + "mean_brightness": float(np.mean(img_array, dtype=np.float64)), + "mean_darkness": float(np.mean(1.0 - img_array, dtype=np.float64)), + "mean_gradient": float(np.mean(gradient_raw, dtype=np.float64)), + "mean_local_entropy": float(np.mean(local_entropy_raw, dtype=np.float64)), + "mean_local_variance": float(np.mean(local_variance_raw, dtype=np.float64))}) + if return_visual_maps: + brightness_map = img_array.copy() + darkness_map = (1.0 - img_array).astype(np.float32) + gradient_minimum = gradient_raw.min() + gradient_maximum = gradient_raw.max() + gradient_map = ((gradient_raw - gradient_minimum) / (gradient_maximum - gradient_minimum + 1e-12)).astype(np.float32) + entropy_minimum = local_entropy_raw.min() + entropy_maximum = local_entropy_raw.max() + local_entropy_map = ((local_entropy_raw - entropy_minimum) / (entropy_maximum - entropy_minimum + 1e-12)).astype(np.float32) + variance_minimum = local_variance_raw.min() + variance_maximum = local_variance_raw.max() + local_variance_map = ((local_variance_raw - variance_minimum) / (variance_maximum - variance_minimum + 1e-12)).astype(np.float32) + results.update({"brightness_map": brightness_map,"darkness_map": darkness_map,"gradient_map": gradient_map,"local_entropy_map": local_entropy_map,"local_variance_map": local_variance_map}) + del gradient_x + del gradient_y + del gradient_raw + del local_mean + del local_squared_mean + del local_variance_raw + del local_entropy_raw + del image_uint8 + if calculate_residual: + denoised_image = median_filter(img_array, size=3).astype(np.float32) + residual_noise_raw = (img_array - denoised_image).astype(np.float32) + if return_residual_values: + results.update({ + "residual_noise_energy": float(np.mean(np.square(residual_noise_raw, dtype=np.float32), dtype=np.float64)), + "residual_noise_std": float(np.std(residual_noise_raw, dtype=np.float64)), + "residual_noise_mean_absolute": float(np.mean(np.abs(residual_noise_raw), dtype=np.float64))}) + if return_visual_maps: + residual_absolute = np.abs(residual_noise_raw).astype(np.float32) + residual_minimum = residual_absolute.min() + residual_maximum = residual_absolute.max() + residual_noise_display = np.sqrt((residual_absolute - residual_minimum) / (residual_maximum - residual_minimum + 1e-12)).astype(np.float32) + results.update({ + "residual_noise_raw": residual_noise_raw, + "residual_noise": residual_noise_display}) + del residual_absolute + del denoised_image + if not return_visual_maps: + del residual_noise_raw + return results \ No newline at end of file