Skip to content
tum-esiPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

PRISM-D

This repository is a compact PRNU-based tamper-detection demo for PRISM-D. Instead of using wavelets and other traditional denoisers, PRSIM-D uses the DoG-LCN residual representation for PRNU estimation, thereby reducing extraction time. Moreover, PRISM-D includes PCE gating for full frame injection attack detection and MSF tamper localization algorithm to localize the exact tamper area.

The pipeline has two phases:

  • offline: builds per-camera artifacts, including a PRNU fingerprint, PCE threshold, q-hat predictors, and sigma estimates.
  • online: runs a full-frame PCE gate first. If the query is rejected by PCE, the output is an all-white mask. If the query passes PCE, the code runs MSF tamper localization and writes a binary mask.

Current Demo Setup

Data

Available Soon

Code Layout

The main implementation lives in these files:

  • main.py: CLI entry point and offline / online orchestration.
  • helper.py: dataset discovery, image listing, JSON I/O, model loading, and other small I/O helpers.
  • prnu.py: grayscale image loading, DoG-LCN residual extraction, and PRNU fingerprint estimation.
  • pce.py: normalized cross-correlation, PCE scoring, PCE calibration, and PCE gate decision.
  • predictor.py: q-hat predictor training, various feature grids calcualtions, ridge fitting, and sigma estimation.
  • msf.py: multi-scale fusion tamper localization and final binary mask generation.

Installation

Create a virtual environment and install the Python dependencies:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Dependencies are listed in requirements.txt:

numpy
opencv-python
scipy
scikit-learn
PyWavelets
PyMaxflow

Run Offline

Build artifacts for all discovered protected cameras with default path:

python3 main.py offline

Build artifacts for one camera, and specified the path to dataset and artifacts:

python3 main.py offline --camera CAM_FRONT --data-root Image_Database/nuscenes --out artifacts

Each camera writes:

artifacts/<CAMERA>/
|-- fingerprint.npy
|-- fingerprint.png
|-- predictor_w64.npz
|-- predictor_w128.npz
|-- predictor_w256.npz
|-- sigma.json
|-- pce_calibration.json
`-- model.json

model.json is the online phase entry point for a camera. It records the artifact paths and the DoG-LCN, PCE, predictor, and MSF parameters used to build the model.

Run Online

Run online inference for all discovered cameras with default path::

python3 main.py online

Run online inference for one camera, and specified the path to dataset and artifacts::

python3 main.py online --camera CAM_FRONT_LEFT --data-root Image_Database/nuscenes --artifact-root artifacts --out outputs

Each query writes:

outputs/<CAMERA>/<image_name>/
|-- tamper_mask.png
`-- decision.json

decision.json records the PCE score, PCE threshold, PCE gate decision, final decision, mask type, sigma values, MSF windows, graph-cut usage, and parameter snapshots.

Online Decision Logic

For each query image:

  1. Preprocess each query image.
  2. Extract a DoG-LCN residual representation.
  3. Compute PCE between the query residual and the camera fingerprint.
  4. If PCE < tau, return rejected_by_pce and write an all-white mask.
  5. If PCE >= tau, run MSF tamper localization.
  6. If the MSF mask has no foreground pixels, the final decision is authentic; otherwise it is tampered.

Current Online Query Images Behavior

CAM_FRONT demonstrates local tamper localization. Its query images pass the PCE gate and are localized by MSF.

CAM_FRONT_LEFT demonstrates PCE gate behavior:

  • Genuine CAM_FRONT_LEFT clean queries should pass PCE and produce all-black MSF masks, meaning "authentic".
  • Foreign CAM_BACK clean queries should be rejected by PCE and produce all-white masks, meaning "full frame injection".

Notes

  • The code requires at least two protected camera folders for offline calibration because each camera uses another discovered camera as the impostor source for sigma0 and PCE threshold calibration.
  • The current dataset is small and curated for demo behavior. It is not a full benchmark reproduction.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages