高光谱图像可视化 视觉增强matlab函数

function I=rsshow_bandwise(I, scale)
    if nargin==1
        scale=0.005;
    end
    I = double(I);
    for i = 1:size(I,3)
        band = I(:,:,i);
        q = quantile(band(:),[scale, 1-scale]);
        [low, high] = deal(q(1),q(2));
        band(band>high) = high;
        band(band<low) = low;
        band = (band-low)/(high-low);
        I(:,:,i)=band;
    end
end

function I = normalize(I)
    low = min(I(:));
    high = max(I(:));
    I = (I - low) / (high - low);
end

高光谱图像可视化 视觉增强python函数

def rsshow_bandwise(I, scale=0.005):
    num_band = I.shape[-1]
    I = I.astype(np.double)
    for i in range(num_band):
        band = I[:,:,i]
        low, high = np.quantile(band, [scale, 1-scale])
        band[band > high] = high
        band[band < low] = low
        band = (band-low)/(high-low)
        I[:, :, i] = band
    return I

def rsshow(I, scale=0.005):
    low, high = np.quantile(I, [scale, 1-scale])
    I[I > high] = high
    I[I < low] = low
    I = (I-low)/(high-low)
    return I

def normalize(I):
    low, high = I.min(), I.max()
    I = (I - low) / (high - low)
    return I
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐