資源簡介
用Matlab實現的圖像尺度變化,包括最近插值和Bilinear插值算法。
代碼片段和文件信息
function?bi_linear(imga)
%?Using?Bilinear?Interpolation?to?scale
%?img?is?the?input?image?a?is?the?scaling?factor
A=imread(img);
[r_sizec_size]=size(A);
%?The?size?of?image?B?is?a*size(A)=R*C
%?use?round()?to?get?the?nearest?integer
R=round(a*r_size);
C=round(a*c_size);
B=zeros(RC);???%?B?is?the?output?matrix
A=double(A);?B=double(B);
for?i=1:R
????for?j=1:C
????????xx=i./a;
????????yy=j./a;
%?Use?floor()?to?get?the?nearest?integers?towards?minus?infinity.
????????x=floor(xx);?
????????y=floor(yy);?
????????x1=x+1;?y1=y+1;
%?The?first?pixel?of?image?begin?with?(11)
%?So?if?x=0?of?y=0?we?must?convert?them?to?1
????????if?x==0?x=1;
????????end
????????if?y==0?y=1;
????????end??
%?Two?if?statements?avoid?x1?or?y1?exceed?A‘s?demensions
????????if?x1>r_size
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1031??2007-04-30?23:46??圖像處理-尺度變換scaling?transformation\bi_linear.m
?????文件??????85760??2006-03-03?00:00??圖像處理-尺度變換scaling?transformation\Lena_gray.bmp
?????文件????????660??2007-04-30?23:47??圖像處理-尺度變換scaling?transformation\nearest.m
?????文件?????712704??2009-03-11?11:35??圖像處理-尺度變換scaling?transformation\Summary?report.doc
?????文件????????534??2007-04-30?23:12??圖像處理-尺度變換scaling?transformation\test.m
?????目錄??????????0??2009-03-11?11:39??圖像處理-尺度變換scaling?transformation
-----------?---------??----------?-----??----
???????????????800689????????????????????6
評論
共有 條評論