I wonder if there is any available code in python or MATLAB in order to plot the psnr Vs Bitrate diagram ? I've found a lot of questions published on the internet but none of them try to explain the process of this job
-
Hi, this question is too vague. Do you have the data to plot? Couldn't you just use `plot(psnr, bitrate)` in MATLAB or python? What is it that you are struggling with exactly, *collecting data, understanding what plotting psnr vs bitrate means, actually plotting the data...* Please add more detail so others can help you. – mimocha Apr 18 '21 at 15:41
-
Yes hello, thanks for responding me. Actually I do have an original image with which I want to plot this graph ( this image can be coded by jpeg,jpeg2000,bpg and proposed method) the problem is that I don't understand exactly the process in order to do this graph. – Ouismed Apr 19 '21 at 07:39
1 Answers
So you want to compare the bitrate (aka. bits-per-pixel, bpp) vs the peak signal-to-noise ratio (PSNR) for images.
This can be done simply by starting with some reference image, then create many copies of this reference image with different levels of compression (different bitrate/bpp).
Calculate and note the different bitrate for each copy of the image.
bpp = (Size of image in bits) / (number of pixels in image)
Then compare each copy of the image with the original reference image, to get the PSNR.
In MATLAB, this can be done with the psnr()
function (this requires the MATLAB Image Processing Toolbox.) The syntax for MATLAB is [peak_snr, snr] = psnr( copy_image, original_image )
In python, one option is with OpenCV's PSNR function. The syntax for OpenCV is cv2.psnr(img1, img2)
Then, once you have the corresponding bitrates-psnr values, you can plot it and be done.

- 1,041
- 8
- 18