当前位置:   article > 正文

matlab 实现点击图像绘制相应像素点的光谱曲线

matlab 实现点击图像绘制相应像素点的光谱曲线

点击鼠标左键绘制对应光谱图像,点击鼠标中键暂停绘制,直到下一次点击鼠标中键再继续绘制

clc;close all;clear

t = Tiff('GF1.tif');
imageData = double(read(t));
imageData = normalize(imageData);

figure

fig = figure;
imshow(imageData(:, :, 3));

isPaused = false;
while true
    impixelinfo(fig);
    [x, y, button] = ginput(1);    
    if strcmp(get(gcf, 'SelectionType'), 'extend')
        isPaused = ~isPaused;
    end
    while isPaused
        buttonInfo = waitforbuttonpress;
        % if strcmp(get(gcf, 'SelectionType'), 'alt')
        if strcmp(get(gcf, 'SelectionType'), 'extend')
            isPaused = false;
        end
    end    
    pixelValue = squeeze(imageData(round(y), round(x), :));
    figure(1)
    plot(pixelValue);
    plotTitle = title(['Spectral Curve', 'x:', num2str(x), 'y:', num2str(y)]);
    xlabel('Band');
    ylabel('Pixel Value');    
    ylim([0, 1])
    pause(0.1)

end




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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/53240
推荐阅读
相关标签
  

闽ICP备14008679号