声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1791|回复: 1

[图像处理] 求图象插值三种基本方法的程序

[复制链接]
发表于 2007-6-11 15:35 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
急需最近邻插值,和立方卷积插值的MATLAB程序,本人编了一个双线性的程序!希望大家指正!双线性插值法的MATLAB程序:

>> width = 512;
>> height = 512;
>> J = uint8(zeros(width,height));
>> I1=imread('I:\mm.jpg');
>> imshow(I1);
>> [nrows,ncols]=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 编辑 ]
回复
分享到:

使用道具 举报

 楼主| 发表于 2007-6-11 16:21 | 显示全部楼层
本人做毕业设计 急需图象插值算法中:最邻近插值 二次线性插值 立方卷积插值法的MATLAB程序,不是很复杂的,只要把一幅小图插值放大到2倍即可.不是自己编的也行,只要能告诉我在哪有也可以,谢谢了!

[ 本帖最后由 eight 于 2007-6-11 16:27 编辑 ]
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-10-3 04:34 , Processed in 0.059425 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表