[C#]
using (Bitmap bm = (Bitmap)Bitmap.FromFile(Server.MapPath("rez/sam-schooler-E9aetBe2w40-unsplash.jpg"))) {
using (BitmapData data = bm.LockBits(ImageLockMode.ReadWrite, bm.Bounds, bm.PixelFormat)) {
var rnd = new Random(42);
for (int i = 0; i < 1000; i++) {
Point p = new Point(rnd.Next(bm.Width), rnd.Next(bm.Height));
Color c = data.GetPixel(p.X, p.Y);
c.R -= Math.Min(c.R, (byte)70);
c.G -= Math.Min(c.G, (byte)70);
c.B -= Math.Min(c.B, (byte)70);
data.SetPixel(p.X, p.Y, c);
}
}
bm.Save(Server.MapPath("IG8_Effects_Despeckle1.jpg"));
Effects.Despeckle(bm, 50);
bm.Save(Server.MapPath("IG8_Effects_Despeckle2.jpg"));
}
Here we apply a despeckle effect with different threshold
levels. First we apply some speckles to our image, then we try and
remove them. Ouput files are shown below.

sam-schooler-E9aetBe2w40-unsplash.jpg

IG8_Effects_Despeckle1.jpg

IG8_Effects_Despeckle2.jpg
|