This program written in python can calculate Peak Signal-to-noise-ratio between two images.
- Add noise to an image by performing color transfer and recovery between two images
- Calculate PSNR between two images
First let us add noise to an image by performing color transfer and recovery
between two images. Of course you can just jump this step if already having your own images.
Last week I had already implemented color transfer
in another repository. After understanding the principle of color transfer, we can perform color recovery
by changing the formula.
After completing the above steps, it's time to calculate PSNR between two images.
Just split a color image into its 3 RGB channels then calculate their MSE
and use it to calculate PSNR
.
MAXI is maximum value of pixel, actually it will be 255.
pip install numpy
pip install opencv-python
pip install python-csv
If you want to create EXE file
after programming, also install this:
pip install pyinstaller
Put 6 source pictures inside source
folder and 6 target pictures inside the target
folder, then execute the code:
python color_transfer_and recovery.py
After that, your can find 6 result images inside result
folder and 6 recovery images inside result
folder.
Then, execute the command below to get PSNR between source
images and recovery
images:
python calculate_PSNR.py
Execute following instruction to create EXE file
of this program:
pyinstaller -F color_transfer.py
Source / Recovery
The PSNR between these two images is 43.71 :)