diff --git a/algorithms/context-adaptive_interpolator.py b/algorithms/context-adaptive_interpolator.py index b2fc477..399f275 100644 --- a/algorithms/context-adaptive_interpolator.py +++ b/algorithms/context-adaptive_interpolator.py @@ -1,14 +1,17 @@ +# Based on https://web.archive.org/web/20231116015653/http://nrl.northumbria.ac.uk/id/eprint/29339/1/Paper_accepted.pdf + from PIL import Image -from statistics import mean +from statistics import mean, median # What about other color channels? image = Image.open('9f04e2005fddb9d5512e2f42a3b826b019755717.jpg').convert('L') -newI = image.load() +r = image.load() I = image.copy().load() DEFAULT_COLOR = 255 # This threshold is debatable. THRESHOLD = 20 # How to manage the border of the image? +# Equation (10) for m in range(1, image.size[0] - 1): for n in range(1, image.size[1] - 1): e = I[m, n + 1] @@ -21,6 +24,30 @@ for m in range(1, image.size[0] - 1): ne = I[m - 1, n + 1] A = [e, se, s, sw, w, nw, no, ne] if max(A) - min(A) <= THRESHOLD: - newI[m, n] = int(round(I[m, n] - mean(A), 0)) + newPixel = I[m, n] - mean(A) + elif abs(e - w) - abs(no - s) > THRESHOLD: + newPixel = I[m, n] - (s + no) / 2 + elif abs(s - no) - abs(e - w) > THRESHOLD: + newPixel = I[m, n] - (e + w) / 2 + elif abs(sw - ne) - abs(se - nw) > THRESHOLD: + newPixel = I[m, n] - (se + nw) / 2 + elif abs(se - nw) - abs(sw - ne) > THRESHOLD: + newPixel = I[m, n] - (sw + ne) / 2 + else: + newPixel = I[m, n] - median(A) + r[m, n] = round(newPixel) + +Q = 3 + +def wienerFilter(): + # Equation (7) + hw[i, j] = h[i, j] * sigma(i, j) / (sigma(i, j) + sigma_0 ** 2) + +def sigma(i, j): + # Equation (9) + return sigma_q(i, j, Q) + +def sigma_q(i, j, q): + # Equation image.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 80a2622..32dcb35 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 @@ -699,22 +699,19 @@ and considered here? 234.01365124 56.90404704 298.47858791 56.90404704 48.39965160 68.06617103 292.04445111 68.06617103 48.80500548 78.49465807 63.32163914 79.14757222 - 94.00552071 80.22668418 213.89141267 80.22668418 - 240.42370680 80.50878333 294.98619459 80.50878333 - 49.91912143 91.68787530 109.00987130 91.68787530 - 124.66186592 101.93477910 124.66186592 117.71048868 234.42102061 117.71048868 234.42102061 101.93477910 124.66186592 101.93477910 + 94.00552071 80.22668418 213.89141267 80.22668418 + 240.42370680 80.50878333 294.98619459 80.50878333 + 49.91912143 91.68787530 109.00987130 91.68787530 + 124.66186592 101.93477910 124.66186592 117.71048868 234.42102061 117.71048868 234.42102061 101.93477910 124.66186592 101.93477910 68.47389354 129.24359993 187.07496247 129.24359993 - 200.54845048 129.63017707 204.79511423 126.67785163 - 239.35741128 127.06747783 270.20461967 127.06747783 - 47.90201170 138.03103337 65.97986726 139.76853746 - 105.20931531 138.45301071 162.92163797 138.45301071 - 181.47051328 139.65138087 238.59035193 139.65138087 - 47.45419049 151.33026173 73.89024898 151.33026173 - 142.72968280 151.18164977 297.64924626 151.18164977 - 48.52801825 161.95356187 265.31657741 161.95356187 - 117.99112359 174.92225050 291.80041063 174.92225050 - 47.90409179 185.51778172 106.48776344 185.51778172 - 135.37302059 186.22120361 289.07569919 186.22120361 + 200.54845048 129.63017707 204.79511423 126.67785163 + 239.35741128 127.06747783 270.20461967 127.06747783 + 47.90201170 138.03103337 65.97986726 139.76853746 + 105.20931531 138.45301071 162.92163797 138.45301071 + 181.47051328 139.65138087 238.59035193 139.65138087 + 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 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 @@ -831,11 +828,11 @@ that way keep edge but smooth otherwise what happens if apply many times the filter? Get a single color image or only edges? ? Independent and identically distributed random variables - 360.62404437 56.50215566 412.62421835 56.50215566 - 503.93888999 56.74246362 563.85102495 56.74246362 - 314.16312679 67.89352828 377.15982828 67.89352828 - 326.73579824 79.29706273 566.05358802 79.29706273 - 314.14872554 92.91554753 396.99601563 92.91554753 + 360.62404437 56.50215566 412.62421835 56.50215566 + 503.93888999 56.74246362 563.85102495 56.74246362 + 314.16312679 67.89352828 377.15982828 67.89352828 + 326.73579824 79.29706273 566.05358802 79.29706273 + 314.14872554 92.91554753 396.99601563 92.91554753 385.42358496 72.64296108 503.46352239 72.64296108 why this value and what does it mean? 331.12401113 122.99908986 558.38174858 122.99908986 @@ -953,6 +950,12 @@ values, is it? 2 3 4 + ? + 135.37302059 186.22120361 289.07569919 186.22120361 + 141.05700684 150.30480957 234.35293524 150.30480957 + 104.65768433 161.09030151 263.06051594 161.09030151 + 240.77893066 150.39559937 297.05985950 150.39559937 + 50.38613892 162.83441162 91.31531997 162.83441162