当前位置: 首页>>代码示例>>Python>>正文


Python measure.compare_psnr方法代码示例

本文整理汇总了Python中skimage.measure.compare_psnr方法的典型用法代码示例。如果您正苦于以下问题:Python measure.compare_psnr方法的具体用法?Python measure.compare_psnr怎么用?Python measure.compare_psnr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在skimage.measure的用法示例。


在下文中一共展示了measure.compare_psnr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: compare

# 需要导入模块: from skimage import measure [as 别名]
# 或者: from skimage.measure import compare_psnr [as 别名]
def compare(inp_img, out_img, calc_ssim=True, calc_msssim=True, calc_psnr=True):
    inp_img = _read_if_not_array(inp_img)
    out_img = _read_if_not_array(out_img)

    assert inp_img.shape == out_img.shape

    def get_ssim():
        return compare_ssim(inp_img, out_img, multichannel=True, gaussian_weights=True, sigma=1.5)

    def get_msssim():
        return MultiScaleSSIM(make_batched(inp_img), make_batched(out_img))

    def get_psnr():
        return compare_psnr(inp_img, out_img)

    def _run_if(cond, fn):
        return fn() if cond else None

    return _run_if(calc_ssim, get_ssim), _run_if(calc_msssim, get_msssim), _run_if(calc_psnr, get_psnr) 
开发者ID:fab-jul,项目名称:imgcomp-cvpr,代码行数:21,代码来源:compare_imgs.py

示例2: slice_process

# 需要导入模块: from skimage import measure [as 别名]
# 或者: from skimage.measure import compare_psnr [as 别名]
def slice_process(x1, x2, y):
    if len(x1.shape) == 3: x1 = x1[0,:,:]
    if len(x2.shape) == 3: x2 = x2[0,:,:]
    if len(y.shape) == 3: y = y[0,:,:]

    # a scaled and shifted version of pred and bilinear
    x1 = 2*x1 + 100
    x2 = 2*x2 + 100

    # normalize/scale images
    (y_norm1, x1_norm) = norm_minmse(y, x1)
    (y_norm2, x2_norm) = norm_minmse(y, x2)

    # calulate psnr and ssim of the normalized/scaled images
    psnr1 = compare_psnr(*(y_norm1, x1_norm), data_range = 1.)
    psnr2 = compare_psnr(*(y_norm2, x2_norm), data_range = 1.)
    ssim1 = compare_ssim(*(y_norm1, x1_norm), data_range = 1.)
    ssim2 = compare_ssim(*(y_norm2, x2_norm), data_range = 1.)
    return psnr1, ssim1, psnr2, ssim2, y_norm1, x1_norm, y_norm2, x2_norm 
开发者ID:BPHO-Salk,项目名称:PSSR,代码行数:21,代码来源:metric_gen.py

示例3: compute_psnr_and_ssim

# 需要导入模块: from skimage import measure [as 别名]
# 或者: from skimage.measure import compare_psnr [as 别名]
def compute_psnr_and_ssim(image1, image2, border_size=0):
    """
    Computes PSNR and SSIM index from 2 images.
    We round it and clip to 0 - 255. Then shave 'scale' pixels from each border.
    """
    if len(image1.shape) == 2:
        image1 = image1.reshape(image1.shape[0], image1.shape[1], 1)
    if len(image2.shape) == 2:
        image2 = image2.reshape(image2.shape[0], image2.shape[1], 1)

    if image1.shape[0] != image2.shape[0] or image1.shape[1] != image2.shape[1] or image1.shape[2] != image2.shape[2]:
        return None

    image1 = trim_image_as_file(image1)
    image2 = trim_image_as_file(image2)

    if border_size > 0:
        image1 = image1[border_size:-border_size, border_size:-border_size, :]
        image2 = image2[border_size:-border_size, border_size:-border_size, :]

    psnr = compare_psnr(image1, image2, data_range=255)
    ssim = compare_ssim(image1, image2, win_size=11, gaussian_weights=True, multichannel=True, K1=0.01, K2=0.03,
                        sigma=1.5, data_range=255)
    return psnr, ssim 
开发者ID:jiny2001,项目名称:dcscn-super-resolution,代码行数:26,代码来源:utilty.py

示例4: psnr

# 需要导入模块: from skimage import measure [as 别名]
# 或者: from skimage.measure import compare_psnr [as 别名]
def psnr(gt, pred):
    """ Compute Peak Signal to Noise Ratio metric (PSNR) """
    return compare_psnr(gt, pred, data_range=gt.max()) 
开发者ID:facebookresearch,项目名称:fastMRI,代码行数:5,代码来源:evaluate.py

示例5: calculate_psnr

# 需要导入模块: from skimage import measure [as 别名]
# 或者: from skimage.measure import compare_psnr [as 别名]
def calculate_psnr(output_img, target_img):
    target_tf = torch2numpy(target_img)
    output_tf = torch2numpy(output_img)
    psnr = 0.0
    n = 0.0
    for im_idx in range(output_tf.shape[0]):
        psnr += compare_psnr(target_tf[im_idx, ...],
                                             output_tf[im_idx, ...],
                                             data_range=255)
        n += 1.0
    return psnr / n 
开发者ID:z-bingo,项目名称:FastDVDNet,代码行数:13,代码来源:data_utils.py

示例6: get_psnr

# 需要导入模块: from skimage import measure [as 别名]
# 或者: from skimage.measure import compare_psnr [as 别名]
def get_psnr(im1, im2):
    return compare_psnr(im1, im2, data_range=255) 
开发者ID:cydonia999,项目名称:Learning_to_See_in_the_Dark_PyTorch,代码行数:4,代码来源:utils.py

示例7: __compare_psnr

# 需要导入模块: from skimage import measure [as 别名]
# 或者: from skimage.measure import compare_psnr [as 别名]
def __compare_psnr(planes):
  a, b = planes
  if (a == b).all():
    # Avoid "Warning: divide by zero encountered in double_scalars" generated
    # by skimage.measure.compare_psnr when a and b are exactly the same.
    return 100
  return skimage_psnr(a, b) 
开发者ID:intel,项目名称:vaapi-fits,代码行数:9,代码来源:metrics.py

示例8: psnr

# 需要导入模块: from skimage import measure [as 别名]
# 或者: from skimage.measure import compare_psnr [as 别名]
def psnr(im1, im2):
    def im2double(im):
        min_val, max_val = 0, 255
        out = (im.astype(np.float64)-min_val) / (max_val-min_val)
        return out
        
    im1 = im2double(im1)
    im2 = im2double(im2)
    psnr = measure.compare_psnr(im1, im2, data_range=1)
    return psnr 
开发者ID:nmhkahn,项目名称:CARN-pytorch,代码行数:12,代码来源:solver.py

示例9: psnr

# 需要导入模块: from skimage import measure [as 别名]
# 或者: from skimage.measure import compare_psnr [as 别名]
def psnr(y_true, y_pred, max_value=2):
  psnr_metric = measure.compare_psnr(y_true, y_pred, max_value)
  return psnr_metric 
开发者ID:tlatkowski,项目名称:inpainting-gmcnn-keras,代码行数:5,代码来源:metrics.py

示例10: mpsnr

# 需要导入模块: from skimage import measure [as 别名]
# 或者: from skimage.measure import compare_psnr [as 别名]
def mpsnr(x_true, x_pred):
    """

    :param x_true: 高光谱图像:格式:(H, W, C)
    :param x_pred: 高光谱图像:格式:(H, W, C)
    :return: 计算原始高光谱数据与重构高光谱数据的均方误差
    References
    ----------
    .. [1] https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio
    """
    n_bands = x_true.shape[2]
    p = [compare_psnr(x_true[:, :, k], x_pred[:, :, k], dynamic_range=np.max(x_true[:, :, k])) for k in range(n_bands)]
    return np.mean(p) 
开发者ID:JiJingYu,项目名称:tensorflow-exercise,代码行数:15,代码来源:hsi_evaluate.py

示例11: get_psnr

# 需要导入模块: from skimage import measure [as 别名]
# 或者: from skimage.measure import compare_psnr [as 别名]
def get_psnr(self, img_true, img_gen):
        return compare_psnr(img_true.astype(np.float32), img_gen.astype(np.float32)) 
开发者ID:arnavkj1995,项目名称:face_inpainting,代码行数:4,代码来源:model.py

示例12: PSNR

# 需要导入模块: from skimage import measure [as 别名]
# 或者: from skimage.measure import compare_psnr [as 别名]
def PSNR(self, gt, pred):
    #gt = gt.astype(np.float64)
    #pred = pred.astype(np.float64)
    #mse = np.mean((pred - gt)**2)
    #psnr = 10*np.log10(255*255/mse)
    #return psnr
    return compare_psnr(gt, pred, data_range=255) 
开发者ID:trevor-m,项目名称:tensorflow-SRGAN,代码行数:9,代码来源:benchmark.py

示例13: test_bm3d

# 需要导入模块: from skimage import measure [as 别名]
# 或者: from skimage.measure import compare_psnr [as 别名]
def test_bm3d(noise_data):
    """Tests BM3D grayscale image denoising."""
    img, noisy_img, noise_std_dev = noise_data

    out = pybm3d.bm3d.bm3d(noisy_img, noise_std_dev)

    noise_psnr = compare_psnr(img, noisy_img)
    out_psnr = compare_psnr(img, out)

    assert out_psnr > noise_psnr 
开发者ID:ericmjonas,项目名称:pybm3d,代码行数:12,代码来源:test_bm3d.py

示例14: test_bm3d_color

# 需要导入模块: from skimage import measure [as 别名]
# 或者: from skimage.measure import compare_psnr [as 别名]
def test_bm3d_color(color_noise_data):
    """Tests BM3D color image denoising."""
    img, noisy_img, noise_std_dev = color_noise_data

    out = pybm3d.bm3d.bm3d(noisy_img, noise_std_dev)

    noise_psnr = compare_psnr(img, noisy_img)
    out_psnr = compare_psnr(img, out)

    assert out_psnr > noise_psnr 
开发者ID:ericmjonas,项目名称:pybm3d,代码行数:12,代码来源:test_bm3d.py

示例15: calcPSNR

# 需要导入模块: from skimage import measure [as 别名]
# 或者: from skimage.measure import compare_psnr [as 别名]
def calcPSNR(self, image1, image2):
        image1 *= 255
        image2 *= 255
        image1[image1>255] = 255
        image1[image1<0] = 0
        image2[image2>255] = 255
        image2[image2<0] = 0
        return compare_psnr(image1, image2, data_range=255) 
开发者ID:sg-nm,项目名称:Evolutionary-Autoencoders,代码行数:10,代码来源:cnn_train.py


注:本文中的skimage.measure.compare_psnr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。