📄 perform_histogram_equalization.m
字号:
function x = perform_histogram_equalization(x,y,options)% perform_histogram_equalization - perform histogram equalization%% x = perform_histogram_equalization(x,y,options);%% Change the values of x so that its ordered values match% the ordered values of y.%% You can set% options.cols=1 to operate along columns% options.rows=1 to operate along rows% options.absval to operate only on absolute values.%% You can also use% x = perform_histogram_equalization(x,'gaussian',options);% x = perform_histogram_equalization(x,'linear',options);% to impose gaussian or uniform density.% % Copyright (c) 2006 Gabriel Peyr?options.null = 0;if iscell(x) for i=1:length(x) x{i} = perform_histogram_equalization(x{i},y{i},options); end return;endif isfield(options ,'absval') absval = options.absval;else absval = 0; endif isfield(options ,'cols') cols = options.cols;else cols = 0; endif isfield(options ,'rows') rows = options.rows;else rows = 0; endif cols && rows error('You cannote specify both cols and rows');endif cols && size(x,2)>1 if not(size(x,2)==size(y,2)) error('x and y must have same number of columns'); end for i=1:size(x,2) x(:,i) = perform_histogram_equalization(x(:,i),y(:,i),options); end return;endif rows && size(x,1)>1 if not(size(x,1)==size(y,1)) error('x and y must have same number of rows'); end for i=1:size(x,1) x(i,:) = perform_histogram_equalization(x(i,:),y(i,:),options); end return;endsx = size(x);x = x(:);if isstr(y) switch y case 'gaussian' y = randn(length(x)); case 'linear' y = linspace(0,1,length(x)); otherwise error('Unknown density.'); endendy = y(:);if absval s = sign(x); x = abs(x); y = abs(y);end[vx,Ix] = sort(x);[vy,Iy] = sort(y);nx = length(x);ny = length(y);ax = linspace(1,ny,nx);ay = 1:ny;vx = interp1(ay,vy,ax);x(Ix) = vx;if absval x = x .* s;endx = reshape(x,sx);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -