why the mse and psnr changing?

조회 수: 2 (최근 30일)
Halimatun Saidah Aminuddin
Halimatun Saidah Aminuddin 2021년 5월 22일
답변: Nagasai Bharat 2021년 5월 27일
I use this coding to find mse and psnr, why everytime i ran the code, the image's psnr and mse changing??
clear all
close all
clc
imdata = imread ('/Users/hp/desktop/FYP IMAGE/blue/160blue.jpg')
figure
imshow (imdata);
title ('Original image');
ref = rgb2gray (imdata);
figure
imshow (ref);
title ('gray image');
N = imnoise (ref, 'salt & pepper', 0.02);
figure
imshow (N);
title ('Noise Image');
error = immse (N, ref);
peaksnr = psnr (N, ref);
subplot (311); imshow(imdata); title ('oroginal image');
subplot (312); imshow(ref); title ('gray image');
subplot (313); imshow(N); title ('Noise Image');

채택된 답변

Nagasai Bharat
Nagasai Bharat 2021년 5월 27일
Hi,
The change in the value of peaksnr and error is due the probabilistic nature of the imnoise function to add noise into the image.
From the documentation of imnoise the algorithm is used is:
To add 'salt & pepper' noise with density d to an image, imnoise first assigns each pixel a random probability value from a standard uniform distribution on the open interval (0, 1).
  • For pixels with probability value in the range (0, d/2), the pixel value is set to 0. The number of pixels that are set to 0 is approximately d*numel(I)/2.
  • For pixels with probability value in the range [d/2, d), the pixel value is set to the maximum value of the image data type. The number of pixels that are set to the maximum value is approximately d*numel(I)/2.
  • For pixels with probability value in the range [d, 1), the pixel value is unchanged.

추가 답변 (0개)

태그

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by