full_contrast.m
来自「用于视频压缩编码中的RGB信号到色差信号变换的VHDL程序」· M 代码 · 共 49 行
M
49 行
% FULL_CONTRAST 2d Matrix adjustment.
% FULL_CONTRAST(A) scales and adjusts the incoming data
% to be positive integer from 0 to 255.
% FULL_CONTRAST(A,size) scales and adjusts the incoming data
% to be positive integer from 0 to size-1.
% FULL_CONTRAST(A) uses the default size = 256.
% full_contrast function
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Author : Daniel Michek
% Date : 29 August 2003
% Version : 0.01
% Intent : Modify data set to limitted
% size.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Requirements %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function new_image = full_contrast(orig_image,size)
% FULL_CONTRAST 2d Matrix adjustment.
% FULL_CONTRAST(A) scales and adjusts the incoming data
% to be positive integer from 0 to 256.
% FULL_CONTRAST(A,size) scales and adjusts the incoming data
% to be positive integer from 0 to size.
% FULL_CONTRAST(A) uses the default size = 256.
% Set default size if not given
if nargin==1
size = 256;
elseif nargin==0
help full_contrast;
orig_image = [0 1];
size = 256;
end
% Modify data set to limitted size
image=double(orig_image); %convert to double to allow processing
mincont=min(min(image)); %find min val in 2d Matrix
maxcont=max(max(image)); %find max val in 2d Matrix
if (maxcont~=mincont)
stretch=(size-1)/(maxcont-mincont); %stretch value to fill full bandwidth
else
stretch=1;
end
normalized=image-mincont; %adjust original image to offset @ 0
new_image=normalized*stretch; %offset image * stretch value
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?