📄 dispimgs.m
字号:
function [f1,a1]=dispimgs(img,fac,txt,mps,img1,v1,img2,v2,img3,v3)
%DISPIMGS Displays an image with coloured overlays
% [f1,a1]=dispimgs(img,fac,txt,mps,img1,v1,img2,v2,img3,v3)
%
% img: matrix containing the image, will be scaled into available map
% as gray levels
% fac: magnifying factor (size of displayed pixels)
% txt: up to 3 lines of text will be displayed in Figure head, title
% and x-label. Hint: use str2mat to combine the two or three
% text labels, trailing blanks will be removed.
% mps: size of the colour map (some systems handle mps<256 better??)
% default 255
% imgx,vx: none or up to 3 of these pairs may be present. They should be
% integer valued in the range 0:vx. Those with positive value
% will ovelay the gray img with coloured pixels, samples of
% which will appear in top left corner of the image, i.e.
% 1:vx in the x-th row, x=1,2,3 (if present).
% In the image, img3 (green) will overlay img2 (blue), etc.,
% img1 will be red (value vx) fading down into red/orange.
%
% f1,a1: handles to figure and axis
%
% Copyright Kautsky J.
% UTIA, 1998
larg=10; % last input argument
if nargin<4, mapsize=255; else mapsize=round(mps(1)); end
if nargin<3, txt=[]; end
stx=size(txt,1);
rowh1=0; if stx>1, rowh1=30; end
rowh2=0; if stx>2, rowh2=30; end
map=[];
% prepare additional colour maps if needed
if nargin<larg, v3=0;
else
tt=gray(2*v3);
map=[tt((v3:-1:1),1) tt((v3+1:2*v3),1) zeros(v3,1)];
end
if nargin<larg-2, v2=0;
else
tt=gray(2*v2);
map=[[zeros(v2,1) tt((v2:-1:1),1) tt((v2+1:2*v2),1)];map];
end
if nargin<larg-4, v1=0;
else
tt=gray(2*v1);
map=[[tt((v1+1:2*v1),1) zeros(v1,1) tt((v1:-1:1),1)];map];
end
% now the gray level map
end1=mapsize-v1-v2-v3;
map=[gray(end1);map];
[n,m]=size(img);
% rescale img into 1 .. end1
a1=min(img(:));
a2=max(img(:));
rho=(end1-1)/(a2-a1);
imgsc=round((img-a1)*rho+1);
% add other images
if v1>0
img1(1,1:v1)=1:v1; % samples
finimg=imgsc.*(~img1)+img1+ end1*(img1~=0);
else
finimg=imgsc;
end
if v2>0
img2(2,1:v2)=1:v2; % samples
finimg= finimg.*(~img2)+img2+ (end1+v1)*(img2~=0);
end
if v3>0
img3(3,1:v3)=1:v3; % samples
finimg= finimg.*(~img3)+img3+ (end1+v1+v2)*(img3~=0);
end
% placing figure at {100,200} is rather arbitrary ...
pom=[100,200,round(fac*m),round(fac*n)+rowh1+rowh2];
if stx>0
headtitl=deblank(txt(1,:));
else
headtitl='Image by DISPIMGS';
end
f1=figure('Position',pom,'Resize','off','Name',headtitl, ...
'UserData',img,'Colormap',map);
h=uimenu('Label','Menu');
h1=uimenu(h,'Label',...
'Quit','Callback','delete(gcf)');
pom=[0,rowh2,round(fac*m),round(fac*n)];
a1=axes('Units','pixels','Position',pom,'Box','on');
set(a1,'Visible','off');
image(finimg);
axis equal;
axis off;
set(a1,'Units','normalized');
if rowh1>0
title(deblank(txt(2,:)));
end
if rowh2>0
xlabel(deblank(txt(3,:)),'Visible','on');
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -