answersLogoWhite

0

To compute the Peak Signal-to-Noise Ratio (PSNR) of an image in MATLAB, you can use the following code:

function psnr_value = compute_psnr(original, distorted)
    mse = mean((original(:) - distorted(:)).^2); % Calculate Mean Squared Error
    if mse == 0
        psnr_value = Inf; % If no difference, PSNR is infinite
    else
        max_pixel = max(original(:)); % Maximum pixel value
        psnr_value = 10 * log10(max_pixel^2 / mse); % Calculate PSNR
    end
end

Call the function with two images as inputs: compute_psnr(original_image, distorted_image).

User Avatar

AnswerBot

2w ago

What else can I help you with?

Related Questions

How do you make graph from an equation in Matlab?

Initially, the equation can be directly realized using Matlab source code. Then various inputs can be applied to it. These values can easily be plotted on a graph using plot or stem command in Matlab.


Digital watermarking source code in matlab?

Digital watermarking in MATLAB can be implemented using various techniques, including spatial domain and frequency domain methods. A simple approach involves embedding a watermark image into a host image by modifying pixel values or using Discrete Cosine Transform (DCT) for frequency-based watermarking. You can use MATLAB's built-in functions like imread, imshow, and matrix operations to manipulate images. For example, to embed a watermark, you can blend it with the host image and then extract it by analyzing the modified image.


What is code validation in Matlab and Simulink?

i want to do validation to my image folder


Segmentation image by GA plus source code Matlab?

Dear My friend I am Diem my Email: buitrongdiem@gmail.com I am writing programming GA code matlab but I do not know association objective function and constraint condition Can you say for me method association it ? Thanh you ve re much!!!! Best Regard BuiDiem


What is the Matlab code to plot a histogram?

imhist(x); where 'x' is your data or image to find histogram.


How do you modulate in matlab without using matlab tools?

You would have to write your own code for a modulation (Matlab has a convolution function not in the tools), otherwise you can use its built in function in the signal processing toolbox.


Gram schmidt matlab code for orthonormalizing set of vectors?

gram schmidt matlab code


Matlab code for filters using LMS algorithm?

http://www.mathworks.com/matlabcentral/fileexchange/3649


Matlab code of convolutional coding and viterbi algorithm?

matlab code for convolutional coding and BCH coding


How do you decompose an image in matlab code?

To decompose an image in MATLAB, you can use the im2col function to reshape the image into overlapping or non-overlapping blocks, or apply techniques like Discrete Wavelet Transform (DWT) using the wavedec2 function for multi-resolution analysis. For example, to perform a wavelet decomposition, you can use: [coeffs, sizes] = wavedec2(image, level, 'waveletname'); Replace level with the desired decomposition level and 'waveletname' with the chosen wavelet type. You can then extract the approximation and detail coefficients from coeffs as needed.


Code for circular convolution matlab?

Please check the help files of the matlab circular convolution . Matlab already has a readymade function for it.


Does matlab talk?

Yes, it is possible to make matlab talk in Windows using a simple program that can be downloaded here: http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=15890&objectType=FILE If you are using a mac, or unix then there may be other ways to make matlab talk, but the basic code will be quite similar. Have fun. Ed