matlab,数字图像处理,intrans实现
[ 2015-5-8 20:43:00 | By: xiaoiixiao ]
 
intrans函数如下:

g = intrans(f,varargin)
  
error (nargchk(2,4,nargin))
%check input
classin = class(f);
%stroe the class of the input for use later.
if strcmp(class(f),'double') & max(f(:))>1 & ~strcmp(varargin{1},'log')
    f = mat2gray(f);
%if all the 3 conditions is filling the need .
else 
% make sure the class(f) is in the class of double , f(:) means all the
% elemnets in the martix F, and the max(f(:))>1 means if the max(f(:))>1 so
% convert them into double , in this way they are all less then1.        
% strcmp(varargin[1],'log') is the string compare, and the varargin {1} 
% compares with log. 
    f = im2double(f);
end
method = varargin{1};
  
switch method
    case 'neg'
        g = imcomplement(f);
    case  'log'
        if length(varargin) == 1
            c = 1;
        elseif length(varargin) == 2
            c = varargin{2};
        elseif length(varargin) == 3
            c = varargin{2};
            classin = varargin{3};
        else
            error('Incorrect number of input for the log option.')
        end
        g = c*(log(1+double(f)));
    case  'gamma'
        if length(varargin) < 2
            error('not enough input for the gamma option')
        end
        gam = varargin{2};
        g = imadjust (f, [], [], gam);
    case 'stretch'
        if length(varargin) == 1
            %defaults vaule
            m = mean2(f);
            E = 4.0;
        elseif length(varargin) == 3
            m = varargin{2};
            E = varargin{3};
        else error('incorrect number of inputs for the srtetch option.')
        end
        g = 1./(1 + (m./(f+eps)).^E);
    otherwise
        error('unkown enhancement method.')
end
  %     g = changeclass(classin , g);


转自http://www.cnblogs.com/zhongnanshan/archive/2010/08/27/1810167.html
 
 
发表评论:
 

时 间 记 忆
<<  < 2015 - >  >>
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
最 新 评 论
最 新 日 志
最 新 留 言
搜 索
用 户 登 录
友 情 连 接


 
天涯博客欢迎您!