The last time we talked about how to use the DIB method to retrieve the pixels of an image. From this time on, we will use the obtained pixels to process the image.
There are many methods for interpolation and amplification of images, mainly including quadratic and cubic linear interpolation.
This time I will publish the quadratic linear interpolation algorithm used in my program to everyone. I hope it will be helpful to anyone who wants to use VB to write similar programs.
For the APIS, data types, and global variables used in the program, see the previous article:
VB Image Processing (I) Acquisition and output of pixels
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) 'First scales in the Y direction, and the results are saved in the intermediate array.
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)