private void ApplyHaarTransform(bool forward, bool safe, int iterations, Bitmap bmp) { var maxScale = WaveletTransform.GetMaxScale(bmp.Width, bmp.Height); if (iterations < 1 || iterations > maxScale) { MessageBox.Show(string.Format("Iteration must be Integer from 1 to {0}", maxScale)); return; } var time = Environment.TickCount; var channels = ColorChannels.CreateColorChannels(safe, bmp.Width, bmp.Height); var transform = WaveletTransform.CreateTransform(forward, iterations); var imageProcessor = new ImageProcessor(channels, transform); imageProcessor.ApplyTransform(bmp); if (forward) { this.TransformedImage = new Bitmap(bmp); } this.pictureBox1.Image = bmp; this.lblDirection.Text = forward ? "Forward" : "Inverse"; this.lblTransformTime.Text = string.Format("{0} milis.", Environment.TickCount - time); }
public void DecomposeWithUnsafeCode() { using (var originalImage = new Bitmap(OriginalFilename)) { var transform = new ForwardWaveletTransform(1); var channels = new UnsafeColorChannels(originalImage.Width, originalImage.Height); var imageProcessor = new ImageProcessor(channels, transform); imageProcessor.ApplyTransform(originalImage); VerifyAsImage(originalImage); } }
public void RecomposeWithSafeCode() { using (var originalImage = new Bitmap(OneStepFileName)) { WaveletTransform transform = new InverseWaveletTransform(1); ColorChannels channels = new SafeColorChannels(originalImage.Width, originalImage.Height); var imageProcessor = new ImageProcessor(channels, transform); imageProcessor.ApplyTransform(originalImage); VerifyAsImage(originalImage); } }
public void FullRecomposeWithSafeCode() { using (var originalImage = new Bitmap(DecomposedFilename)) { var width = originalImage.Width; var height = originalImage.Height; var transform = new InverseWaveletTransform(width, height); var channels = new SafeColorChannels(width, height); var imageProcessor = new ImageProcessor(channels, transform); imageProcessor.ApplyTransform(originalImage); VerifyAsImage(originalImage); } }
static void ApplyWavelet() { int times = 7; string[] images = Directory.GetFiles(@"..\..\..\TestHaarCSharp\Resources_Noisy\", "*", SearchOption.AllDirectories); Parallel.ForEach(images, (i) => { Bitmap initial = new Bitmap(Image.FromFile(i)); //var res = AddNoise(initial, 50); //res.Save($@"..\..\..\TestHaarCSharp\Resources_noisy\{Path.GetFileName(i)}", res.RawFormat); Bitmap forward = new Bitmap(initial); var channels = ColorChannels.CreateColorChannels(initial.Width, initial.Height); var transform = WaveletTransform.CreateTransform(true, times); var imageProcessor = new ImageProcessor(channels, transform); imageProcessor.ApplyTransform(forward); string newPath = Path.Combine(@"..\..\..\TestHaarCSharp\Forward_Noisy", Path.GetFileName(i)); string dirName = Path.GetDirectoryName(newPath); if (!Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } forward.Save(newPath, initial.RawFormat); Bitmap inverse = new Bitmap(forward); transform = WaveletTransform.CreateTransform(false, times); imageProcessor = new ImageProcessor(channels, transform); imageProcessor.ApplyTransform(inverse); var rmse = GetRMSE(initial, inverse); newPath = Path.Combine(@"..\..\..\TestHaarCSharp\Inverse_Noisy", $"{Path.GetFileNameWithoutExtension(i)}_{rmse.ToString("#.##")}{Path.GetExtension(i)}"); dirName = Path.GetDirectoryName(newPath); if (!Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } inverse.Save(newPath, inverse.RawFormat); }); }
private Bitmap ApplyHaarTransform(bool forward, bool safe, int iterations, Bitmap bmp) { var maxScale = WaveletTransform.GetMaxScale(bmp.Width, bmp.Height); if (iterations < 1 || iterations > maxScale) { MessageBox.Show(string.Format("Iteration must be Integer from 1 to {0}", maxScale)); return(new Bitmap(bmp.Width, bmp.Height)); } var channels = ColorChannels.CreateColorChannels(safe, bmp.Width, bmp.Height); var transform = WaveletTransform.CreateTransform(forward, iterations); var imageProcessor = new ImageProcessor(channels, transform); imageProcessor.ApplyTransform(bmp); return(bmp); }
private Bitmap ApplyHaarTransform(bool forward, bool safe, int iterations, Bitmap bmp) { var maxScale = WaveletTransform.GetMaxScale(bmp.Width, bmp.Height); if (iterations < 1 || iterations > maxScale) { MessageBox.Show(string.Format("Iteration must be Integer from 1 to {0}", maxScale)); return new Bitmap(bmp.Width, bmp.Height); } var channels = ColorChannels.CreateColorChannels(safe, bmp.Width, bmp.Height); var transform = WaveletTransform.CreateTransform(forward, iterations); var imageProcessor = new ImageProcessor(channels, transform); imageProcessor.ApplyTransform(bmp); return bmp; }