//MOZNA DODAC WARTOSC SREDNIA ENERGII W OBRAZIE I POKAZAC ZE Z USUWANIE SEAMOW SIE PODNOSI private void LoadButton_Click(object sender, EventArgs e) { var result = OpenFileDialog.ShowDialog(); if (result != DialogResult.OK) { return; } if (_imageForm != null) { _imageForm.Close(); } _imageForm = new ImageForm(this); var image = Image.FromFile(OpenFileDialog.FileName); _imageFileName = OpenFileDialog.SafeFileName; _imageForm.imageBox.Image = image; _imageForm.imageBox.Width = image.Width; _imageForm.imageBox.Height = image.Height; _imageForm.Show(); ImageHeightNumeric.Value = image.Height; ImageWidthNumeric.Value = image.Width; EnableImageControls(); //for testing //MemoryStream ms = new MemoryStream(); //image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); SeamCarving.LoadImage(new Bitmap(image)); double avgEnergy; Bitmap bmp; SeamCarving.FindImageEnergy(GetEnergyAlgorithm(), out avgEnergy, out bmp); AverageEnergyLabel.Text = avgEnergy.ToString("F2"); //_imageForm.imageBox.Image = bmp; }
private void SetHeightButton_Click(object sender, EventArgs e) { var heightDiff = _imageForm.imageBox.Height - ImageHeightNumeric.Value; var energyFunction = GetEnergyAlgorithm(); SeamCarving.ResizeHeight(energyFunction, heightDiff); var newBitmap = SeamCarving.ToImage(); Bitmap bmp; double avgEnergy; SeamCarving.FindImageEnergy(energyFunction, out avgEnergy, out bmp); AverageEnergyLabel.Text = avgEnergy.ToString("F2"); _imageForm.imageBox.Image = newBitmap; _imageForm.imageBox.Width = newBitmap.Width; _imageForm.imageBox.Height = newBitmap.Height; ImageHeightNumeric.Value = newBitmap.Height; ImageWidthNumeric.Value = newBitmap.Width; ProgressBar.Value = 100; }
public void GenerateEnergyMaps() { CreateOutputDirectory(); string[] files = GetFiles(); foreach (var f in files) { Image image = Image.FromFile(f); double energy; Bitmap bmp; string filename = Path.GetFileNameWithoutExtension(f); string fileExtension = Path.GetExtension(f); foreach (var ef in enerfyFunctions) { SeamCarving.LoadImage(new Bitmap(image)); SeamCarving.FindImageEnergy(GetEnergyFunction(ef), out energy, out bmp); bmp.Save(outputDirectory + "\\" + filename + "_" + ef + "_energyMap" + fileExtension); //int [,] m = SeamCarving.ResizeWidth(GetEnergyFunction(ef),50); //SeamCarving.LoadImage(bmp); //Image im2 = SeamCarving.ToImage(m); //im2.Save(outputDirectory + "\\" + filename + "_" + ef + "_test" + fileExtension); } } }