From 739317fa634e32a653ad57999f34b51e72e61a7e Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Thu, 21 Mar 2024 13:00:51 +0100 Subject: [PATCH] WIP: Context-Adaptive Interpolator (CAI) --- algorithms/context-adaptive_interpolator.py | 17 +++++++++++++---- ...: A Systematic Empirical Evaluation.xopp.xml | 8 +++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/algorithms/context-adaptive_interpolator.py b/algorithms/context-adaptive_interpolator.py index da3252f..6c7dc47 100644 --- a/algorithms/context-adaptive_interpolator.py +++ b/algorithms/context-adaptive_interpolator.py @@ -43,19 +43,28 @@ for m in range(1, IImage.size[0] - 1): r[m - 1, n - 1] = round(newPixel) Q = 3 +# $\sigma_0^2$ is the noise variance. +sigma_0 = sqrt(9) -def wienerFilter(): +# Wiener filter. +def h_w(i, j): # Equation (7) - hw[i, j] = h[i, j] * sigma(i, j) / (sigma(i, j) + sigma_0 ** 2) + return h[i, j] * sigma(i, j) / (sigma(i, j) + sigma_0 ** 2) +# Minimum of the considered variances. def sigma(i, j): # Equation (9) return sigma_q(i, j, Q) +def getPixelIndexesAround(i, numberOfPixelsInEachDirection): + return range(i - numberOfPixelsInEachDirection, i + numberOfPixelsInEachDirection) + +# Local variance obtained by Maximum A Posteriori (MAP). def sigma_q(i, j, q): # Equation (8) - # TODO: - pass + numberOfPixelsInEachDirection = (q - 1) // 2 + B_q = [(x, z) for x in getPixelIndexesAround(i, numberOfPixelsInEachDirection) for z in getPixelIndexesAround(j, numberOfPixelsInEachDirection)] + return max(0, (1 / q ** 2) * sum([h[x, z] ** 2 - sigma_0 ** 2 for (x, z) in B_q])) # Why need to rotate the image? See #14. rImage.rotate(-90).show() \ No newline at end of file diff --git a/articles/On the Sensor Pattern Noise Estimation in Image Forensics: A Systematic Empirical Evaluation/On the Sensor Pattern Noise Estimation in Image Forensics: A Systematic Empirical Evaluation.xopp.xml b/articles/On the Sensor Pattern Noise Estimation in Image Forensics: A Systematic Empirical Evaluation/On the Sensor Pattern Noise Estimation in Image Forensics: A Systematic Empirical Evaluation.xopp.xml index 32dcb35..3e832c8 100644 --- a/articles/On the Sensor Pattern Noise Estimation in Image Forensics: A Systematic Empirical Evaluation/On the Sensor Pattern Noise Estimation in Image Forensics: A Systematic Empirical Evaluation.xopp.xml +++ b/articles/On the Sensor Pattern Noise Estimation in Image Forensics: A Systematic Empirical Evaluation/On the Sensor Pattern Noise Estimation in Image Forensics: A Systematic Empirical Evaluation.xopp.xml @@ -712,10 +712,10 @@ and considered here? 47.45419049 151.33026173 73.89024898 151.33026173 117.99112359 174.92225050 291.80041063 174.92225050 47.90409179 185.51778172 106.48776344 185.51778172 - 79.84740241 197.12191732 180.26366418 197.12191732 + 79.84740241 197.12191732 180.26366418 197.12191732 91.25706084 205.78669895 91.25706084 233.33486307 257.24161221 233.33486307 257.24161221 205.78669895 91.25706084 205.78669895 - 74.52609696 243.52963985 94.17824960 241.75708008 - 124.26769196 243.44950274 264.89012007 243.44950274 + 74.52609696 243.52963985 94.17824960 241.75708008 + 124.26769196 243.44950274 264.89012007 243.44950274 45.89230932 257.64400315 82.97993299 254.67293541 122.83964251 257.92927196 169.60141510 257.92927196 208.12297469 255.97655874 294.58478097 255.97655874 @@ -956,6 +956,8 @@ values, is it? 104.65768433 161.09030151 263.06051594 161.09030151 240.77893066 150.39559937 297.05985950 150.39559937 50.38613892 162.83441162 91.31531997 162.83441162 + guess that no Wavelet coefficients are involved here +but only the image itself