Hi,
I'm a beginner in c# and I'm now work in a project with image editing.
i already figure how to do this manually but my professor wants it automatically.
and i tried to call the class type after i load the image but it doesn't work.
here is my codes for the removing it manually.
#region Methods
public void Extract(Point position, int fuzziness)
{
if (_image != null)
{
SaveUndo();
Color clrBaseColor = _image.GetPixel(position.X, position.Y);
if (clrBaseColor.A != 0)
{
BitmapData bitmapData = _image.LockBits(new Rectangle(0, 0, _image.Width, _image.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
int stride = bitmapData.Stride;
IntPtr ptrScan0 = bitmapData.Scan0;
unsafe
{
int count = 0;
int limit = (fuzziness + count) * 20;
byte* pixel = (byte*)(void*)ptrScan0;
int nOffset = stride - _image.Width * 4;
byte alpha;
byte red;
byte green;
byte blue;
for (int y = 0; y < _image.Height; ++y)
{
for (int x = 0; x < _image.Width; ++x)
{
blue = pixel[0];
green = pixel[1];
red = pixel[2];
alpha = pixel[3];
//if (limit >= Math.Sqrt (Math .Pow ((red - clrBaseColor.R),2)+ Math .Pow ((green- clrBaseColor.G),2) +Math .Pow ((blue-clrBaseColor.B),2)))
if (Math.Abs(red - clrBaseColor.R) < limit && Math.Abs(green - clrBaseColor.G) < limit && Math.Abs(blue - clrBaseColor.B) < limit )
// {
//if (limit >= Math.Abs(Math.Sqrt(Math.Pow((red - clrBaseColor.R), 2) + Math.Pow((green - clrBaseColor.G), (2 + 1 / 2)) + Math.Pow((blue - clrBaseColor.B), 2))))
{
pixel[0] = 0;
pixel[1] = 0;
pixel[2] = 0;
pixel[3] = 0;
}
pixel += 4;
}
pixel += nOffset;
//}
}
count = count - 1;
}
_image.UnlockBits(bitmapData);
}
}
}
thanks