VB图像处理,(二)二次线性插值的应用

本文介绍了VB中二次线性插值在图像放大的应用,提供了具体的算法实现,通过实例展示了如何使用该算法进行图像的放大处理,以提高图像处理速度。
摘要由CSDN通过智能技术生成

上次讲到了用DIB方法来获取图像的像素。从这次开始将如果运用已经得到的像素来处理图像。
图像插值放大的方法有很多,最主要的有二次线性插值和三次线性插值这两种。
这次我把自己的程序中所用的二次线性插值的算法公布给大家,希望对各位要使用VB写类似程序的朋友有所帮助。
程序中用到的API、数据类型、全局变量的定义请参考上一篇:
《VB图像处理,(一)像素的获取和输出 》

Public Sub ZoomImage(ByVal OutPutWidth As Long, ByVal OutputHeight As Long)
Dim I As Long
Dim L As Long
Dim X As Long
Dim Y As Long
Dim Xb As Long
Dim Yb As Long
Dim Xe As Long
Dim Ye As Long
Dim M As Integer
Dim N As Integer
Dim CurR As Long
Dim CurG As Long
Dim CurB As Long
Dim NxtR As Integer
Dim NxtG As Integer
Dim NxtB As Integer
Dim DR As Single
Dim DG As Single
Dim DB As Single
Dim DRt As Single
Dim DGt As Single
Dim DBt As Single
Dim Xratio As Single
Dim Yratio As Single
Dim CurStep As Single
Dim NxtStep As Single
Dim NegN As Single

On Error GoTo ErrLine
If Not CanZoom Then Exit Sub
Done = False

OutPutWid = OutPutWidth - 1
OutPutHei = OutputHeight - 1
I = (Bits / 8) - 1
ReDim ColTmp(I, InPutWid, OutPutHei) '先从Y方向进行缩放处理,结果保存在此中间数组内
ReDim ColOut(I, OutPutWid, OutPutHei)
Xratio = OutPutWid / InPutWid
Yratio = OutPutHei / InPutHei

TimeZoom = timeGetTime

   NegN = 1 / Int(Yratio + 1)
   For X = 0 To InPutWid
      CurR = ColVal(0, X, 0)
      CurG = ColVal(1, X, 0)
      CurB = ColVal(2, X, 0)
      CurStep = 0
      NxtStep = 0
      For Y = 0 To InPutHei - 1
         NxtStep = CurStep + Yratio
         Yb = CurStep
         Ye = NxtStep
         N = Ye - Yb
         ColTmp(0, X, Yb) = CurR
         ColTmp(1,

评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值