求图象插值三种基本方法的程序
急需最近邻插值,和立方卷积插值的MATLAB程序,本人编了一个双线性的程序!希望大家指正!双线性插值法的MATLAB程序:>> width = 512;
>> height = 512;
>> J = uint8(zeros(width,height));
>> I1=imread('I:\mm.jpg');
>> imshow(I1);
>> =size(I1);
>> widthScale = nrows/width;
>> heightScale = ncols/height;
>> for x = 5:width - 5 % this index range is to avoid exceeding the permitted matrix index
for y = 5:height - 5
xx = x * widthScale; % xx and yy are the source ordinate,while x and y are the destinate ordinate
yy = y * heightScale;
if (xx/double(uint16(xx)) == 1.0) & (xx/double(uint16(xx)) == 1.0) % if a and b is integer,then J(x,y) <- I(x,y)
J(x,y) = I(int16(xx),int16(yy));
else % a or b is not integer
a = double(uint16(xx)); % (a,b) is the base-dot
b = double(uint16(yy));
x11 = double(I(a,b)); % x11 <- I(a,b)
x12 = double(I(a,b+1)); % x12 <- I(a,b+1)
x21 = double(I(a+1,b)); % x21 <- I(a+1,b)
x22 = double(I(a+1,b+1)); % x22 <- I(a+1,b+1)
J(x,y) = uint8( (b+1-yy) * ((xx-a)*x21 + (a+1-xx)*x11) + (yy-b) * ((xx-a)*x22 +(a+1-xx) * x12) ); % calculate J(x,y)
end
end
end
>> figure;
>> imshow(J)
[ 本帖最后由 eight 于 2007-6-11 15:52 编辑 ] 本人做毕业设计 急需图象插值算法中:最邻近插值 二次线性插值 立方卷积插值法的MATLAB程序,不是很复杂的,只要把一幅小图插值放大到2倍即可.不是自己编的也行,只要能告诉我在哪有也可以,谢谢了!
[ 本帖最后由 eight 于 2007-6-11 16:27 编辑 ]
页:
[1]