rafael-fuente / diffractsim

✨🔬 A flexible diffraction simulator for exploring and visualizing physical optics.
https://rafael-fuente.github.io/simulating-diffraction-patterns-with-the-angular-spectrum-method-and-python.html
Other
668 stars 82 forks source link

ApertureFromImage() seems to always assume the image is in linear sRGB #36

Open stduhpf opened 1 year ago

stduhpf commented 1 year ago

Hi,

I think this tool you made is awesome, and I really enjoy playing with it. My only "complaint" is that when using a grayscale image as an aperture, the result at a dstance of 0 look different from the original image. I'm guessing that it's because F.get_colors() correctly converts the output image to sRGB, but when loading the aperture image with ApertureFromImage(), the image isn't correctly converted to linear.

Editing the grayscale conversion in aperture_from_image.py this way seems to fix it: t = 0.2990 * np.power(imgRGB[:, :, 0],2.2) + 0.5870 * np.power(imgRGB[:, :, 1],2.2) + 0.1140 * np.power(imgRGB[:, :, 2],2.2)