I would like to select only the gray area in the middle of my image ?
I mean my calculations of mean, standard deviation must use values in this area.
I can select columns and rows but I will still have the corners.
import numpy as np
import cv2
import rawpy
import rawpy.enhance
import matplotlib.pyplot as plt
import glob
#################### 2023-09-21_16-58-51.894
# Reading a Nikon RAW (NEF) image
init="/media/alexandre/Transcend/Expérience/Ombroscopie/eau/initialisation/2023-09-19_19-02-33.473.nef"
brut="/media/alexandre/Transcend/Expérience/Ombroscopie/eau/DT0.4/2023-09-25_13-26-56.259.nef"
bruit="/media/alexandre/Transcend/Expérience/Ombroscopie/eau/bruit-electronique/2023-09-18_18-59-34.994.nef"
####################
# This uses rawpy library
print("reading init file using rawpy.")
raw_init = rawpy.imread(init)
image_init = raw_init.postprocess(use_camera_wb=True, output_bps=16)
print("Size of init image read:" + str(image_init.shape))
print("reading brut file using rawpy.")
raw_brut = rawpy.imread(brut)
image_brut = raw_brut.postprocess(use_camera_wb=True, output_bps=16)
print("Size of brut image read:" + str(image_brut.shape))
print("reading bruit file using rawpy.")
raw_bruit = rawpy.imread(bruit)
image_bruit = raw_bruit.postprocess(use_camera_wb=True, output_bps=16)
print("Size of bruit image read:" + str(image_bruit.shape))
####################
# (grayscale) OpenCV
init_grayscale = cv2.cvtColor(image_init, cv2.COLOR_RGB2GRAY)
brut_grayscale = cv2.cvtColor(image_brut, cv2.COLOR_RGB2GRAY)
bruit_grayscale = cv2.cvtColor(image_bruit, cv2.COLOR_RGB2GRAY)
print("max brut_grayscle : ", np.max(brut_grayscale))
print("init grayscale type : ", init_grayscale.dtype)
print("brut grayscale type : ", brut_grayscale.dtype)
test = cv2.divide((brut_grayscale-init_grayscale),(init_grayscale))
####################
# Irms, std, mean
intensite_rms = np.sqrt(np.mean(np.square(test)))
print("Intensité RMS de l'image :", intensite_rms)
mean, std_dev = cv2.meanStdDev(test)
print("ecart type de l'image :", std_dev[0][0])
print("Moyenne de l'image :", mean[0][0])
print("variance de l'image :", std_dev[0][0]**2)
####################
# Matplotlib
import matplotlib.pyplot as plt
plt.imshow((test * 65535), cmap='gray')
plt.imshow((brut_grayscale * 65535), cmap='gray')
plt.show()
Do you have any idea to do it ?