点击鼠标左键绘制对应光谱图像,点击鼠标中键暂停绘制,直到下一次点击鼠标中键再继续绘制
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