Traceback (most recent call last):
File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/./split_and_compare_prnus_of_subgroups.py", line 45, in <module>
print('Alpha')
File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/utils.py", line 145, in print
print(datetime.now(), *toPrint)
File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/utils.py", line 145, in print
print(datetime.now(), *toPrint)
File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/utils.py", line 145, in print
print(datetime.now(), *toPrint)
[Previous line repeated 996 more times]
RecursionError: maximum recursion depth exceeded while calling a Python object
```py
from utils import silentTqdm
tqdm = silentTqdm
```
Need `builtins` import otherwise get:
```
Traceback (most recent call last):
File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/./split_and_compare_prnus_of_subgroups.py", line 45, in <module>
print('Alpha')
File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/utils.py", line 145, in print
print(datetime.now(), *toPrint)
File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/utils.py", line 145, in print
print(datetime.now(), *toPrint)
File "/home/benjamin/robust_image_source_identification_on_modern_smartphones/datasets/raise/utils.py", line 145, in print
print(datetime.now(), *toPrint)
[Previous line repeated 996 more times]
RecursionError: maximum recursion depth exceeded while calling a Python object
```
Related to [issues/25#issuecomment-1476](https://gitea.lemnoslife.com/Benjamin_Loison/Robust_image_source_identification_on_modern_smartphones/issues/25#issuecomment-1476).
do not result in significant execution speed increase.
So only loading the specified color channel might not help too.
However, can keep the crop loaded into memory such that do not have to load the whole image when want to work with it. Assuming loading the whole raw images is the issue, can just load to memory getSingleColorChannelImages.
Could save the crops as Numpy arrays on hard disk if want to avoid loading time.
An interesting thing would be to save the images in a format such that can load only part of the image.
The question is what data structure do I precisely want to store this way?
getSingleColorChannelImages calls getColorChannel which calls getRawColorChannel. So a dict or similar seems to make sense. Maybe partial read is not compatible with dict and will have to make a file per color channel.
It does not seem that can only load part of a raw image with rawpy, if even possible at all.
In `getRawColorChannel`:
```python
rawImageVisible = raw.raw_image_visible.copy()[:100, :100]
```
or
```python
rawImageVisible = raw.raw_image_visible[:100, :100].copy()
```
do not result in significant execution speed increase.
So only loading the specified color channel might not help too.
However, can keep the crop loaded into memory such that do not have to load the whole image when want to work with it. Assuming loading the whole raw images is the issue, can just load to memory `getSingleColorChannelImages`.
Could save the crops as Numpy arrays on hard disk if want to avoid loading time.
An interesting thing would be to save the images in a format such that can load only part of the image.
The question is what data structure do I precisely want to store this way?
`getSingleColorChannelImages` calls `getColorChannel` which calls `getRawColorChannel`. So a `dict` or similar seems to make sense. Maybe partial read is not compatible with `dict` and will have to make a file per color channel.
but in fact just using time and adding an exit to current algorithm was faster to use and almost as precise.
mmap_mode{None, ‘r+’, ‘r’, ‘w+’, ‘c’}, optional
If not None, then memory-map the file, using the given mode (see numpy.memmap for a detailed description of the modes). A memory-mapped array is kept on disk. However, it can be accessed and sliced like any ndarray. Memory mapping is especially useful for accessing small fragments of large files without reading the entire file into memory.
Thought about using `benchmark_raw_images_loading.py`:
```python
#!/usr/bin/env python
from tqdm import tqdm
IMAGES_CAMERAS_FOLDER = {
'RAISE': 'flat-field/nef',
'Rafael 23/04/24': 'rafael/230424',
}
for color in
getColorChannel(imageFilePath, color)
```
but in fact just using `time` and adding an `exit` to current algorithm was faster to use and almost as precise.
> mmap_mode{None, ‘r+’, ‘r’, ‘w+’, ‘c’}, optional
>
> If not None, then memory-map the file, using the given mode (see numpy.memmap for a detailed description of the modes). A memory-mapped array is kept on disk. However, it can be accessed and sliced like any ndarray. **Memory mapping is especially useful for accessing small fragments of large files without reading the entire file into memory.**
Source: https://numpy.org/doc/1.26/reference/generated/numpy.load.html
https://numpy.org/doc/1.26/reference/generated/numpy.memmap.html#numpy.memmap
https://numpy.org/doc/1.26/reference/generated/numpy.save.html
Someone asked this question as [the Stack Overflow question 42727412](https://stackoverflow.com/q/42727412).
Image: 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [01:58<00:00, 1.19s/it]
Camera: 0%| | 0/2 [01:58<?, ?it/s]
real 1m58.753s
user 1m57.897s
sys 0m1.744s
With only one color:
time ./benchmark_load_part_of_images.py
Image: 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:29<00:00, 3.41it/s]
Camera: 0%| | 0/2 [00:29<?, ?it/s]
real 0m29.580s
user 0m29.782s
sys 0m0.729s
Should have at least a factor 4 improvement as only consider a single color.
With all colors:
```bash
time ./benchmark_load_part_of_images.py
```
```
Image: 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [01:58<00:00, 1.19s/it]
Camera: 0%| | 0/2 [01:58<?, ?it/s]
real 1m58.753s
user 1m57.897s
sys 0m1.744s
```
With only one color:
```bash
time ./benchmark_load_part_of_images.py
```
```
Image: 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:29<00:00, 3.41it/s]
Camera: 0%| | 0/2 [00:29<?, ?it/s]
real 0m29.580s
user 0m29.782s
sys 0m0.729s
```
Should have at least a factor 4 improvement as only consider a single color.
time ./benchmark_load_part_of_images.py
OPERATION = <Operation.SAVE: 2>
Image: 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [02:05<00:00, 1.26s/it]
Image: 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 259/259 [02:49<00:00, 1.53it/s]
Camera: 100%|███████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [04:54<00:00, 147.33s/it]
real 4m54.894s
user 4m27.517s
sys 0m21.637s
Well I was only saving the last color.
```
time ./benchmark_load_part_of_images.py
OPERATION = <Operation.SAVE: 2>
Image: 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [02:05<00:00, 1.26s/it]
Image: 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 259/259 [02:49<00:00, 1.53it/s]
Camera: 100%|███████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [04:54<00:00, 147.33s/it]
real 4m54.894s
user 4m27.517s
sys 0m21.637s
```
Saving each color channel in a different file:
```
OPERATION = <Operation.SAVE: 2>
Image: 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [02:30<00:00, 1.50s/it]
Image: 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 259/259 [04:20<00:00, 1.01s/it]
Camera: 100%|███████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [06:50<00:00, 205.27s/it]
real 6m50.766s
user 6m26.275s
sys 0m24.466s
```
For Rafael 23/04/24 estimated PRNU with mean denoiser:
400x400 (per color channel) centered crop:
6024x4024 so 800x800 centered crop is from (2612, 1612) to (3412, 2412).
Could use same color scale to ease comparing both images.
For Rafael 23/04/24 estimated PRNU with mean denoiser:


400x400 (per color channel) centered crop:

6024x4024 so 800x800 centered crop is from (2612, 1612) to (3412, 2412).
Could use same color scale to ease comparing both images.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Initially at #8.
https://github.com/JeffOwOSun/gpu-bm3d
https://github.com/OpenImageDenoise/oidn
Related to #53.
Need
builtinsimport otherwise get:Thanks to the Stack Overflow answer 5347492:
So reduced 21 seconds per merge to 1 second.
Related to issues/25#issuecomment-1476.
It does not seem that can only load part of a raw image with rawpy, if even possible at all.
In
getRawColorChannel:or
do not result in significant execution speed increase.
So only loading the specified color channel might not help too.
However, can keep the crop loaded into memory such that do not have to load the whole image when want to work with it. Assuming loading the whole raw images is the issue, can just load to memory
getSingleColorChannelImages.Could save the crops as Numpy arrays on hard disk if want to avoid loading time.
An interesting thing would be to save the images in a format such that can load only part of the image.
The question is what data structure do I precisely want to store this way?
getSingleColorChannelImagescallsgetColorChannelwhich callsgetRawColorChannel. So adictor similar seems to make sense. Maybe partial read is not compatible withdictand will have to make a file per color channel.Thought about using
benchmark_raw_images_loading.py:but in fact just using
timeand adding anexitto current algorithm was faster to use and almost as precise.Source: https://numpy.org/doc/1.26/reference/generated/numpy.load.html
https://numpy.org/doc/1.26/reference/generated/numpy.memmap.html#numpy.memmap
https://numpy.org/doc/1.26/reference/generated/numpy.save.html
Someone asked this question as the Stack Overflow question 42727412.
With all colors:
With only one color:
Should have at least a factor 4 improvement as only consider a single color.
Related to Benjamin_Loison/rawpy/issues/2.
Loading all colors on both cameras:
For saving:
With
.npyloading:Note that could consider a middle image (per image resolution) crop to reduce possible issues like vignetting.
Can also consider random location crop.
Well I was only saving the last color.
Saving each color channel in a different file:
My tests seem biased due to a cache.
For Rafael 23/04/24 estimated PRNU with mean denoiser:
400x400 (per color channel) centered crop:
6024x4024 so 800x800 centered crop is from (2612, 1612) to (3412, 2412).
Could use same color scale to ease comparing both images.
On the crop we seem to particularly see the lines artifacts, see #70.