Use same color map for different images to more accurately compare them #68

Closed
opened 2024-05-09 23:18:36 +02:00 by Benjamin_Loison · 9 comments
help(plt.imsave)
...
    vmin, vmax : float, optional
        *vmin* and *vmax* set the color scaling for the image by fixing the
        values that map to the colormap color limits. If either *vmin*
        or *vmax* is None, that limit is determined from the *arr*
        min/max value.
    cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
        A Colormap instance or registered colormap name. The colormap
        maps scalar data to colors. It is ignored for RGB(A) data.
...
```python help(plt.imsave) ``` ``` ... vmin, vmax : float, optional *vmin* and *vmax* set the color scaling for the image by fixing the values that map to the colormap color limits. If either *vmin* or *vmax* is None, that limit is determined from the *arr* min/max value. cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap` A Colormap instance or registered colormap name. The colormap maps scalar data to colors. It is ignored for RGB(A) data. ... ```
Benjamin_Loison added the
enhancement
low priority
quick
labels 2024-05-09 23:18:36 +02:00
Author
Owner
plt.imsave(PREFIX + 'multiple_colors.png', multipleColorsImage, vmin = multipleColorsImage.min(), vmax = multipleColorsImage.max())

is identical (according to diff) to:

plt.imsave(PREFIX + 'multiple_colors.png', multipleColorsImage)
```python plt.imsave(PREFIX + 'multiple_colors.png', multipleColorsImage, vmin = multipleColorsImage.min(), vmax = multipleColorsImage.max()) ``` is identical (according to `diff`) to: ```python plt.imsave(PREFIX + 'multiple_colors.png', multipleColorsImage) ```
Author
Owner
denoiser = bilateral np.min(multipleColorsImage) = -0.04890543970650529 np.max(multipleColorsImage) = 0.047219058067642594
denoiser = wavelet np.min(multipleColorsImage) = -0.05360332845280251 np.max(multipleColorsImage) = 0.03556257229735231
denoiser = mean np.min(multipleColorsImage) = -69.4864864864864 np.max(multipleColorsImage) = 36.67181467181476

If use the same color scale, then only mean is interesting as it enforces its own color scale and 2 other images are monocolor.

Mean:

mean_rafael_230424_mean_multiple_colors

Bilateral:

mean_rafael_230424_bilateral_multiple_colors

When remove mean denoiser:

Bilateral:

mean_rafael_230424_bilateral_multiple_colors

Wavelet:

mean_rafael_230424_wavelet_multiple_colors

``` denoiser = bilateral np.min(multipleColorsImage) = -0.04890543970650529 np.max(multipleColorsImage) = 0.047219058067642594 denoiser = wavelet np.min(multipleColorsImage) = -0.05360332845280251 np.max(multipleColorsImage) = 0.03556257229735231 denoiser = mean np.min(multipleColorsImage) = -69.4864864864864 np.max(multipleColorsImage) = 36.67181467181476 ``` If use the same color scale, then only `mean` is interesting as it enforces its own color scale and 2 other images are monocolor. Mean: ![mean_rafael_230424_mean_multiple_colors](/attachments/2823f3c5-b68f-4d4b-8035-d04bc1ff1794) Bilateral: ![mean_rafael_230424_bilateral_multiple_colors](/attachments/366a53f3-bd3a-479d-9682-540c8de9e242) When remove mean denoiser: Bilateral: ![mean_rafael_230424_bilateral_multiple_colors](/attachments/78fe2daf-0458-474c-b033-09e477097906) Wavelet: ![mean_rafael_230424_wavelet_multiple_colors](/attachments/04e13889-9ae0-413e-b5df-0c53ece15cfc)
Author
Owner

prnu_estimate_distribution_of_values_for_rafael_230424_images

![prnu_estimate_distribution_of_values_for_rafael_230424_images](/attachments/52c1f5a5-cdad-4f9a-9be3-d3469cf4921a)
Author
Owner

Should make similar plot for RAISE flat-field to maybe understand why Rafael images are absorbing in #63.

prnu_estimate_distribution_of_values_for_raise_flat-field_images

prnu_estimate_distribution_of_values_for_raise_flat-field_images

Figure_1

Why have such an outlier for mean blue? Maybe because of borders? I would not say so as they do not behave differently as far as I understand. Maybe because of point at (644, 1200)? It seems to:

image

image

import numpy as np
import matplotlib.pyplot as plt

fileName = 'means/mean_flat-field_NEF_mean_blue'
npArray = np.load(f'{fileName}.npy')

plt.title('Distribution of PRNU estimation of RAISE flat-field raw blue channel')
plt.hist(npArray.flatten(), 'auto')
plt.show()

distribution_of_prnu_estimation_of_raise_flat-field_raw_blue_channel

distribution_of_prnu_estimation_of_raise_flat-field_raw_blue_channel

>>> index = -1; np.partition(npArray.flatten(), index)[index]
5042.010000000002

>>> index = -2; np.partition(npArray.flatten(), index)[index]
423.28999999999934

So the first and second maximum are 5042 and 423.29.

Should make similar plot for RAISE flat-field to maybe understand why Rafael images are absorbing in #63. ![prnu_estimate_distribution_of_values_for_raise_flat-field_images](/attachments/bac0a3cc-d60c-4a89-9ae5-1e6036147b40) ![prnu_estimate_distribution_of_values_for_raise_flat-field_images](/attachments/b1b46f64-d5e9-44c2-bff4-53e31087dccd) ![Figure_1](/attachments/44261368-e522-4aca-b3a9-4e1bf1ff3869) Why have such an outlier for mean blue? Maybe because of borders? I would not say so as they do not behave differently as far as I understand. Maybe because of point at (644, 1200)? It seems to: ![image](/attachments/d3f797f4-a361-443c-8c88-0b70e7184664) ![image](/attachments/946eacdc-a2f2-43fa-aaca-76601a930592) ```python import numpy as np import matplotlib.pyplot as plt fileName = 'means/mean_flat-field_NEF_mean_blue' npArray = np.load(f'{fileName}.npy') plt.title('Distribution of PRNU estimation of RAISE flat-field raw blue channel') plt.hist(npArray.flatten(), 'auto') plt.show() ``` ![distribution_of_prnu_estimation_of_raise_flat-field_raw_blue_channel](/attachments/ff5fa212-5673-4b12-b66e-c5cdcf8a962c) ![distribution_of_prnu_estimation_of_raise_flat-field_raw_blue_channel](/attachments/1109ecfc-0a42-409f-af27-5e59e9b7b181) ```pycon >>> index = -1; np.partition(npArray.flatten(), index)[index] 5042.010000000002 >>> index = -2; np.partition(npArray.flatten(), index)[index] 423.28999999999934 ``` So the first and second maximum are 5042 and 423.29.
Author
Owner

Could be interesting to just add a line with raw images.

Could be interesting to just add a line with raw images.
Author
Owner
>>> index = -100; np.partition(npArray.flatten(), index)[index]
27.28
>>> index = 100; np.partition(npArray.flatten(), index)[index]
-26.35

So width of 53.63 and compared to other denoisers width of about 0.1, the width is 563 times wider...

```pycon >>> index = -100; np.partition(npArray.flatten(), index)[index] 27.28 >>> index = 100; np.partition(npArray.flatten(), index)[index] -26.35 ``` So width of 53.63 and compared to other denoisers width of about 0.1, the width is 563 times wider...
Author
Owner

Could locate such maximums to potentially see visually other outliers.

>>> np.unravel_index(npArray.argmax(), npArray.shape)
(1200, 644)
>>> index = -0; np.where(npArray == np.partition(npArray.flatten(), index)[index])
(array([1202]), array([643]))
>>> index = -1; np.array(np.where(npArray == np.partition(npArray.flatten(), index)[index])[::-1]) * 2
array([[1288],
       [2400]])

They are not clearly visible as the first maximum, this is explainable as the intensity is 133 times less.

Could locate such maximums to potentially see visually other outliers. ```pycon >>> np.unravel_index(npArray.argmax(), npArray.shape) (1200, 644) >>> index = -0; np.where(npArray == np.partition(npArray.flatten(), index)[index]) (array([1202]), array([643])) >>> index = -1; np.array(np.where(npArray == np.partition(npArray.flatten(), index)[index])[::-1]) * 2 array([[1288], [2400]]) ``` They are not clearly visible as the first maximum, this is explainable as the intensity is 133 times less.
Author
Owner
Related to [Benjamin_Loison/gimp/issues/29](https://gitlab.gnome.org/Benjamin_Loison/gimp/-/issues/29).
Author
Owner

Could compute proportion of pixels for mean outside largest other denoisers band.

But it may be a significant proportion exceeding not much, so should maybe just plot distribution of pixel values and zoom on the largest other denoisers band.

Could compute proportion of pixels for mean outside largest other denoisers band. But it may be a significant proportion exceeding not much, so should maybe just plot distribution of pixel values and zoom on the largest other denoisers band.
Sign in to join this conversation.
No description provided.