嗨,我写了一个噪音去除器(平均滤镜),但图像结果不好?我不知道问题出在哪里?我需要帮忙吗?

问题描述:

Dim myBitmap1 As Bitmap = PictureBox1.Image

Dim myBitmap2 As New Bitmap(myBitmap1.Width,myBitmap1.Height,System.Drawing.Imaging.PixelFormat.Format32bppPArgb)

对于ii = 1到PictureBox1.Width - 2

对于jj = 1到PictureBox1.Height - 2

Dim Win = 0

Dim平均值= 0

对于X = ii - 1到(ii + 1)

对于Y = jj - 1到(jj + 1)

Win = Win +(System.Drawing.ColorTranslator.ToWin32(myBitmap1.GetPixel(X,Y)))

下一页Y

下一页X

Mean =(Win \ 11)

Dim r = Mean Mod

Dim g =((平均和& HFF00FF00)/ 256&)

Dim b =((平均和& HFF0000)/ 65536)

myBitmap2.SetPixel(ii,jj,Color.FromArgb(r,g,b))

PictureBox2.Image = myBitmap2

下一个jj

下一个ii

TextBox1.Visible = True

TextBox1.Text =均值过滤器



我尝试过:



我不知道问题出在哪里?我需要帮助??????????

Dim myBitmap1 As Bitmap = PictureBox1.Image
Dim myBitmap2 As New Bitmap(myBitmap1.Width, myBitmap1.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb)
For ii = 1 To PictureBox1.Width - 2
For jj = 1 To PictureBox1.Height - 2
Dim Win = 0
Dim Mean = 0
For X = ii - 1 To (ii + 1)
For Y = jj - 1 To (jj + 1)
Win = Win + (System.Drawing.ColorTranslator.ToWin32(myBitmap1.GetPixel(X, Y)))
Next Y
Next X
Mean = (Win \ 11)
Dim r = Mean Mod 256
Dim g = ((Mean And &HFF00FF00) / 256&)
Dim b = ((Mean And &HFF0000) / 65536)
myBitmap2.SetPixel(ii, jj, Color.FromArgb(r, g, b))
PictureBox2.Image = myBitmap2
Next jj
Next ii
TextBox1.Visible = True
TextBox1.Text = "Mean Filter"

What I have tried:

I don't know where is the problem?? i need a help ??????????





什么是关于图像结果是不好?



如果模糊,这对于均值滤波器来说可能是正常的,您可以使用中值滤波器代替。

如果某些颜色看起来很奇怪,可能是图像中的噪点类型以及你如何分裂和重新组合。



干杯,



Jon
Hi,

What is it about the image result that is "not good"?

If it is blurry, this could be normal for a mean filter, you could use a median filter instead.
If some colours seem odd, it could be the type of noise in the image and how you split and recombine.

Cheers,

Jon


我怀疑当你应该单独平均组件时,问题在于平均RGB值。



例如,选择两种颜色,绿色(00FF00)和深绿色(008D00)。您正在寻找的平均值类似于(00C900),绿色成分位于两个单元格的中间。但是你的算法可能会给出(00C680)这是数值平均值并且包含一些绿色和大量蓝色(我认为),因为除法溢出将半绿色转移到很多蓝色。随着你对更多细胞的平均值,颜色混合变得更糟。



还除以9而不是11?



Jon
I suspect the problem lies with averaging the RGB value when you should be averaging the components individually.

For instance, take two colours, a full on Green (00FF00) and a darker green (008D00). The average you are looking for is something like (00C900) with the green component half way in between the two cells. But your algorithm might give (00C680) which is the numerical average and includes a bit of green and a lot of blue (I think) as the division overflows shift half a shade of green into a lot of blue. The mixing of colours becomes worse as you average over more cells.

Also divide by 9 not 11?

Jon