什么叫归一化?怎么联系到HSI格式的?
我理解的归一化是将数据变成某种相对值关系(它是一种无量纲处理手段),例如:将0~255这间的数据double化为0~1(相对值)。
从RGB到HSI只是对同一图像用不同的方式表示,这样有利于使用不同的方法进行处理。
例如:我想将一幅图像的饱和度提高,那么直接用RGB不太容易,于是转化为HSI后,就非常容易了。
下面是转换代码RGB和HSI的互换代码。
--------------------------------------------------------------------------
function
hsi=rgb2hsi(rgb)
%RGB2HSI
Converts
an
RGB
image
to
HSI
%
HSI=RGB2HSI(rgb)
converts
an
RGB
image
to
HSI
The
input
image
is
%
assumed
to
be
of
size
M-by-N-by-3,
where
the
third
dimension
accounts
%
for
three
image
planes:red,
green,
and
blue,
in
that
order
If
all
RGB
%
component
images
are
equal,
the
HSI
conversion
is
undefined
Ths
input
%
image
can
be
of
class
double
(with
values
in
the
rang[0,1]),
uint8,
or
%
uint16
%
The
output
image,
HSI,
is
of
class
double,
where:
%
hsi(:,:,1)=
hue
image
normalized
values
to
the
range
[0,1]
by
%
dividing
all
angle
values
by
2pi
%
hsi(:,:,2)=saturation
image,
in
the
range
[0,1]
%
hsi(:,:,3)=intensity
image,
in
the
range
[0,1]
%Extract
the
individual
component
images
rgb=im2double(rgb);
r=rgb(:,:,1);
g=rgb(:,:,2);
b=rgb(:,:,3);
%Implement
the
conversion
equations
num=05((r-g)+(r-b));
den=sqrt((r-g)^2+(r-b)(g-b));
theta=acos(num/(den+eps));
H=theta;
H(b>g)=2pi-H(b>g);
H=H/(2pi);
num=min(min(r,g),b);
den=r+g+b;
den(den==0)=eps;
S=1-3num/den;
H(S==0)=0;
I=(r+g+b)/3;
%Combine
all
three
results
into
an
hsi
image
hsi=cat(3,H,S,I);
function
rgb=hsi2rgb(hsi)
%HSI2RGB
Converts
an
HSI
image
to
RGB
%
HSI2RGB
Converts
an
HSI
image
to
RGB,
where
HSI
is
assumed
to
be
of
%
class
double
with:
%
hsi(:,:,1)=
hue
image
normalized
values
to
the
range
[0,1]
by
%
dividing
all
angle
values
by
2pi
%
hsi(:,:,2)=saturation
image,
in
the
range
[0,1]
%
hsi(:,:,3)=intensity
image,
in
the
range
[0,1]
%
The
components
of
the
output
image
are:
%
rgb(:,:,1)=red;
%
rgb(:,:,2)=green
%
rgb(:,:,3)=blue
%Extract
the
individaul
HSI
component
images
H=hsi(:,:,1)2pi;
S=hsi(:,:,2);
I=hsi(:,:,3);
%Implement
the
conversion
equations
R=zeros(size(hsi,1),size(hsi,2));
G=zeros(size(hsi,1),size(hsi,2));
B=zeros(size(hsi,1),size(hsi,2));
%
RG
sector
(0<=H<2pi/3)
idx=find((0<=H)&(H<2pi/3));
B(idx)=I(idx)(1-S(idx));
R(idx)=I(idx)(1+S(idx)cos(H(idx))/cos(pi/3-H(idx)));
G(idx)=3I(idx)-(R(idx)+B(idx));
%BG
sector
(2pi/3<=H<4pi/3)
idx=find((2pi/3<=H)&(H<4pi/3));
R(idx)=I(idx)(1-S(idx));
G(idx)=I(idx)(1+S(idx)cos(H(idx)-2pi/3)/cos(pi-H(idx)));
B(idx)=3I(idx)-(R(idx)+G(idx));
%BR
sector
idx=find((4pi/3<=H)&(H<=2pi));
G(idx)=I(idx)(1-S(idx));
B(idx)=I(idx)(1+S(idx)cos(H(idx)-4pi/3)/cos(5pi/3-H(idx)));
R(idx)=3I(idx)-(G(idx)+B(idx));
%Combine
all
three
results
into
an
RGB
image
Clip
to
[0,1]
to
compensate
for
floating-point
arithmetic
rounding
effects
rgb=cat(3,R,G,B);
rgb=max(min(rgb,1),0);
member
英[ˈmembə(r)]
美[ˈmɛmbɚ]
n
成员;
分子;
身体部位(尤指胳膊或腿);
构件,部件;
[例句]He
refused
to
name
the
members
of
staff
involved
他拒绝说出所涉及员工的姓名。
[其他]
复数:members
hug
英[hʌg]
美[hʌɡ]
vt
热烈地拥抱,抱住,紧抱;
vt
紧靠…走;
抱有,持有;
n
紧抱,热烈拥抱;
[例句]Shaerl
trudged
toward
them,
hugging
a
large
box
谢尔抱着一个大箱子步履艰难地向他们走去。
[其他]
第三人称单数:hugs
复数:hugs
现在分词:hugging
过去式:hugged过去分词:hugged
欢迎分享,转载请注明来源:品搜搜测评网