this looks like the code
Public Shared Sub GaussianImageDemo()
Dim fileName As String = "c:/Sample.png"
Dim reImage As REImage = REFile.OpenImageFile(fileName)
Dim newImage As REImage = ImageProcessing.ApplyBlurGaussian(reImage)
REFile.SaveImageFile(newImage, "c:/reimage.png", New PNGEncoder())
does someone have a noob friendly explanation as to how that algorithm (Gaussian blur)works logic wize ?
this worls for small pics but it is way too slow
Public Class Form1
Private Function Average(ByVal Size As Size, ByVal imageSize As SizeF, _
ByVal PixelX As Integer, ByVal Pixely As Integer) As Color
Dim pixels As New ArrayList
Dim x As Integer, y As Integer
Dim bmp As Bitmap = PictureBox1.Image.Clone
' Find the color for each pixel and add it to a new array.
'
' Remember a 5X5 area on or near the edge will ask
' for pixels that don't
' exist in our image, this will filter those out.
'
For x = PixelX - CInt(Size.Width / 2) To PixelX + _
CInt(Size.Width / 2)
For y = Pixely - CInt(Size.Height / 2) To Pixely + _
CInt(Size.Height / 2)
If (x > 0 And x < imageSize.Width) And _
(y > 0 And y < imageSize.Height) Then
pixels.Add(bmp.GetPixel(x, y))
End If
Next
Next
' Adverage the A, R, G, B channels
' reflected in the array
Dim thisColor As Color
Dim alpha As Integer = 0
Dim red As Integer = 0
Dim green As Integer = 0
Dim blue As Integer = 0
For Each thisColor In pixels
alpha += thisColor.A
red += thisColor.R
green += thisColor.G
blue += thisColor.B
Next
' Return the sum of the colors / the number of colors (The average)
'
Return Color.FromArgb(alpha / pixels.Count, _
red / pixels.Count, _
green / pixels.Count, _
blue / pixels.Count)
End Function
Private Sub gausianBlur(ByVal alphaEdgesOnly As Boolean, _
ByVal blurSize As Size)
Dim PixelY As Integer
Dim PixelX As Integer
Dim bmp As Bitmap = PictureBox1.Image.Clone
' UI Stuff
Label1.Text = "Applying Gausian Blur of " & blurSize.ToString
Progress.Maximum = bmp.Height * bmp.Width
Progress.Minimum = 0
Progress.Value = 0
' Loop the rows of the image
For PixelY = 0 To bmp.Width - 1
' Loop the cols of the image
For PixelX = 0 To bmp.Height - 1
If Not alphaEdgesOnly Then ' Blur everything
bmp.SetPixel(PixelX, PixelY, Average(blurSize, _
bmp.PhysicalDimension, PixelX, PixelY))
ElseIf bmp.GetPixel(PixelX, PixelY).A _
<> 255 Then ' Alpha blur channel check
bmp.SetPixel(PixelX, PixelY, Average(blurSize, _
bmp.PhysicalDimension, PixelX, PixelY))
End If
Progress.Value += 1
Application.DoEvents()
Next
Next
PictureBox1.Image = bmp.Clone
bmp.Dispose()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
gausianBlur(False, New Size(6, 6))
End Sub
End Class