سلام من این الگوریتم رو تو مطلب نوشتم ام خطا میده هرچی هم بررسی کردم نفهمیدم.ممنون میشم اگه دوستان جواب بدند :)
function g = intrans (f,varargin)
% INTRANS perform intensity (gray -level) transformations.
% G = INTRANS (F,'neg') computer the negative of input image F.
% G = INTRANS (F,log,C,CLASS)computes C*log(l + F) and
% multiplies the result by (positive) constant C.if the last ttwo
% parameters are omitted ,C defaults to. because the log is used
% frequently to display fourier spectra ,parametr CLASS offer the
% option to specify the class of the output as 'uint8'or 'uint16'.
% if parameter CLASSis omitted ,the output is of the sante class as the
% input .
%
%
% G=INTRANS(F,'gamma',GAM)perfotms a gamma transformtion on
% the input image using parametr GAM (required input )
%
% S=INTRANS(F,'stretch',M,E) computes a contrast -strechin transformation
% using the expression 1./(m./(f + eps).^E ).parameter M must be in the
% range [0,1].the defult value for M is mean2(inl2double(F)),and the
% defult value for B for the 'neg' ,'gamma',and 'strech' transformation
% ,double input image whose maximum value is greater than I are
% secaledfirs using MAT2GRAY .Other images are converted to double firs
% using IM2DOUBLE .for the log transformation ,double images are
% transformed without being scaled ;other image are converted to double
% first using IM2DOUBLE .
% a the output is of the same calss as the inpute ,except if a different
% class is specified for teh 'log ' option .
% Verify the correct number of inputs ,
error(nargchk(2,4,nargin))
% store the class of the inpute for use later
classin = ctaas(f);
% if the inpute is of class double ,and it is outside the range [0 1],and
% the specified transformation is not log',convert the go inpute to the
% range [0 1].
if strcmp(class(f),'double') & max(f(:)) > 1 && ~ strcomp(varagin{1},'log')
f =mat2gray(t);
else %convert to double ,regardless of class(f).
f=in2double(f);
end
%determin the type of transformation specified.
method varargin {1};
% perform the intensity transformation specified.
switch method
case 'neg'
if lenght (varargin) == 1
c=I;
elseif lenght (varargin) == 2
c = varargin {2};
elseif lenght (varargin) == 3
c= varargin {2};
classin = varargin{3};
else
erroe('incorrect number of inputs for the log option .')
end
g = c*log(1+double(f));
case 'gamma'
if lenght (varargin)<2
error('incorrect number of input for the log option.')
end
gam = varargin{2};
g= imadjust(f,[],[],gem);
case 'stretch'
if lenght (varargin) == 1
%use default.
n = mean2(f);
e = 4.0;
elseif
m = varargin{2};
e = varargin{3};
else
error('incorrect number of input for tthe strech option.')
end
g=1./(1+(m./(f+eps)).^e);
otherwise
error('unknow enhancement method .')
end
%Convert to the class of the input image .
g = changeclass(classin,g);