标签:point code ati format span tla 假设 als def
\[g(x,y)=T[f(x,y)]\]
g=imadjust(f,[low_in high_in],[low_out high_out],gamma)
f=imread(‘Fig0203(a).tif‘);
g1=imadjust(f,[0 1],[1 0]);
g2=imadjust(f,[0.5 0.75],[0 1]);
g3=imadjust(f,[],[],2);
g4=imadjust(f,stretchlim(f),[]);
g5=imadjust(f,stretchlim(f),[1 0]);
subplot(231);imshow(f);xlabel(‘(a)‘);
subplot(232);imshow(g1);xlabel(‘(b)‘);
subplot(233);imshow(g2);xlabel(‘(c)‘);
subplot(234);imshow(g3);xlabel(‘(d)‘);
subplot(235);imshow(g4);xlabel(‘(e)‘);
subplot(236);imshow(g5);xlabel(‘(f)‘);
g1=imadjust(f,[0 1],[1 0]);
g2=imadjust(f,[0.5 0.75],[0 1]);
g3=imadjust(f,[],[],2);
Low_high=stretchlim(f)
g4=imadjust(f,stretchlim(f),[]);
g5=imadjust(f,stretchlim(f),[1 0]);
Low_high=stretchlim(f,tol)
g=c*log(1+(f))
gs=im2uint8(mat2gray(g));
f=imread(‘Fig0205(a).tif‘);
g=im2uint8(mat2gray(log(1+double(f))));
subplot(1,2,1);imshow(f);xlabel(‘(a)‘);
subplot(1,2,2);imshow(g);xlabel(‘(b)‘);
n=nargin
n=nargout
>>T=testhv(4,5)
msg=nargchk(low,high,number)
function G=testhv2(x,y,z)
.
.
.
error(nargchk(2,3,nargin));
.
.
.
>>testhv2(6)
Not enough input arguments
function [m,n]=testhv3(varargin)
function [varargout]=testhv4(m,n,p)
function [m,n]=testhv3(x,varargin)
>>[m,n]=testhv3(f,[0 0.5 1.5],A,‘label‘);
[g,revertclass]=tofloat(f)
function g=intrans2(f,method,varargin)
%Intras performs intensity (gray-level) transformations
% G=INTRANS(F,‘neg‘) computes the negative of input image F.
% G=INTRANS(F,‘log‘,C,CLASS) computes log(1+F) and multiplies the result
% by constant C. If the last two parameters are ommitted, C defaults to 1.
% Because the log is used frequently to display Fourier spectra, parameter
% CLASS offers the option to specify the class of the output as ‘uint8‘ or
% ‘uint16‘. If parameter CLASS is ommitted, the output is of thr same class
% as the input
%G=INTRANS(F,‘gamma‘,GAM) performs a gamma transformation on the input
%image using parameter GAM
%G+INTRANS(F,‘stretch‘,M,E) computes a constrast-stretching transformation
%using the expression 1./(1+(M./(F+eps).^E)). Parameter M Must be in the
%range [0,1], The default value for M is mean2(tofloat(F)), and the
%default value for E is 4
%G=INTRANS(F,‘specified‘,TXFUN) performances the intensity transformation
%s=TXFUN(r) where r are input intensities, s are output intensities, and
%TXFUN is an intensity transformation function, expressed as a vector with
%values in the range [0,1]. TXFUN must have at least two values.
%For the ‘neg‘, ‘gamma‘, and ‘stretch‘ transformations, floating-point input images
%whose values are outside the range [0,1] are scaled first using mat2gray.
%Other images are converted to floating point using tofloat. For the ‘log‘
%transformation, floating-point images are transformed without being scaled;other
%images are converted to floating point first using tofloat
%Verify the correct number of inputs
narginchk(2,4);
if strcmp(method,‘log‘);
%The log transform handles image classes differently than the other
%trnasforms, so let the logTransform function handle that and then
%return.
g=logTransform(f,varargin(:));
return;
end
%if f is floating point, check to see if it is in the range [0 1].
%If it is not, force it to be using function mat2gray.
if isfloat(f) && (max(f(:))>1 || min(f(:))<0)
f=mat2gray(f);
end
[f,revertclass]=tofloat(f);%store class of f for use later.
%Perfor the intensity transformation specified.
switch method
case ‘neg‘
g=imcomplement(f);
case ‘gamma‘
g=gammaTransform(f,varargin{:});
case ‘stretch‘
g=stretchTransform(f,varargin{:});
case ‘specified‘
g=spcfiedTransform(f,varargin{:});
otherwise
error(‘unknown enhancement method.‘)
end
%Convert to the class of the input image.
g=revertclass(g);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [out,revertclass]=tofloat(in)
%Tofloat Convert image to floating point
%[OUT,REVERTCLASS]=TOFLOAT(IN) converts the input image IN to
%floating-point. if IN is a double or single image, then OUT equals IN.
%Othereise, OUT equals im2single(IN). Revertcalss is a function handle that
%can be used to convert back to the class of IN
identity=@(x)x;
tosingle=@im2single;
table={‘uint8‘,tosingle,@im2uint8
‘uint16‘,tosingle,@im2uint16
‘int16‘,tosingle,@im2int16
‘logical‘,tosingle,@logical
‘double‘,identity,identity
‘single‘,identity,identity};
classIndex=find(strcmp(class(in),table(:,1)));
if isempty(classIndex)
error(‘Unsupported input image calss.‘);
end
out=table{classIndex,2}(in);
revertclass=table{classIndex,3};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function g=gammaTransform(f,gamma)
g=imadjust(f,[],[],gamma);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function g=stretchTransform(f,varargin)
if isempty(varargin)
%Use defaults
m=mean2(f);
E=4.0;
elseif length(varargin) == 2
m=varargin{1};
E=varargin{2};
else
error(‘Incorrect number of inputs for the stretch method.‘);
end
g=1./(1+(m./f).^E);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function g=spcfiedTransform(f,txfun)
%f is floating point with values in the range [0 1]
txfun=txfun(:);%Force it to be a column vector.
if any(txfun)>1 || any(txfun)<=0
error(‘All elements of txfun must be in the range [0 1].‘)
end
T=txfun;
X=Linspace(0,1,numel(T))‘;
g=interpl(X,T,f);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function g=logTransform(f,varargin)
[f,revertclass]=tofloat(f);
if numel(varargin)>=2
if strcmp(varargin{2},‘uint8‘)
revertclass=@im2uint8;
elseif strcmp(varargin{2},‘uint16‘)
revertclass=@im2uint16;
else
error(‘Unsupported CLASS option for ‘‘log‘‘ method.‘)
end
end
if numel(varargin)<1
% Set default for C.
C=1;
else
C=varargin{1};
end
g=C*(log(1+f));
g=revertclass(g);
>> f=imread(‘Fig0306(a).tif‘);
>> g=intrans2(f,‘stretch‘,mean2(im2double(f)),0.9);
>> subplot(121);imshow(f);subplot(122);imshow(g);
function g=gscale(f,varargin)
%GSCALE Scales the intensity of the input image
% G=GSCALE(F,‘full8‘) scales the intensity of F to the full 8-bit intensity
% range [0,255]. This is the default if there is only one input argument.
%
% G=GSCALE(F,‘full16‘) scales the intensities of F to the full 16-bit
% intensity range [0,65535].
%
% G=GSCALE(F,‘minmax‘,LOW,HIGH) scales the intensities of F to the range
% [LOW,HIGH]. These values must be provided, and they must be in the range
% [0,1], independently of the class of the input. GSCALE performs any
% necessary scaling. If the input is of class double, and its values are
% not in the range [0,1], then GSCALE scales it to this range before
% processing.
%
% The class of the output is the same as the class of the input.
if length(varargin)==0 % If only one argument it must be f.
method=‘full8‘;
else
method=varargin{1};
end
if strcmp(class(f),‘double‘) & (max(f(:))>1 | min(f(:))<0)
f=mat2gray(f);
end
% Perform the specified scaling.
switch method
case ‘full8‘
g=im2uint8(mat2gray(double(f)));
case ‘full19‘
g=im2uint16(mat2gray(double(f)));
case ‘minmax‘
low=varargin{2};high=varargin{3};
if low >1 | low<0 | high>1 | high<0
error(‘Parameters low and high must be in the range [0,1].‘)
end
if strcmp(class(f),‘double‘)
low_in=min(f(:));
hign_in=max(f(:));
elseif strcmp(class(f),‘uint8‘)
low_in=double(min(f(:)))./255;
high_in=double(max(f(:)))./255;
elseif strcmp(class(f),‘uint16‘)
low_in=double(min(f(:)))./65535;
high_in=double(max(f(:)))./65535;
end
% imadjust automatically matches the class of the input.
g=imadjust(f,[low_in high_in],[low high]);
otherwise
error(‘Unknown method.‘)
end
g=gscale(f,method,low,high)
标签:point code ati format span tla 假设 als def
原文地址:https://www.cnblogs.com/SweetZxl/p/9219645.html