29 Commits

Author SHA1 Message Date
5fa61f7ff8 Make PRNU compatible with 4x4 split 2024-03-29 11:23:48 +01:00
8351e46437 Comparison of an image without and with Gaussian noise and PRNU 2024-03-29 01:55:46 +01:00
2f66e82f22 Show both RMS and RMS normalized 2024-03-29 01:47:01 +01:00
3ccec5bbd0 Add RMS computation 2024-03-29 01:35:48 +01:00
f297060f42 Split images in 4x4 to increase PRNU estimation accuracy 2024-03-29 01:21:26 +01:00
9b57d3441c Render PRNU estimate taking into account all images 2024-03-29 01:10:31 +01:00
d59a251b1f Revert to some extent previous commit 2024-03-29 01:07:48 +01:00
4382b3d649 Add PRNU_FACTOR 0.1 and 0.01 view on a single figure 2024-03-29 01:05:28 +01:00
dfe2540c02 Apply Context-Adaptive Interpolator 2024-03-29 00:06:13 +01:00
9a3cfd7ba1 Add PRNU showing such 2024-03-28 22:24:16 +01:00
ba5a1b742b #24: Make executions reproducible 2024-03-28 22:20:40 +01:00
a99e942d3a Add datasets/noise_free_test_images/estimate_prnu.py 2024-03-28 17:06:58 +01:00
0953fb7475 Add issue reference to datasets/fake/generate_dataset.py 2024-03-28 17:06:36 +01:00
82e7026264 Add algorithms/image_utils/image_utils.py and move there randomGaussianImage and showImageWithMatplotlib 2024-03-28 16:32:38 +01:00
70ccb094d5 Rename randomImage to randomGaussianImage 2024-03-28 16:18:32 +01:00
64eaeddf98 Update annotations 2024-03-28 15:26:57 +01:00
18d34a3101 Add datasets/noise_free_test_images/no_noise_images.zip.txt 2024-03-28 15:25:21 +01:00
cbc778c4dc Move datasets/noise_free_test_images/noise_free_test_images.{pdf.txt,xopp.xml} to datasets/noise_free_test_images/webpage/ 2024-03-28 15:22:28 +01:00
5af7afaf75 Add datasets/noise_free_test_images/ 2024-03-28 15:03:57 +01:00
77d6c038fe Update annotations 2024-03-28 14:50:45 +01:00
69368a9057 Add articles/Law of large numbers - Wikipedia/ 2024-03-28 14:50:41 +01:00
abfc9772e8 Update annotations 2024-03-28 14:47:13 +01:00
d716574973 Update annotations 2024-03-26 18:23:30 +01:00
2093f2e613 Update annotations 2024-03-26 18:21:12 +01:00
9028d4d12c Add __pycache__ to .gitignore
Note that I do not precisely know if Pyzo or Python script shell execution generate `__pycache__`.
2024-03-26 18:21:01 +01:00
811b355989 Add articles/Shot noise - Wikipedia/ 2024-03-26 18:20:28 +01:00
cfe718da7d Make x-axis logarithmic 2024-03-26 02:32:03 +01:00
2bc13c5949 #21: Make a RMS curve depending on the number of images considered for the mean 2024-03-26 01:59:22 +01:00
c2862eaf43 #21: Incorrect mean, as it is a RMS mean, not a mean of images 2024-03-26 01:55:08 +01:00
14 changed files with 340 additions and 13 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
*.pdf
*.xopp
__pycache__

View File

@@ -6,6 +6,7 @@ from wiener_filter import wienerFilter
# Assume greyscale PIL image passed.
# What about other color channels? See #11.
# `THRESHOLD` seems to have been designed to assume 256 range based images.
def contextAdaptiveInterpolator(I, IImage, showProgress = False):
rImage = Image.new('L', (IImage.size[0] - 2, IImage.size[1] - 2))
r = rImage.load()

View File

@@ -14,5 +14,13 @@ def rmsDiffPil(im1, im2):
map(lambda h, i: h*(i**2), h, range(256))
) / (float(im1.size[0]) * im1.size[1]))
def rmsDiffNumpy(image0, image1):
def normalizeImage(image):
image = image - image.min()
image = image / image.max()
return image
def rmsDiffNumpy(image0, image1, normalize = False):
if normalize:
image0 = normalizeImage(image0)
image1 = normalizeImage(image1)
return np.sqrt(np.mean(np.square(image0 - image1)))

View File

@@ -0,0 +1,15 @@
from PIL import Image
import numpy as np
from matplotlib import pyplot as plt
def randomGaussianImage(scale, size):
return np.random.normal(loc = 0, scale = scale, size = size)
def showImageWithMatplotlib(npArray, title = None):
if title is not None:
plt.title(title)
plt.imshow(npArray)
plt.show()
def toPilImage(npArray):
return Image.fromarray(npArray)

View File

@@ -0,0 +1 @@
https://en.wikipedia.org/w/index.php?title=Law_of_large_numbers&oldid=1214684685

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" standalone="no"?>
<xournal creator="Xournal++ 1.1.3" fileversion="4">
<title>Xournal++ document - see https://github.com/xournalpp/xournalpp</title>
<page width="596.00000000" height="842.00000000">
<background type="pdf" domain="absolute" filename="/home/benjamin/Desktop/bens_folder/school/ens/asp/aria/internship/work/articles/Law of large numbers - Wikipedia/Law of large numbers - Wikipedia.pdf" pageno="1"/>
<layer>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">172.79332005 455.71986902 176.74788473 461.64321741</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">176.74788473 461.64321741 185.60032684 446.31033791</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">551.70618022 154.14224043 556.89385206 161.24116676</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">557.16641469 161.24116676 565.35602737 142.40508790</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">380.32310272 214.79667307 115.27752645 382.17214760</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">54.81231868 100.23162958 121.10611350 100.23162958</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">44.94156833 77.24209718 229.25613510 77.24209718</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">241.87676723 99.25463731 255.19612112 99.25463731</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">282.25762979 100.01803628 364.60489826 100.01803628</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">67.07284300 111.51919777 366.62676024 111.51919777</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">43.00099023 124.14875416 357.10161952 124.14875416</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">186.66547704 136.27102646 365.04606404 136.27102646</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">44.06579223 149.49702205 286.77048459 149.49702205</stroke>
</layer>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="2"/>
<layer/>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="3"/>
<layer/>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="4"/>
<layer/>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="5"/>
<layer/>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="6"/>
<layer/>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="7"/>
<layer/>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="8"/>
<layer/>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="9"/>
<layer/>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="10"/>
<layer/>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="11"/>
<layer/>
</page>
</xournal>

View File

@@ -0,0 +1 @@
https://en.wikipedia.org/w/index.php?title=Shot_noise&oldid=1210973018

View File

@@ -0,0 +1,111 @@
<?xml version="1.0" standalone="no"?>
<xournal creator="Xournal++ 1.1.3" fileversion="4">
<title>Xournal++ document - see https://github.com/xournalpp/xournalpp</title>
<page width="596.00000000" height="842.00000000">
<background type="pdf" domain="absolute" filename="/home/benjamin/Desktop/bens_folder/school/ens/asp/aria/internship/work/articles/Shot noise - Wikipedia/Shot noise - Wikipedia.pdf" pageno="1"/>
<layer>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">46.11154175 86.32046509 150.35152358 86.32046509</stroke>
<stroke tool="highlighter" color="#ff00007f" width="8.50000000" fill="128">127.45324707 116.81433105 200.04861869 116.81433105</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">78.01306400 132.47647418 254.63864121 132.47647418</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">169.41341684 160.67209108 303.27056261 160.67209108</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">47.40466685 177.72969763 162.33560428 177.72969763</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">235.26941037 177.45813474 302.79955883 177.45813474</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">47.64915140 193.41002363 303.37602767 193.41002363</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">260.11489192 207.76653791 44.85486037 207.76653791</stroke>
<text font="Sans" size="11.00000000" x="327.01944284" y="309.08399263" color="#00c0ffff" ts="0" fn="">so pixel or black?</text>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">328.65629476 277.60449072 502.30991623 277.60449072</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">519.69371999 291.55182641 330.19208155 291.55182641</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">326.95781155 305.28418629 524.57140525 305.28418629</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">67.09423681 269.80212503 168.61949049 269.80212503</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">215.60499276 270.06481466 307.72054223 270.06481466</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">67.99859807 285.73181932 106.17849107 285.73181932</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">211.27064832 284.39049036 281.11851124 284.39049036</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">189.00535807 306.61017621 301.13379781 306.61017621</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">47.56651777 322.75420432 199.59521732 322.75420432</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">289.46654265 364.52157976 392.58953849 364.52157976</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">424.26032361 365.22355284 547.10319361 365.22355284</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">47.01925345 381.43359155 548.32815761 381.43359155</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">45.66284913 397.20432388 202.52479214 397.20432388</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">44.36838564 424.34332408 169.17738859 424.34332408</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">282.64330743 426.96873001 546.79134851 426.96873001</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">48.50904320 441.01837181 80.50800279 441.01837181</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">207.55202066 439.18481794 246.98777059 441.61400340</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">301.21051378 449.25105599 323.03490551 449.25105599</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">434.06341346 448.50774316 476.11050162 448.50774316</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">425.87754889 512.42902313 552.42238033 512.42902313</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">44.67524665 529.10365815 550.78712902 529.10365815</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">44.76212201 544.86315560 511.52154545 544.86315560</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">526.29441305 538.25024176 552.02883643 538.25024176</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">44.88893849 555.01991461 174.03463657 555.01991461</stroke>
<stroke tool="pen" ts="0" fn="" color="#000000ff" width="1.41000000" fill="255">290.63859190 588.55877883 314.74527387 588.55877883</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">46.50521225 625.64681904 444.64200883 625.64681904</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">303.56511346 640.27596237 549.47878566 640.27596237</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">537.92131225 656.01232516 46.38337531 656.01232516</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">53.45846243 679.71771951 492.32045636 679.71771951</stroke>
<text font="Sans" size="11.00000000" x="362.81672248" y="683.55551806" color="#00c0ffff" ts="0" fn="">uniquement</text>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">47.10556707 716.64930841 200.39634201 716.64930841</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">211.03226270 723.63411941 410.12069510 723.63411941</stroke>
<stroke tool="pen" ts="0" fn="" color="#ff00ffff" width="1.41000000" fill="255">420.20141693 724.59194949 448.96595043 724.59194949</stroke>
<stroke tool="pen" ts="0" fn="" color="#000000ff" width="1.41000000" fill="255">453.45856103 723.28033562 552.49284040 723.28033562</stroke>
<stroke tool="pen" ts="0" fn="" color="#000000ff" width="1.41000000" fill="255">45.32520687 741.83387670 552.40812386 741.83387670</stroke>
<stroke tool="pen" ts="0" fn="" color="#000000ff" width="1.41000000" fill="255">45.14761566 757.00280973 152.41913671 757.00280973</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">166.53777136 749.27954670 551.05563429 749.27954670</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">45.46027753 765.43685030 175.30696655 765.43685030</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">185.83120895 771.31310054 420.29842273 771.31310054</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">450.78131420 764.48388103 552.05132785 764.48388103</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">46.86073859 782.32056856 549.40004325 782.32056856</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">46.17630567 799.83536558 326.61443210 799.83536558</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">430.34159877 799.99744579 549.45598233 799.99744579</stroke>
<text font="Sans" size="11.00000000" x="173.37040718" y="82.43216394" color="#00c0ffff" ts="0" fn="">example of generating Poisson noise?</text>
</layer>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="2"/>
<layer>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">46.94473645 83.82312021 159.02826360 83.82312021</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">47.74493440 106.39993738 358.84150350 106.39993738</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">46.24946990 123.26490028 95.03541660 123.26490028</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">46.03968734 155.13559251 358.58354595 155.13559251</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">45.89209782 171.99810209 136.50406601 171.99810209</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">74.95227243 225.57011697 74.95227243 250.76211403 174.99590959 250.76211403 174.99590959 225.57011697 74.95227243 225.57011697</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">197.37577259 169.44888693 360.89557240 169.44888693</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">90.40439299 187.31985228 339.71317253 187.31985228</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">45.29636306 203.96312138 139.23525650 203.96312138</stroke>
<text font="Sans" size="11.00000000" x="234.92328463" y="307.76575248" color="#00c0ffff" ts="0" fn="">?</text>
<stroke tool="pen" ts="0" fn="" color="#000000ff" width="1.41000000" fill="255">43.17994265 282.56787329 364.59659633 282.56787329</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">271.53114875 307.49055445 544.33799740 307.49055445</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">44.52646486 323.36324897 352.40420412 323.36324897</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">538.36492915 324.74195106 549.51146455 324.74195106</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">45.77901541 340.83512419 195.69395184 340.83512419</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">412.31054798 212.41133165 497.78366914 212.41133165</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">387.33932759 225.38077500 427.05427198 225.38077500</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">446.25494518 239.20996112 525.06844193 239.20996112</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">390.43487847 254.31210398 439.48051735 254.31210398</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">385.76075943 268.18013066 502.37680488 268.18013066</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">521.55384777 87.17784122 521.55384777 106.33948689 539.06360056 106.33948689 539.06360056 87.17784122 521.55384777 87.17784122</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">44.55310756 45.16262224 371.62378483 45.16262224</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">388.15745548 46.29871990 395.75530066 52.90615388</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">395.75530066 52.90615388 407.90469014 27.90090789</stroke>
</layer>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="3"/>
<layer/>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="4"/>
<layer/>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="5"/>
<layer/>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="6"/>
<layer/>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="7"/>
<layer/>
</page>
</xournal>

View File

@@ -21,6 +21,12 @@
<stroke tool="highlighter" color="#ff00007f" width="8.50000000" fill="128">78.66667086 411.37732832 172.83413256 411.37732832</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">182.94980638 411.63570950 294.96144099 411.63570950</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">78.08589681 419.59506323 154.70364562 419.59506323</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">201.73046875 190.98156738 295.14835752 190.98156738</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">77.83660889 203.19790649 95.32058716 202.45193481</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">103.98278809 201.52066040 298.68438360 201.52066040</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">78.63943481 212.82376099 103.41469363 212.82376099</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">154.10906982 212.40234375 294.61920570 212.40234375</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">79.34304810 223.27105713 254.63002133 223.27105713</stroke>
</layer>
</page>
<page width="612.00000000" height="792.00000000">

View File

@@ -1,3 +1,5 @@
# Notes: https://gitea.lemnoslife.com/Benjamin_Loison/Robust_image_source_identification_on_modern_smartphones/issues/21
import numpy as np
from matplotlib import pyplot as plt
from PIL import Image
@@ -10,6 +12,10 @@ from rms_diff import rmsDiffPil, rmsDiffNumpy
sys.path.insert(0, '../../algorithms/context_adaptive_interpolator/')
from context_adaptive_interpolator import contextAdaptiveInterpolator
sys.path.insert(0, '../../algorithms/image_utils/')
from image_utils import showImageWithMatplotlib, randomGaussianImage, toPilImage
from tqdm import tqdm
IMAGE_SIZE = 64
@@ -18,30 +24,38 @@ NUMBER_OF_IMAGES_PER_PHONE = 10_000
# Compared to images being 1.
PRNU_FACTOR = 0.1
IMAGE_SIZE_SHAPE = (IMAGE_SIZE, IMAGE_SIZE)
np.random.seed(0)
# Generate PRNUs and images of phones.
# Is such `np.maximum` probabilistically correct with our theoretical method? See #19.
def randomImage(scale):
return np.random.normal(loc = 0, scale = scale, size = (IMAGE_SIZE, IMAGE_SIZE))
imagesWithoutPrnu = [[randomGaussianImage(scale = 1, size = IMAGE_SIZE_SHAPE) for _ in range(NUMBER_OF_IMAGES_PER_PHONE)] for phoneIndex in range(NUMBER_OF_PHONES)]
imagesWithoutPrnu = [[randomImage(scale = 1) for _ in range(NUMBER_OF_IMAGES_PER_PHONE)] for phoneIndex in range(NUMBER_OF_PHONES)]
prnus = [randomImage(scale = PRNU_FACTOR) for _ in range(NUMBER_OF_PHONES)]
prnus = [randomGaussianImage(scale = PRNU_FACTOR, size = IMAGE_SIZE_SHAPE) for _ in range(NUMBER_OF_PHONES)]
imagesWithPrnu = [[imageWithoutPrnu + prnus[phoneIndex] for imageWithoutPrnu in imagesWithoutPrnu[phoneIndex]] for phoneIndex in range(NUMBER_OF_PHONES)]
allImages = np.max([np.max(imagesWithoutPrnu) + np.max(prnus) + np.max(imagesWithPrnu)])
def toPilImage(npArray):
return Image.fromarray(npArray)
def showImageWithPil(npArray):
npArray -= npArray.min()
npArray = (npArray / npArray.max()) * 255
Image.fromarray(npArray).show()
def showImageWithMatplotlib(npArray):
plt.imshow(npArray)
plt.show()
plt.title('RMS between actual PRNU and the mean of the first $N$ images with PRNU (i.e. estimated PRNU)')
plt.xlabel('$N$ first images with PRNU')
plt.ylabel('RMS')
plt.xscale('log')
rmss = []
mean = np.zeros(IMAGE_SIZE_SHAPE)
for imageIndex in range(NUMBER_OF_IMAGES_PER_PHONE):
mean = (mean * imageIndex + imagesWithPrnu[0][imageIndex]) / (imageIndex + 1)
rms = rmsDiffNumpy(mean, prnus[0])
rmss += [rms]
plt.plot(rmss)
plt.show()
##
NUMBER_OF_ROWS = 5
NUMBER_OF_COLUMNS = 3

View File

@@ -0,0 +1,66 @@
# Notes: https://gitea.lemnoslife.com/Benjamin_Loison/Robust_image_source_identification_on_modern_smartphones/issues/25
import os
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
import sys
sys.path.insert(0, '../../algorithms/image_utils/')
from image_utils import showImageWithMatplotlib, randomGaussianImage, toPilImage
sys.path.insert(0, '../../algorithms/context_adaptive_interpolator/')
from context_adaptive_interpolator import contextAdaptiveInterpolator
sys.path.insert(0, '../../algorithms/distance/')
from rms_diff import rmsDiffNumpy
from skimage.restoration import denoise_tv_chambolle
datasetPath = 'no_noise_images'
# Note that contrarily to `datasets/fake/`, here we do not have images being Gaussian with `scale` `1` but actual images with pixel values between 0 and 255.
# In addition to the range difference, note that the distribution in the first set of images was a Gaussian and here is very different and specific.
PRNU_FACTOR = 0.01
NOISE_FACTOR = 0.1
IMAGE_SIZE_SHAPE = (469, 704)
IMAGE_SIZE_SHAPE_4x4 = [size // 4 for size in IMAGE_SIZE_SHAPE]
np.random.seed(0)
#prnuNpArray = 255 * randomGaussianImage(scale = PRNU_FACTOR, size = IMAGE_SIZE_SHAPE)
prnuPil = Image.open('prnu_4x4_noise.png').convert('F')
prnuNpArray = np.array(prnuPil) * PRNU_FACTOR
def isIn256Range(x):
return 0 <= x and x <= 255
imagesPrnuEstimateNpArray = []
for imageName in os.listdir(datasetPath):
if imageName.endswith('.png'):
imagePath = f'{datasetPath}/{imageName}'
imageWithoutPrnuPil = Image.open(imagePath).convert('F')
imageWithoutPrnuNpArray = np.array(imageWithoutPrnuPil)
m = imageWithoutPrnuNpArray.shape[0] // 4
n = imageWithoutPrnuNpArray.shape[1] // 4
imageWithoutPrnuNpArrayTiles = [imageWithoutPrnuNpArray[x : x + m, y : y + n] for x in range(0, imageWithoutPrnuNpArray.shape[0], m) for y in range(0, imageWithoutPrnuNpArray.shape[1], n)]
for imageWithoutPrnuNpArrayTile in imageWithoutPrnuNpArrayTiles:
imageNoise = randomGaussianImage(scale = 255 * NOISE_FACTOR, size = imageWithoutPrnuNpArrayTile.shape)
imageWithPrnuNpArray = imageWithoutPrnuNpArrayTile + prnuNpArray + imageNoise
#assert all([isIn256Range(extreme) for extreme in [imageWithPrnuNpArray.max(), imageWithPrnuNpArray.min()]]), 'Adding the PRNU resulted in out of 256 bounds image'
imageWithPrnuPil = toPilImage(imageWithPrnuNpArray)
#imagePrnuEstimatePil = contextAdaptiveInterpolator(imageWithPrnuPil.load(), imageWithPrnuPil)
#imagePrnuEstimateNpArray = np.array(imagePrnuEstimatePil)
imagePrnuEstimateNpArray = imageWithPrnuNpArray - denoise_tv_chambolle(imageWithPrnuNpArray, weight=0.2, channel_axis=-1)
imagesPrnuEstimateNpArray += [imagePrnuEstimateNpArray]
cameraPrnuEstimateNpArray = np.array(imagesPrnuEstimateNpArray).mean(axis = 0)
rms = rmsDiffNumpy(cameraPrnuEstimateNpArray, prnuNpArray, True)
showImageWithMatplotlib(cameraPrnuEstimateNpArray, f'Camera PRNU estimate\nRMS with actual one: {rmsDiffNumpy(cameraPrnuEstimateNpArray, prnuNpArray):.4f} (normalized RMS: {rmsDiffNumpy(cameraPrnuEstimateNpArray, prnuNpArray, True):.4f})')

View File

@@ -0,0 +1 @@
https://web.archive.org/web/20220121204219/https://mcolom.perso.math.cnrs.fr/download/no_noise_images/no_noise_images.zip

View File

@@ -0,0 +1 @@
https://web.archive.org/web/20221230200626/https://mcolom.perso.math.cnrs.fr/pages/no_noise_images/

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" standalone="no"?>
<xournal creator="Xournal++ 1.1.3" fileversion="4">
<title>Xournal++ document - see https://github.com/xournalpp/xournalpp</title>
<page width="596.00000000" height="842.00000000">
<background type="pdf" domain="absolute" filename="/home/benjamin/Desktop/bens_folder/school/ens/asp/aria/internship/work/datasets/noise_free_test_images/webpage/noise_free_test_images.pdf" pageno="1"/>
<layer>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">44.16991935 149.86110719 276.63410082 149.86110719</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">280.30546835 143.78018970 541.08492691 143.78018970</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">42.96677014 154.05265871 198.56628848 154.05265871</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">233.93128450 170.94835013 492.23933025 170.94835013</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">42.99659414 184.92242482 112.65886477 184.92242482</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">149.16792941 183.91166246 216.17115865 183.91166246</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">294.03605816 184.15454202 354.65329212 184.15454202</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">378.27254366 184.83142695 394.34985957 184.14821152</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">85.58659829 199.62412937 411.27805159 199.62412937</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">418.29380004 200.39743471 541.57682036 200.39743471</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">44.73424234 213.56413029 69.64328426 213.56413029</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">112.38907743 213.70955538 483.94315603 213.70955538</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">44.49702491 230.38688218 98.83166378 230.38688218</stroke>
<stroke tool="pen" ts="0" fn="" color="#00c0ffff" width="1.41000000" fill="255">155.44600053 263.30094771 311.89079733 263.30094771</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">370.62786512 257.40568303 547.67625847 257.40568303</stroke>
<stroke tool="highlighter" color="#00c0ff7f" width="8.50000000" fill="128">44.88887314 272.09091817 331.36022445 272.09091817</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">350.89020532 268.80336793 450.39163443 268.80336793</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">44.93306058 287.15898498 351.10131254 287.15898498</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">45.27054464 307.01382219 263.17418553 307.01382219</stroke>
<stroke tool="highlighter" color="#ffff007f" width="8.50000000" fill="128">93.80213209 345.70257013 454.50227983 345.70257013</stroke>
<text font="Sans" size="11.00000000" x="45.82731792" y="353.90876455" color="#00c0ffff" ts="0" fn="">legends not matching actual webpage web-browser rendering</text>
<text font="Sans" size="11.00000000" x="48.63067627" y="32.63059998" color="#00c0ffff" ts="0" fn="">Almost identical content as `no_noise_images.zip/readme.txt`.</text>
</layer>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="2"/>
<layer/>
</page>
<page width="596.00000000" height="842.00000000">
<background type="pdf" pageno="3"/>
<layer/>
</page>
</xournal>