精华内容
下载资源
问答
  • psnr函数
    千次阅读
    2016-11-07 19:36:32
    double getPSNR(const Mat& I1, const Mat& I2)
    {
        Mat s1;
        absdiff(I1, I2, s1);       // |I1 - I2|AbsDiff函数是 OpenCV 中计算两个数组差的绝对值的函数
        s1.convertTo(s1, CV_32F);  // 这里我们使用的CV_32F来计算,因为8位无符号char是不能进行平方计算
        s1 = s1.mul(s1);           // |I1 - I2|^2
    
        Scalar s = sum(s1);         //对每一个通道进行加和
    
        double sse = s.val[0] + s.val[1] + s.val[2]; // sum channels
    
        if (sse <= 1e-10) // 对于非常小的值我们将约等于0
            return 0;
        else
        {
            double  mse = sse / (double)(I1.channels() * I1.total());//计算MSE
            double psnr = 10.0*log10((255 * 255) / mse);
            return psnr;//返回PSNR
        }
    }
    更多相关内容
  • 基于Matlab的PSNR算法实现(源码,直接运行),在窗口输入PSNR('img1','img2')直接出结果,简单易行。
  • matlab实现图像质量评价指标SSIM和PSNR

    千次阅读 2020-09-25 10:58:27
    (matlab的内置psnr函数使用此方法) 3:将R,G,B格式转换为YCbCr,只计算Y分量(亮度分量),结果会比直接计算要高几个dB。 (本文章给出此方法的实现代码) 其中方法2和3用的比较多,1不常用! 方法二: help psnr ...

    其实使用那儿个方法计算PSNR和SSIM都无所谓!!
    只要将所有算法使用同一种计算方法对照实验即可!!!!

    matlab有内置函数ssim()、psnr()可以直接调用

    **
    在这里插入图片描述

    计算psnr方法,分为三种:

    **

    1:计算rgb三通道每个通道的psnr值,再求平均
    2:计算rgb三通道每个通道的mse值,再平均,得到psnr。**
    方法一和方法二理论上计算出来的psnr应该相同,并比方法三高3左右…
    3:将R,G,B格式转换为YCbCr,只计算Y分量(亮度分量),结果会比直接计算要高几个dB。 (本文章给出此方法的实现代码)

    (matlab的内置psnr函数默认将图片当成灰度图像处理)
    其中方法2和3用的比较多,1不常用!

    方法一 (与matlab内置psnr()函数计算的峰值信噪比有略微差别!)

    img=imread('src_88.png'); 
    img = imcrop(img,[0,146,1242,230]);    //img和imgn必须保证大小相同
    [h,w]=size(img);
    imgn=imread('dehaze.png');
    img=double(img);
    imgn=double(imgn);   
    B=8;                %编码一个像素用多少二进制位
    MAX=2^B-1;          %图像有多少灰度级
    MES=sum(sum((img-imgn).^2))/(h*w/3);     %均方差
    PSNR=10*log10(MAX.^2/MES);           %峰值信噪比 MAX.^2
    Total_PSNR=(PSNR(:,:,1)+PSNR(:,:,2)+PSNR(:,:,3))/3;
    disp(Total_PSNR)
    

    使用matlab内置psnr函数(等同于mesaerr()函数,都返回两张图片的psnr):

    help psnr   % 查看psnr函数详情
    psnr(A, ref)   % 直接使用matlab内置函数计算psnr
    
    

    方法二 (与直接使用matlab内置的psnr()函数得到的峰值信噪比相同!)

    X = imread('src_88.png'); 
    X = imcrop(X,[0,146,1242,230]);  %将两张图片裁剪成统一大小
    Y = imread('dehaze.png');
    
    [r,cl]=size(X);   %读入图像尺寸
    c=cl/3;
    X = double(X);
    Y = double(Y);
    mse_mR=double(zeros(r,c));
    mse_mG=double(zeros(r,c));
    mse_mB=double(zeros(r,c));
    Xr=X(:,:,1);
    Xg=X(:,:,2);
    Xb=X(:,:,3);
    Yr=Y(:,:,1);
    Yg=Y(:,:,2);
    Yb=Y(:,:,3);
    for i=1:r
        for j=1:c
            mse_mR(i,j)=(Xr(i,j)-Yr(i,j))^2;
            mse_mG(i,j)=(Xg(i,j)-Yg(i,j))^2;
            mse_mB(i,j)=(Xb(i,j)-Yb(i,j))^2;
        end
    end
    mseRGB = sum(mse_mR(:))+sum(mse_mG(:))+sum(mse_mB(:));
    mse = mseRGB/(r*cl);        
        
    PSNR = 10*log10(255^2/mse)
    

    方法三(如果传入RGB图像,比使用matlab内置的psnr函数得到的值要大2左右)

    function [PSNR, MSE] = psnr(X, Y)
    %%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % 计算峰值信噪比PSNR
    % 将RGB转成YCbCr格式进行计算
    % 如果直接计算会比转后计算值要小2dB左右(当然是个别测试)
    %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%
     if size(X,3)~=1   %判断图像时不是彩色图,如果是,结果为3,否则为1
       org=rgb2ycbcr(X);
       test=rgb2ycbcr(Y);
       Y1=org(:,:,1);
       Y2=test(:,:,1);
       Y1=double(Y1);  %计算平方时候需要转成double类型,否则uchar类型会丢失数据
       Y2=double(Y2);
     else              %灰度图像,不用转换
         Y1=double(X);
         Y2=double(Y);
     end
     
    if nargin<2    
       D = Y1;
    else
      if any(size(Y1)~=size(Y2))
        error('The input size is not equal to each other!');
      end
     D = Y1 - Y2; 
    end
    MSE = sum(D(:).*D(:)) / numel(Y1); 
    PSNR = 10*log10(255^2 / MSE);
    
    

    调用方法:

    >> X= imread('C:\Users\Administrator\Desktop\noise_image.jpg');
    >> Y= imread('C:\Users\Administrator\Desktop\actruel_image.jpg');
    >> psnr(X, Y)
    

    计算ssim

    计算SSIM的差异原因:同上,如果直接不转换成YCbCr格式,结果会偏高很多( matlab中内置ssim函数使用的方法 )。opencv里面是分别计算了R,G,B三个分量的SSIM值( 官方代码 )。最后将3个值取了个平均(这个值比matlab里面低很多)。

    方法1. 直接使用matlab内置的ssim函数

    help ssim   % 查看ssim函数详情
    

    在这里插入图片描述
    将RGB图像转换成YCbCr计算图片的SSIM(与matlab内置的ssim函数相同)

    function [ssimval, ssimmap] = ssim(varargin)
    %SSIM Structural Similarity Index for measuring image quality
    %   SSIMVAL = SSIM(A, REF) calculates the Structural Similarity Index
    %   (SSIM) value for image A, with the image REF as the reference. A and
    %   REF can be 2D grayscale or 3D volume images, and must be of the same
    %   size and class. 
    % 
    %   [SSIMVAL, SSIMMAP] = SSIM(A, REF) also returns the local SSIM value for
    %   each pixel in SSIMMAP. SSIMMAP has the same size as A.
    %
    %   [SSIMVAL, SSIMMAP] = SSIM(A, REF, NAME1, VAL1,...) calculates the SSIM
    %   value using name-value pairs to control aspects of the computation.
    %   Parameter names can be abbreviated.
    %
    %   Parameters include:
    %
    %   'Radius'                 - Specifies the standard deviation of 
    %                              isotropic Gaussian function used for
    %                              weighting the neighborhood pixels around a
    %                              pixel for estimating local statistics. This
    %                              weighting is used to avoid blocking
    %                              artifacts in estimating local statistics.
    %                              The default value is 1.5.
    % 
    %   'DynamicRange'           - Positive scalar, L, that specifies the
    %                              dynamic range of the input image. By
    %                              default, L is chosen based on the class of
    %                              the input image A, as L =
    %                              diff(getrangefromclass(A)). Note that when
    %                              class of A is single or double, L = 1 by
    %                              default.
    % 
    %   'RegularizationConstants'- Three-element vector, [C1 C2 C3], of 
    %                              non-negative real numbers that specifies the
    %                              regularization constants for the luminance,
    %                              contrast, and structural terms (see [1]),
    %                              respectively. The regularization constants
    %                              are used to avoid instability for image
    %                              regions where the local mean or standard
    %                              deviation is close to zero. Therefore, small
    %                              non-zero values should be used for these
    %                              constants. By default, C1 = (0.01*L).^2, C2
    %                              = (0.03*L).^2, and C3 = C2/2, where L is the
    %                              specified 'DynamicRange' value. If a value
    %                              of 'DynamicRange' is not specified, the
    %                              default value is used (see name-value pair
    %                              'DynamicRange').
    % 
    %   'Exponents'               - Three-element vector [alpha beta gamma],
    %                               of non-negative real numbers that specifies
    %                               the exponents for the luminance, contrast,
    %                               and structural terms (see [1]),
    %                               respectively. By default, all the three
    %                               exponents are 1, i.e. the vector is [1 1
    %                               1].
    % 
    %   Notes 
    %   -----
    %   1. A and REF can be arrays of upto three dimensions. All 3D arrays
    %      are considered 3D volumetric images. RGB images will also be
    %      processed as 3D volumetric images.
    % 
    %   2. Input image A and reference image REF are converted to
    %      floating-point type for internal computation.
    % 
    %   3. For signed-integer images (int16), an offset is applied to bring the
    %      gray values in the non-negative range before computing the SSIM
    %      index.
    % 
    %   Example
    %   ---------
    %   This example shows how to compute SSIM value for a blurred image given
    %   the original reference image.
    % 
    %   ref = imread('pout.tif');
    %   H = fspecial('Gaussian',[11 11],1.5);
    %   A = imfilter(ref,H,'replicate');
    % 
    %   subplot(1,2,1); imshow(ref); title('Reference Image');
    %   subplot(1,2,2); imshow(A);   title('Blurred Image');
    % 
    %   [ssimval, ssimmap] = ssim(A,ref);
    % 
    %   fprintf('The SSIM value is %0.4f.\n',ssimval);
    % 
    %   figure, imshow(ssimmap,[]);
    %   title(sprintf('SSIM Index Map - Mean SSIM Value is %0.4f',ssimval));
    
    %   Class Support
    %   -------------
    %   Input arrays A and REF must be one of the following classes: uint8,
    %   int16, uint16, single, or double. Both A and REF must be of the same
    %   class. They must be nonsparse. SSIMVAL is a scalar and SSIMMAP is an
    %   array of the same size as A. Both SSIMVAL and SSIMMAP are of class
    %   double, unless A and REF are of class single in which case SSIMVAL and
    %   SSIMMAP are of class single.
    % 
    %   References:
    %   -----------
    %   [1] Z. Wang, A. C. Bovik, H. R. Sheikh, and E. P. Simoncelli, "Image 
    %       Quality Assessment: From Error Visibility to Structural
    %       Similarity," IEEE Transactions on Image Processing, Volume 13,
    %       Issue 4, pp. 600- 612, 2004.
    %
    %   See also IMMSE, MEAN, MEDIAN, PSNR, SUM, VAR.
    
    %   Copyright 2013-2014 The MathWorks, Inc. 
    
    narginchk(2,10);
    
    [A, ref, C, exponents, radius] = parse_inputs(varargin{:});
    
    if isempty(A)
        ssimval = zeros(0, 'like', A);
        ssimmap = A;
        return;
    end
    
    if isa(A,'int16') % int16 is the only allowed signed-integer type for A and ref.
        % Add offset for signed-integer types to bring values in the
        % non-negative range.
        A = double(A) - double(intmin('int16'));
        ref = double(ref) - double(intmin('int16'));
    elseif isinteger(A)
        A = double(A);
        ref = double(ref);
    end
          
    % Gaussian weighting function
    gaussFilt = getGaussianWeightingFilter(radius,ndims(A));
    
    % Weighted-mean and weighted-variance computations
    mux2 = imfilter(A, gaussFilt,'conv','replicate');
    muy2 = imfilter(ref, gaussFilt,'conv','replicate');
    muxy = mux2.*muy2;
    mux2 = mux2.^2;
    muy2 = muy2.^2;
    
    sigmax2 = imfilter(A.^2,gaussFilt,'conv','replicate') - mux2;
    sigmay2 = imfilter(ref.^2,gaussFilt,'conv','replicate') - muy2;
    sigmaxy = imfilter(A.*ref,gaussFilt,'conv','replicate') - muxy;
    
    % Compute SSIM index
    if (C(3) == C(2)/2) && isequal(exponents(:),ones(3,1))
        % Special case: Equation 13 from [1]
        num = (2*muxy + C(1)).*(2*sigmaxy + C(2));
        den = (mux2 + muy2 + C(1)).*(sigmax2 + sigmay2 + C(2));
        if (C(1) > 0) && (C(2) > 0)
            ssimmap = num./den;
        else
            % Need to guard against divide-by-zero if either C(1) or C(2) is 0.
            isDenNonZero = (den ~= 0);           
            ssimmap = ones(size(A));
            ssimmap(isDenNonZero) = num(isDenNonZero)./den(isDenNonZero);
        end
        
    else
        % General case: Equation 12 from [1] 
        % Luminance term
        if (exponents(1) > 0)
            num = 2*muxy + C(1);
            den = mux2 + muy2 + C(1); 
            ssimmap = guardedDivideAndExponent(num,den,C(1),exponents(1));
        else 
            ssimmap = ones(size(A), 'like', A);
        end
        
        % Contrast term
        sigmaxsigmay = [];
        if (exponents(2) > 0)  
            sigmaxsigmay = sqrt(sigmax2.*sigmay2);
            num = 2*sigmaxsigmay + C(2);
            den = sigmax2 + sigmay2 + C(2); 
            ssimmap = ssimmap.*guardedDivideAndExponent(num,den,C(2),exponents(2));        
        end
        
        % Structure term
        if (exponents(3) > 0)
            num = sigmaxy + C(3);
            if isempty(sigmaxsigmay)
                sigmaxsigmay = sqrt(sigmax2.*sigmay2);
            end
            den = sigmaxsigmay + C(3); 
            ssimmap = ssimmap.*guardedDivideAndExponent(num,den,C(3),exponents(3));        
        end
        
    end
    
    ssimval = mean(ssimmap(:));
        
    end
    
    % -------------------------------------------------------------------------
    function component = guardedDivideAndExponent(num, den, C, exponent)
    
    if C > 0
        component = num./den;
    else
        component = ones(size(num),'like',num);
        isDenNonZero = (den ~= 0);
        component(isDenNonZero) = num(isDenNonZero)./den(isDenNonZero);
    end
    
    if (exponent ~= 1)
        component = component.^exponent;
    end
    
    end
    
    function gaussFilt = getGaussianWeightingFilter(radius,N)
    % Get 2D or 3D Gaussian weighting filter
    
    filtRadius = ceil(radius*3); % 3 Standard deviations include >99% of the area. 
    filtSize = 2*filtRadius + 1;
    
    if (N < 3)
        % 2D Gaussian mask can be used for filtering even one-dimensional
        % signals using imfilter. 
        gaussFilt = fspecial('gaussian',[filtSize filtSize],radius);
    else 
        % 3D Gaussian mask
         [x,y,z] = ndgrid(-filtRadius:filtRadius,-filtRadius:filtRadius, ...
                        -filtRadius:filtRadius);
         arg = -(x.*x + y.*y + z.*z)/(2*radius*radius);
         gaussFilt = exp(arg);
         gaussFilt(gaussFilt<eps*max(gaussFilt(:))) = 0;
         sumFilt = sum(gaussFilt(:));
         if (sumFilt ~= 0)
             gaussFilt  = gaussFilt/sumFilt;
         end
    end
    
    end
    
    function [A, ref, C, exponents, radius] = parse_inputs(varargin)
    
    validImageTypes = {'uint8','uint16','int16','single','double'};
    
    A = varargin{1};
    validateattributes(A,validImageTypes,{'nonsparse','real'},mfilename,'A',1);
    
    ref = varargin{2};
    validateattributes(ref,validImageTypes,{'nonsparse','real'},mfilename,'REF',2);
    
    if ~isa(A,class(ref))
        error(message('images:validate:differentClassMatrices','A','REF'));
    end
        
    if ~isequal(size(A),size(ref))
        error(message('images:validate:unequalSizeMatrices','A','REF'));
    end
    
    if (ndims(A) > 3)
        error(message('images:validate:tooManyDimensions','A and REF',3));
    end
    
    % Default values for parameters
    dynmRange = diff(getrangefromclass(A));        
    C = [];
    exponents = [1 1 1];
    radius = 1.5;
    
    args_names = {'dynamicrange', 'regularizationconstants','exponents',...
                  'radius'};
    
    for i = 3:2:nargin
        arg = varargin{i};
        if ischar(arg)        
            idx = find(strncmpi(arg, args_names, numel(arg)));
            if isempty(idx)
                error(message('images:validate:unknownInputString', arg))
                
            elseif numel(idx) > 1
                error(message('images:validate:ambiguousInputString', arg))
                
            elseif numel(idx) == 1
                if (i+1 > nargin) 
                    error(message('images:validate:missingParameterValue'));             
                end
                if idx == 1
                    dynmRange = varargin{i+1};
                    validateattributes(dynmRange,{'numeric'},{'positive', ...
                        'finite', 'real', 'nonempty','scalar'}, mfilename, ...
                        'DynamicRange',i);
                    dynmRange = double(dynmRange);
                    
                elseif idx == 2
                    C = varargin{i+1};
                    validateattributes(C,{'numeric'},{'nonnegative','finite', ...
                        'real','nonempty','vector', 'numel', 3}, mfilename, ...
                        'RegularizationConstants',i);                              
                    C = double(C);                              
                                  
                elseif idx == 3
                    exponents = varargin{i+1};
                    validateattributes(exponents,{'numeric'},{'nonnegative', ...
                        'finite', 'real', 'nonempty','vector', 'numel', 3}, ...
                        mfilename,'Exponents',i);
                    exponents = double(exponents);
                    
                elseif idx == 4
                    radius = varargin{i+1};
                    validateattributes(radius,{'numeric'},{'positive','finite', ...
                        'real', 'nonempty','scalar'}, mfilename,'Radius',i);
                    radius = double(radius);
                end
            end    
        else
            error(message('images:validate:mustBeString')); 
        end
    end
    
    % If 'RegularizationConstants' is not specified, choose default C.
    if isempty(C)
        C = [(0.01*dynmRange).^2 (0.03*dynmRange).^2 ((0.03*dynmRange).^2)/2];
    end
    
    end
    

    参考链接:

    1. https://blog.csdn.net/xiaohaijiejie/article/details/48053595?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2allbaidu_landing_v2~default-2-48053595.nonecase&utm_term=matlab%E7%9A%84ssim%E5%87%BD%E6%95%B0%E7%94%A8%E6%B3%95
    2. https://www.zhihu.com/question/41539785/answer/92954547
    展开全文
  • PSNR的matlab函数

    2012-12-31 12:12:36
    图像降噪质量评价指标psnr的matlab实现函数
  • matlab实现PSNR

    千次阅读 2019-12-07 22:18:59
    文章目录1.PSNR原理 1.PSNR原理 PSNR,峰值信噪比,通常用来评价一幅图像压缩后和原图像相比质量的好坏,当然,压缩后图像一定会比原图像质量差的,所以就用这样一个评价指标来规定标准了。PSNR越高,压缩后失真越小...

    1.PSNR原理

    PSNR,峰值信噪比,通常用来评价一幅图像压缩后和原图像相比质量的好坏,当然,压缩后图像一定会比原图像质量差的,所以就用这样一个评价指标来规定标准了。PSNR越高,压缩后失真越小。这里主要定义了两个值,一个是均方差MSE,另一个是峰值信噪比PSNR,公式如下:
    在这里插入图片描述
    这里的MAX通常是图像的灰度级,一般就是255了。

    2.PSNR的matlab实现代码

    将图像缩小再放大比较一下,下面是代码:

    close all;
    clear all;
    clc;
    
    img=imread('lena.jpg');
    [h w]=size(img);
    imgn=imresize(img,[floor(h/2) floor(w/2)]);
    imgn=imresize(imgn,[h w]);
    img=double(img);
    imgn=double(imgn);
    
    B=8;                %编码一个像素用多少二进制位
    MAX=2^B-1;          %图像有多少灰度级
    MES=sum(sum((img-imgn).^2))/(h*w);     %均方差
    PSNR=20*log10(MAX/sqrt(MES));           %峰值信噪比
    

    PSNR越高,图像和原图越接近。

    3.针对彩色图像的PSNR的matlab代码

    (a)可以将分别计算R,G,B三个通道总和,最后MSE直接在原公式上多除以3就行(opencv官方代码是这么做的,与matlab直接计算结果是一样的)。
    (b)将R,G,B格式转换为YCbCr,只计算Y分量(亮度分量),结果会比直接计算要高几个dB。
    贴代码,这里是将图片格式转成YCbCr(只计算Y分量):

    function [PSNR, MSE] = psnr(X, Y)
    %%%%%%%%%%%%%%%%%%%%%%%%%%%
    %
    % 计算峰值信噪比PSNR
    % 将RGB转成YCbCr格式进行计算
    % 如果直接计算会比转后计算值要小2dB左右(当然是个别测试)
    %
    %%%%%%%%%%%%%%%%%%%%%%%%%%%
     if size(X,3)~=1   %判断图像时不是彩色图,如果是,结果为3,否则为1
       org=rgb2ycbcr(X);
       test=rgb2ycbcr(Y);
       Y1=org(:,:,1);
       Y2=test(:,:,1);
       Y1=double(Y1);  %计算平方时候需要转成double类型,否则uchar类型会丢失数据
       Y2=double(Y2);
     else              %灰度图像,不用转换
         Y1=double(X);
         Y2=double(Y);
     end
     
    if nargin<2    
       D = Y1;
    else
      if any(size(Y1)~=size(Y2))
        error('The input size is not equal to each other!');
      end
     D = Y1 - Y2; 
    end
    MSE = sum(D(:).*D(:)) / numel(Y1); 
    PSNR = 10*log10(255^2 / MSE);
    

    然后写主函数

     X= imread('C:\Users\Administrator\Desktop\noise_image.jpg');
     Y= imread('C:\Users\Administrator\Desktop\actruel_image.jpg');
     psnr(X, Y)
    
    展开全文
  • PYTHON 计算PSNR

    千次阅读 2019-03-18 22:25:51
    PSNR 计算公式 对于一张RGB三通道图像,其计算公式如下: 先计算图像与Ground Truth的均方误差MSE: 再计算PSNR: python 实现 网上的实现有下面两种: import imageio import numpy as np import math def psnr1...

    PSNR 计算公式

    对于一张RGB三通道图像,其计算公式如下:

    先计算图像与Ground Truth的均方误差MSE:
    在这里插入图片描述

    再计算PSNR:

    在这里插入图片描述

    python 实现

    网上的实现有下面两种:

    import imageio
    import numpy as np
    import math
     
    def psnr1(img1, img2):
       mse = np.mean((img1/1.0 - img2/1.0) ** 2 )
       if mse < 1.0e-10:
          return 100
       return 10 * math.log10(255.0**2/mse)
     
    def psnr2(img1, img2):
       mse = np.mean( (img1/255. - img2/255.) ** 2 )
       if mse < 1.0e-10:
          return 100
       PIXEL_MAX = 1
       return 20 * math.log10(PIXEL_MAX / math.sqrt(mse))
    
    gt = imageio.imread('1.jpg')
    img= imageio.imread('2.jpg')
    
    print(psnr1(gt,img))
    print(psnr2(gt,img))
    

    注意点:

    1. 使用imageio的原因是在使用scipy.misc.imread()的时候,被提示这个写法将被丢弃,所以大家也可以选择导入这个新的模块来进行图像的读写等操作。

    2. 其中psnr1函数中在两个数组相减前除以1.0,是为了将数组的类型从uint类型转化为float类型。

    转载:https://blog.csdn.net/u010886794/article/details/84784453

    展开全文
  • 自选一幅图像,并对其分别添加一定强度的周期噪声和高斯噪声,然后分别采用高斯模板、中值滤波的时域方法以及傅里叶变换和小波变换的频率滤波方法对该含噪图像进行去噪处理,并基于PSNR值和视觉效果这两个指标来比较...
  • 在matlab中的PSNR图像

    2021-04-18 11:22:32
    我对原始图像和加密图像之间的峰值信噪比(PSNR)感到困惑。据我所知,PSNR值越高意味着图像质量越好。我试着测试并计算PSNR值。我在文本隐写术中使用了LSB技术。我尝试在图片中嵌入100个字符。结果为69.9696 dB。我...
  • 深入理解PSNR 作者:老李 日期:2022-1-19 本文引入MSE、SNR、变异系数(Coefficient of Variation),并希望从统计学的角度上解释这个变量 这个变量。 PSNR是“Peak Signal to Noise Ratio”的缩写,即峰值信噪比。...
  • python/c++计算psnr

    2021-11-05 09:22:35
    def psnr(target, ref): #将图像格式转为float64 target_data = np.array(target, dtype=np.float64) ref_data = np.array(ref,dtype=np.float64) # 直接相减,求差值 diff = ref_data - target_data # 按第三...
  • PSNR源代码

    2014-07-28 11:41:05
    PSNR源代码,我自己写的,已经运行成功过,希望对大家有帮助!
  • Python之PSNR

    千次阅读 2020-07-07 11:03:25
    print('img1的图像shape:',img1.shape) print('img2的图像shape:',img2.shape) # 计算PSNR的值 def psnr(img1, img2): mse = np.mean((img1 - img2) ** 2 ) if mse == 0: return 100 PIXEL_MAX = 255.0 return 20 * ...
  • python设计PSNR和SSIM计算函数

    多人点赞 2021-05-26 17:43:23
    PSNR import numpy as np import math def PSNR(x, y): MSE = np.mean((x/255. - y/255.)**2) if MSE<1.0e-10: return 100 MAX = 1 return 20*math.log10(MAX/math.sqrt(MSE)) SSIM import numpy as np ...
  • matlab ---PSNR

    千次阅读 2015-11-08 14:22:52
    PSNR,峰值信噪比,通常用来评价一幅图像压缩后和原图像相比质量的好坏,当然,压缩后图像一定会比原图像质量差的,所以就用这样一个评价指标来规定标准了。PSNR越高,压缩后失真越小。这里主要定义了两个值,一个是...
  • MATLAB--数字图像处理 PSNR

    千次阅读 2019-10-11 20:48:45
    PSNR 概念 psnr是“Peak Signal to Noise Ratio”的缩写,即峰值信噪比,是一种评价图像的客观标准,它具有局限性,一般是用于最大值信号和背景噪音之间的一个工程项目。 PSNR的单位为dB。值越大,代表失真越少。 ...
  • PSNR-峰值信噪比(原理及python代码实现)

    万次阅读 多人点赞 2018-11-28 16:40:30
    PSNR的全称为“Peak Signal-to-Noise Ratio”,直译为中文就是峰值信噪比。 是一种衡量图像质量的指标。在很多领域都会需要这个指标,比如在超分辨率重建图像的时候,PSNR就是很重要的指标了。 WIKI解释 峰值...
  • Python计算两张图的PSNR

    千次阅读 2021-12-21 12:35:39
    Python计算两张图的PSNR值     本文主要记录如何用python实现求解两张图的PSNR值。 目录Python计算两张图的PSNR值1.PSNR求解公式2.完整的PSNR求解代码3.运算结果展示4.参考文献 1.PSNR求解公式     (1)...
  • 质量指标相关的理论文章网上已经有很多了,代码写不出?... 峰值信噪比PSNR: https://ww2.mathworks.cn/help/images/ref/psnr.html 结构相似性SSIM: https://ww2.mathworks.cn/help/images/ref/ssim.html
  • 图像质量评价指标之 PSNR 和 SSIM

    千次阅读 2020-12-08 12:16:01
    1. PSNR (Peak Signal-to-Noise Ratio) 峰值信噪比 给定一个大小为m×nm×n的干净图像II和噪声图像KK,均方误差(MSE)(MSE)定义为: 然后PSNR(dB)PSNR(dB)就定义为: 其中为图片可能的最大像素值。如果每个...
  • 自己写的"计算峰值信噪比PSNR"的matlab函数,有详细注释.应该是初学者想要的.
  • 图像处理PSNR及其计算(OpenCV和matlab实现)

    万次阅读 多人点赞 2016-05-27 19:42:19
    图像PSNR及其计算OpenCV和matlab实现 PSNR的概念 PSNR编程实现 matlab实现 第一种实现方法 第二种实现方法 OpenCV实现图像PSNR及其计算(OpenCV和matlab实现) 引言:在图像处理中,要对图像进行客观的评价,常常...
  • 通过callback回调啊!仔细研究下这个程序就好 clf resetH=axes('unit','normalized','position',[0,0,1,1],'visible','off');set(gcf,'currentaxes',H);str='\fontname{隶书}归一化二阶系统的阶跃响应曲线';...
  • PSNR的全称为“Peak Signal-to-Noise Ratio”,直译为中文就是峰值信噪比。 是一种衡量图像质量的指标。在很多领域都会需要这个指标,比如在超分辨率重建图像的时候,PSNR就是很重要的指标了。 WIKI解释 峰值...
  • PSNR

    千次阅读 2018-12-18 17:37:27
    PSNR(Peak Signal to Noise Ratio)峰值信噪比,是一种全参考的图像质量评价指标。 其中,MSE表示当前图像X和参考图像Y的均方误差(MeanSquare Error),H、W分别为图像的高度和宽度;n为每像素的比特数,一般取8...
  • 计算均方误差MSE信噪比SNR峰值信噪比PSNR绝对平均误差的matlab函数
  • PSNR峰值信噪比matlab实现

    万次阅读 2017-08-01 17:30:33
    PSNR,峰值信噪比,通常用来评价一幅图像压缩后和原图像相比质量的好坏,当然,压缩后图像一定会比原图像质量差的,所以就用这样一个评价指标来规定标准了。PSNR越高,压缩后失真越小。这里主要定义了两个值,一个是...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 4,410
精华内容 1,764
关键字:

psnr函数