spfunctions.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:spfeas 作者: jgrss 项目源码 文件源码
def saliency(i_info, parameter_object, i_sect, j_sect, n_rows, n_cols):

    """
    References:
        Federico Perazzi, Philipp Krahenbul, Yael Pritch, Alexander Hornung. Saliency Filters. (2012).
            Contrast Based Filtering for Salient Region Detection. IEEE CVPR, Providence, Rhode Island, USA, June 16-21.

            https://graphics.ethz.ch/~perazzif/saliency_filters/

        Ming-Ming Cheng, Niloy J. Mitra, Xiaolei Huang, Philip H. S. Torr, Shi-Min Hu. (2015).
            Global Contrast based Salient Region detection. IEEE TPAMI.
    """

    # min_max = sputilities.get_layer_min_max(i_info)
    min_max = [(parameter_object.image_min, parameter_object.image_max)] * 3

    if parameter_object.vis_order == 'bgr':
        lidx = [2, 1, 0]
    else:
        lidx = [0, 1, 2]

    # Read the section.
    layers = i_info.read(bands2open=[1, 2, 3],
                         i=i_sect,
                         j=j_sect,
                         rows=n_rows,
                         cols=n_cols,
                         d_type='float32')

    layers = scale_rgb(layers, min_max, lidx)

    # Transpose the image to RGB
    layers = layers.transpose(1, 2, 0)

    # Perform RGB to CIE Lab color space conversion
    layers = rgb2rgbcie(layers)

    # Compute Lab average values
    # lm = layers[:, :, 0].mean(axis=0).mean()
    # am = layers[:, :, 1].mean(axis=0).mean()
    # bm = layers[:, :, 2].mean(axis=0).mean()
    lm = parameter_object.lab_means[0]
    am = parameter_object.lab_means[1]
    bm = parameter_object.lab_means[2]

    return np.uint8(rescale_intensity((layers[:, :, 0] - lm)**2. +
                                      (layers[:, :, 1] - am)**2. +
                                      (layers[:, :, 2] - bm)**2.,
                                      in_range=(-1, 1),
                                      out_range=(0, 255)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号