public override void ApplayFilter(_Image ApplayImage) { Bitmap ImageBitMap = new Bitmap(ApplayImage.GetMainImage()); Color c; for (int i = 0; i < ImageBitMap.Width; i++) { for (int j = 0; j < ImageBitMap.Height; j++) { c = ImageBitMap.GetPixel(i, j); int nPixelR = 0; int nPixelG = 0; int nPixelB = 0; nPixelR = c.R - 255; nPixelG = c.G; nPixelB = c.B - 255; nPixelR = Math.Max(nPixelR, 0); nPixelR = Math.Min(255, nPixelR); nPixelG = Math.Max(nPixelG, 0); nPixelG = Math.Min(255, nPixelG); nPixelB = Math.Max(nPixelB, 0); nPixelB = Math.Min(255, nPixelB); ImageBitMap.SetPixel(i, j, Color.FromArgb((byte)nPixelR, (byte)nPixelG, (byte)nPixelB)); } } ApplayImage.SetFilterdBitMap(ref ImageBitMap); }
public override void ApplayFilter(_Image ApplayImage) { // The filter Side Size const int KernalSize = 3; // init The main Matrix of The Filter FilterMatrix = new double[KernalSize, KernalSize] { { 1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f }, { 1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f } , { 1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f } }; //FilterMatrix = new double[KernalSize, KernalSize] { { 1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f , 1.0f / 9.0f ,1.0f / 9.0f}, // { 1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f , 1.0f / 9.0f ,1.0f / 9.0f} // , { 1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f , 1.0f / 9.0f ,1.0f / 9.0f} , // { 1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f , 1.0f / 9.0f ,1.0f / 9.0f}, // { 1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f , 1.0f / 9.0f ,1.0f / 9.0f} // }; MainImage = ApplayImage.GetMainImage(); ImageBitMap = new Bitmap(MainImage); // Applying Padding RGBvalues = HelperFunctions.Padding(ImageBitMap, KernalSize, out NewWidth, out Newheight); // Applay Convolution HelperFunctions.Convolution(ImageBitMap, KernalSize, FilterMatrix, RGBvalues, NewWidth, Newheight); // Set The Filterd Image To the MainImage ApplayImage.SetFilterdBitMap(ref ImageBitMap); }
public override void ApplayEnhancement(_Image ApplayImage) { ApplayImage.CalculateRGBValues(); Bitmap NewBitMap = new Bitmap(ApplayImage.GetMainImage()); for (int i = 0; i < ApplayImage.ImageHeight; i++) { for (int j = 0; j < ApplayImage.ImageWidth; j++) { if (ApplayImage.RGBVaues[j][i].R < ThresholdStart) { NewBitMap.SetPixel(j, i, Color.FromArgb(0, 0, 0)); } else if (ApplayImage.RGBVaues[j][i].R > ThresholdEnd) { NewBitMap.SetPixel(j, i, Color.FromArgb(255, 255, 255)); } //else //{ // NewBitMap.SetPixel(j, i, Color.FromArgb((int)DefultValue, (int)DefultValue, (int)DefultValue)); //} } } ApplayImage.SetFilterdBitMap(ref NewBitMap); }
public override void ApplayFilter(_Image ApplayImage) { ImageBitMap = new Bitmap(ApplayImage.GetMainImage()); Vector3d GammaRGB = FilterInputs[0] as Vector3d; SetGamma(GammaRGB.X, GammaRGB.Y, GammaRGB.Z); ApplayImage.SetFilterdBitMap(ref ImageBitMap); }
public override void ApplayEnhancement(_Image ApplayImage) { ApplayImage.CalculateRGBValues(); List <double> Group1 = new List <double>(); List <double> Group2 = new List <double>(); double OldT = 0; while (T0 < Math.Abs(T1 - OldT)) { Group1 = new List <double>(); Group2 = new List <double>(); for (int i = 0; i < ApplayImage.ImageHeight; i++) { for (int j = 0; j < ApplayImage.ImageWidth; j++) { if (ApplayImage.RGBVaues[j][i].R > T1) { Group1.Add(ApplayImage.RGBVaues[j][i].R); } else { Group2.Add(ApplayImage.RGBVaues[j][i].R); } } } OldT = T1; double Mean1 = Group1.Sum() / Group1.Count; double Mean2 = Group2.Sum() / Group2.Count; T1 = 0.5 * (Mean1 + Mean2); Console.WriteLine(T1.ToString()); } Bitmap NewImage = new Bitmap(ApplayImage.GetMainImage()); for (int i = 0; i < ApplayImage.ImageHeight; i++) { for (int j = 0; j < ApplayImage.ImageWidth; j++) { if (ApplayImage.RGBVaues[j][i].R > T1) { NewImage.SetPixel(j, i, Color.FromArgb(255, 255, 255)); } else { NewImage.SetPixel(j, i, Color.FromArgb(0, 0, 0)); } } } ApplayImage.SetFilterdBitMap(ref NewImage); }
public override void ApplayEnhancement(_Image ApplayImage) { Bitmap bitmap = new Bitmap(ApplayImage.GetMainImage()); PointF MinMax = HelperFunctionality.HelperFunctions.GetMinMax(bitmap); for (int i = 0; i < bitmap.Width; i++) { for (int j = 0; j < bitmap.Height; j++) { double PixelValue = bitmap.GetPixel(i, j).R; int floatValue = (int)Math.Round(((Math.Pow(2, FormInput) - 1) * ((PixelValue - MinMax.X) / (MinMax.Y - MinMax.X)))); bitmap.SetPixel(i, j, Color.FromArgb(floatValue, floatValue, floatValue)); } } ApplayImage.SetFilterdBitMap(ref bitmap); }
public override void ApplayFilter(_Image ApplayImage) { // The Side Size of The Filter const int KernalSize = 3; // The Matrix of The Filter MainImage = ApplayImage.GetMainImage(); ImageBitMap = new Bitmap(MainImage); // Applying Padding RGBvalues = HelperFunctions.Padding(ImageBitMap, KernalSize, out NewWidth, out Newheight); // Applay Convolution for X And y Sobel HelperFunctions.Convolution(ImageBitMap, KernalSize, ySobel, xSobel, RGBvalues, NewWidth, Newheight); // Set The Filterd Image To the MainImage ApplayImage.SetFilterdBitMap(ref ImageBitMap); }
public override void ApplayEnhancement(_Image ApplayImage) { bitmap = new Bitmap(ApplayImage.GetMainImage()); for (int i = 0; i < bitmap.Width; i++) { for (int j = 0; j < bitmap.Height; j++) { if (bitmap.GetPixel(i, j).R > FormInput) { bitmap.SetPixel(i, j, Color.FromArgb(255, 255, 255)); } else { bitmap.SetPixel(i, j, Color.FromArgb(0, 0, 0)); } } } ApplayImage.SetFilterdBitMap(ref bitmap); }
public override void ApplayFilter(_Image ApplayImage) { Arr = new double[ApplayImage.ImageHeight, ApplayImage.ImageWidth]; double[,] FilterMatrix = HelperFunctions.BuildGaussianMatrix(KernalSize, Sigma); MainImage = ApplayImage.GetMainImage(); if (MainImage == null) { ImageBitMap = ApplayImage.GetFilterdImageBitMap(); } else { ImageBitMap = new Bitmap(MainImage); } // Applying Padding RGBvalues = HelperFunctions.Padding(ImageBitMap, KernalSize, out NewWidth, out NewHeight); // Applay Convolution HelperFunctions.Convolution(ImageBitMap, KernalSize, FilterMatrix, RGBvalues, NewWidth, NewHeight); // Set The Filterd Image To the MainImage ApplayImage.SetFilterdBitMap(ref ImageBitMap); }
public override void ApplayEnhancement(_Image ApplayImage) { Bitmap ImageBitmap = new Bitmap(ApplayImage.GetMainImage()); Dictionary <double, int> values = HelperFunctionality.HelperFunctions.ShowHistoGram(ImageBitmap); int MaxValue = values.Values.Max(); double ThresholdValue = values.FirstOrDefault(x => x.Value == MaxValue).Key; Console.WriteLine(ThresholdValue); for (int i = 0; i < ApplayImage.ImageHeight; i++) { for (int j = 0; j < ApplayImage.ImageWidth; j++) { if (ImageBitmap.GetPixel(j, i).R > ThresholdValue) { ImageBitmap.SetPixel(j, i, Color.FromArgb(255, 255, 255)); } else if (ImageBitmap.GetPixel(j, i).R < ThresholdValue) { ImageBitmap.SetPixel(j, i, Color.FromArgb(0, 0, 0)); } } } ApplayImage.SetFilterdBitMap(ref ImageBitmap); }
public override void ApplayObjectDetection(_Image ApplayImage) { _Image XsobelImage = new _Image(); XsobelImage.SetImageLocation(ApplayImage.ImageLocation, true); // Applaying x-Sobel Opreator X_Sobel xsolbel = new X_Sobel(); xsolbel.ApplayFilter(XsobelImage); _Image YsobelImage = new _Image(); YsobelImage.SetImageLocation(ApplayImage.ImageLocation, true); // Applaying Y-sobel Opreator Y_Sobel ysobel = new Y_Sobel(); ysobel.ApplayFilter(YsobelImage); double[,] XsolbelArray = SquerBitmap(XsobelImage.GetFilterdImageBitMap()); double[,] YsolbelArray = SquerBitmap(YsobelImage.GetFilterdImageBitMap()); YsobelImage.ReplaceMainImageWithiltedImage(); XsobelImage.ReplaceMainImageWithiltedImage(); // Get The Multipication OF 2 Image string Message = ""; Bitmap MultBitMap = HelperFunctions.MultibleTwoImage(XsobelImage.GetFilterdImageBitMap(), YsobelImage.GetFilterdImageBitMap(), out Message); _Image MultiImage = new _Image(); MultiImage.SetFilterdBitMap(ref MultBitMap); MultiImage.ReplaceMainImageWithiltedImage(); // Applay Gaussian Filter GaussianFilter NewFilter = new GaussianFilter(); NewFilter.Sigma = 2; NewFilter.KernalSize = 7; NewFilter.ApplayFilter(XsobelImage); NewFilter.ApplayFilter(YsobelImage); NewFilter.ApplayFilter(MultiImage); Bitmap SobelXBitMap = XsobelImage.GetFilterdImageBitMap(); Bitmap SobelyBitMap = YsobelImage.GetFilterdImageBitMap(); MainImage = ApplayImage.GetMainImage(); ImageBitMap = new Bitmap(MainImage); int imageWidth = ApplayImage.ImageWidth, ImageHieght = ApplayImage.ImageHeight; double[,] Result = new double[ImageHieght, imageWidth]; double[,] R = new double[ImageHieght, imageWidth]; double Rmax = double.MinValue; for (int i = 0; i < ImageHieght; i++) { for (int j = 0; j < imageWidth; j++) { double det = (SobelXBitMap.GetPixel(i, j).R *SobelyBitMap.GetPixel(i, j).R) - (MultBitMap.GetPixel(i, j).R *MultBitMap.GetPixel(i, j).R); double trace = (SobelXBitMap.GetPixel(i, j).R + SobelyBitMap.GetPixel(i, j).R); R[i, j] = det - (trace * trace / 100); if (R[i, j] > Rmax) { Rmax = R[i, j]; } //int RGB = (int)R[i, j]; //ImageBitMap.SetPixel(i, j, Color.FromArgb(RGB , RGB , RGB)); } } int count = 0; for (int i = 2; i < ImageHieght - 1; i++) { for (int j = 2; j < imageWidth - 1; j++) { if ((R[i, j] > Rmax / 10) && (R[i, j] > R[i - 1, j - 1]) && (R[i, j] > R[i - 1, j]) && (R[i, j] > R[i - 1, j + 1]) && (R[i, j] > R[i, j - 1]) && (R[i, j] > R[i, j + 1]) && (R[i, j] > R[i + 1, j - 1]) && (R[i, j] > R[i + 1, j]) && (R[i, j] > R[i + 1, j + 1])) { ImageBitMap.SetPixel(i, j, Color.Red); count++; } //if (R[i, j] > 0.1 * Rmax && R[i, j] > R[i - 1, j - 1] && R[i, j] > R[i - 1, j] && R[i, j] > R[i - 1, j + 1] && R[i, j] > R[i, j - 1] && R[i, j] > R[i, j + 1] && R[i, j] > R[i + 1, j - 1] && R[i, j] > R[i + 1, j] && R[i, j] > R[i + 1, j + 1]) //{ // //Result[i, j] = 1; // ImageBitMap.SetPixel(i, j, Color.Red); // count++; //} } } Console.WriteLine(count); ApplayImage.SetFilterdBitMap(ref ImageBitMap); }