private void BandCutFilterButton_Click(object sender, EventArgs e) { string minRangeText = rangeTextBox.Text; string maxRangeText = rangeTextBox2.Text; if (!string.IsNullOrEmpty(minRangeText) && !string.IsNullOrEmpty(maxRangeText)) { int minRange = int.Parse(minRangeText); int maxRange = int.Parse(maxRangeText); if (minRange >= Colors.MIN_PIXEL_VALUE && minRange <= Colors.MAX_PIXEL_VALUE && maxRange >= Colors.MIN_PIXEL_VALUE && maxRange <= Colors.MAX_PIXEL_VALUE) { Complex[][] filteredData = FourierUtil.BandCutFilter(_originalComplexData, minRange, maxRange); _processedComplexData = filteredData; } else { _processedComplexData = FourierUtil.CopyComplexArray(_originalComplexData); } } else { _processedComplexData = FourierUtil.CopyComplexArray(_originalComplexData); } Bitmap resultBitmap = Effect.IfftTransform(_processedComplexData); SetProcessedBitmap(resultBitmap); }
private void HighPassEdgeDetectionFilterButton_Click(object sender, EventArgs e) { string sectorWidthText = sectorWidthTextBox.Text; string rotationAngleText = rotationTextBox.Text; string rangeText = rangeTextBox.Text; if (!string.IsNullOrEmpty(sectorWidthText) && !string.IsNullOrEmpty(rotationAngleText) && !string.IsNullOrEmpty(rangeText)) { int sectorWidth = int.Parse(sectorWidthText); int rotationAngle = int.Parse(rotationAngleText); int range = int.Parse(rangeText); if (sectorWidth >= 0 && sectorWidth <= _originalBitmap.Width && Math.Abs(rotationAngle) >= 0 && Math.Abs(rotationAngle) <= 360 && range >= Colors.MIN_PIXEL_VALUE && range <= Colors.MAX_PIXEL_VALUE) { int[,] mask = Effect.GenerateEdgeDetectionMask(_originalBitmap.Width, _originalBitmap.Height, sectorWidth, rotationAngle); Bitmap bitmap = new Bitmap(_originalBitmap.Width, _originalBitmap.Height); for (int i = 0; i < bitmap.Width; i++) { for (int j = 0; j < bitmap.Height; j++) { if (mask[i, j] == Colors.MIN_PIXEL_VALUE) { bitmap.SetPixel(i, j, Color.Black); } else { bitmap.SetPixel(i, j, Color.White); } } } bitmap.Save("detMask.bmp", System.Drawing.Imaging.ImageFormat.Bmp); Complex[][] filteredData = FourierUtil.HighPassEdgeDetectionFilter(mask, _originalComplexData, range); _processedComplexData = filteredData; } } else { _processedComplexData = FourierUtil.CopyComplexArray(_originalComplexData); } Bitmap resultBitmap = Effect.IfftTransform(_processedComplexData); SetProcessedBitmap(resultBitmap); }
private void PhaseSpectrumFilterButton_Click(object sender, EventArgs e) { string kComponentText = kComponentTextBox.Text; string lComponentText = lComponentTextBox.Text; if (!string.IsNullOrEmpty(kComponentText) && !string.IsNullOrEmpty(lComponentText)) { int kComponent = int.Parse(kComponentText); int lComponent = int.Parse(lComponentText); Complex[][] filteredData = FourierUtil.PhaseSpectrumFilter(_originalComplexData, kComponent, lComponent); _processedComplexData = filteredData; } else { _processedComplexData = FourierUtil.CopyComplexArray(_originalComplexData); } Bitmap resultBitmap = Effect.IfftTransform(_processedComplexData); SetProcessedBitmap(resultBitmap); }