function g = intrans(f, method,varargin)
%INTRANS Performs intensity (gray-level) transformations.
% G = INTRANS(F, 'neg') computes the negative of input image F.
%
% G = INTRANS(F, 'log', C, CLASS) computes C*log(1 + F) and
% multiplies the result by (positive) constant C. If the last two
% parameters are omitted, 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 omitted, the output is of the
% same class as the input.
%
% G = INTRANS(F, 'gamma', GAM) performs a gamma transformation on
% the input image using parameter GAM (a required input).
%
% G = INTRANS(F, 'stretch', M, E) computes a contrast-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(im2double(F)), and the default value for E
% is 4.
% G = INTRANS(F, 'specified', TXFUN) performs the intensity
% transformation s = TXFUN(r) where r are input intensities, s are
% output intensities, and TXFUN is an insensity transformation (mapping)
% function, expressed as a vector with values in the range [0, 1].
% TXFUN must have at least two values.
%
%
% For the 'neg', 'gamma', 'stretch' and 'specified' transformations,
% floating-point input images whose values are outside the range [0, 1]
% are scaled first using MAT2GRAT. 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.
%
%
% The output is of the same class as the input, except if a
% different class is specified for the 'log' option.
% Verify the correct number of inputs.
error(nargchk(2, 4, nargin))
if strcmp(method,'log')
% The log transform handles image classes differently than the other
% transform, so let the LOGTRANSFORM function handles 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 the class of f for use later.
% Perform 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 = specifiedTransform(f,varargin{:});
otherwise
error('Unknown enhancement method.');
end
% Convert to the class of the input image.
g = revertClass(g);
%%
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 11.
txfun= txfun(:);%Force it to be a column vector
if any(txfun)> 1 || any(txfun) <= o
error('All elements of txfun nust be in the range 10 11.')
end
T=txfun;
x=linspace(0, 1, numel(T))';
g= interp1(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);
paddedsize.rar_cardx9z_greatestbj9_paddedsize_paddedsize.m_频率域滤波
版权申诉
108 浏览量
2022-07-15
01:40:38
上传
评论
收藏 5KB RAR 举报
刘良运
- 粉丝: 68
- 资源: 1万+
最新资源
- 基于Typescript的兔子饭店经营类游戏源码设计免费送cocoscreator
- 基于Java的web快速开发数据权限管理脚手架wonder-server设计源码
- 基于Apache Log4cxx的C++日志库设计源码
- 基于Vue3的likeadmin免费任意商用管理后台设计源码
- 基于JavaScript的Chrome扩展WeNote分享插件设计源码
- 基于C++的中泰EM9108S动态库开发示例源码
- gxlx2-p291-1g.dts和gxlx2-p291-1g.dtb
- STM32WBxx Keil芯片包
- 基于CNN+Bi-LSTM+Attention 的自动对对联系统
- 基于Java的IndexBar Android字母索引栏设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈