?? waveblend.cs
字號:
// Waveblend - complex dualtree based image fusion// (C) Copyright 2004 -- Sebastian Nowozin <nowozin@cs.tu-berlin.de>//// This file is part of Waveblend.//// Waveblend is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published// by the Free Software Foundation; version 2 of the License.//// Waveblend is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// The license is included with the distribution in the file 'LICENSE'.//using Gtk;using GtkSharp;using System;using System.Collections;public classWaveblend{ public static void Main (string[] args) { Console.WriteLine ("waveblend - version 0.1.0\n"); Console.WriteLine ("(C) Copyright 2004 -- Sebastian Nowozin <nowozin@cs.tu-berlin.de>"); Console.WriteLine ("Released as free software under the conditions of the GNU General Public License."); Console.WriteLine ("See the included LICENSE file for details.\n"); if (args.Length < 3) { Console.WriteLine ("usage: waveblend.exe [options] output image1 image2 [image3 [...]]\n"); Console.WriteLine ("Options"); Console.WriteLine (" --predenoise <thresh> Apply soft denoising onto the input images with the"); Console.WriteLine (" given threshhold (0.0 - 1.0)."); Console.WriteLine (" --postdenoise <thresh> Apply soft denoising onto output image with the"); Console.WriteLine (" given threshhold (0.0 - 1.0)."); Console.WriteLine (" --debug Graphically display all fusion stages."); Console.WriteLine ("\noutput: The output fused image file. File extension determines file format."); Console.WriteLine ("image<n>: The input images. At least two are required for image fusion."); Console.WriteLine (""); return; } double inputDenoise = 0.0; double outputDenoise = 0.0; bool debug = false; int optionCount = 0; int optionN = 0; while (args[optionN].Length >= 3 && args[optionN][0] == '-' && args[optionN][1] == '-') { string optionStr = args[optionN]; if (String.Compare (optionStr, "--debug") == 0) { debug = true; optionN += 1; } else if (String.Compare (optionStr, "--predenoise") == 0) { try { inputDenoise = Double.Parse (args[optionN + 1]); } catch (Exception ex) { Console.WriteLine ("Parameter to predenoise option invalid. See the usage help."); System.Environment.Exit (1); } if (inputDenoise < 0.0 || inputDenoise > 1.0) { Console.WriteLine ("Preprocessing denoise value {0} out of range (0.0 to 1.0).", inputDenoise); System.Environment.Exit (1); } optionN += 2; } else if (String.Compare (optionStr, "--postdenoise") == 0) { try { outputDenoise = Double.Parse (args[optionN + 1]); } catch (Exception ex) { Console.WriteLine ("Parameter to predenoise option invalid. See the usage help."); System.Environment.Exit (1); } if (outputDenoise < 0.0 || outputDenoise > 1.0) { Console.WriteLine ("Postprocessing denoise value {0} out of range (0.0 to 1.0).", outputDenoise); System.Environment.Exit (1); } optionN += 2; } else { Console.WriteLine ("Usage error. Run \"waveblend.exe\" without arguments for help."); System.Environment.Exit (1); } } optionCount = optionN; string outputfile = args[optionCount]; string[] imagefiles = new string[args.Length - 1 - optionCount]; Array.Copy (args, 1 + optionCount, imagefiles, 0, args.Length - 1 - optionCount); Application.Init (); Console.WriteLine ("==============================================================================="); Console.WriteLine ("Processing {0} input images...", imagefiles.Length); // Debugging stuff Gtk.VBox vb = new Gtk.VBox (); Gtk.Window win = new Window ("Waveblend"); if (debug) { win.DefaultSize = new Gdk.Size (400, 300); win.DeleteEvent += new DeleteEventHandler (Window_Delete); foreach (string filename in imagefiles) vb.Add (new Image (new DisplayImage (filename).Pbuf)); } Waveblend wb = new Waveblend (); wb.Fuse (imagefiles, inputDenoise); // Reconstruct and crop fused grayscale image ImageMap fused = wb.FusedImage; // Output denoising of grayscale image if (outputDenoise > 0.0) { Console.WriteLine ("Denoising grayscale fused image..."); fused = Denoise.DenoiseSoft (fused, outputDenoise); } // Display grayscale fused image if (debug) vb.Add (new Image (new DisplayImage (fused, 1.0).Pbuf)); // Create integer clipping map Console.WriteLine ("Creating clipping map..."); int[,] topology = MultiClipping.ClippingMap (wb.originals, fused); // Generate grayscale topology map and siplay it if (debug) { ImageMap topMap = new ImageMap (topology); topMap.Normalize (); vb.Add (new Image (new DisplayImage (topMap, 1.0).Pbuf)); } // Incrementally build color image by nearest match replacing DisplayImage baseImg = null; Console.WriteLine ("Recreating fused color image from topology..."); for (int n = 0 ; n < imagefiles.Length ; ++n) { DisplayImage fImg = new DisplayImage (imagefiles[n]); if (baseImg == null) { Console.WriteLine (" base: {0}", imagefiles[n]); baseImg = fImg; continue; } Console.WriteLine (" merge: {0}", imagefiles[n]); baseImg.ReplaceSelective (fImg, topology, n); } // Write imagefile Console.WriteLine ("Saving to \"{0}\"...", outputfile); baseImg.Save (outputfile); if (debug) { Console.WriteLine ("Displaying debugging output."); vb.Add (new Image (baseImg.Pbuf)); win.Add (vb); win.ShowAll (); Application.Run (); } } static void Window_Delete (object obj, DeleteEventArgs args) { Application.Quit (); args.RetVal = true; } ImageMap fusedImage = null; ArrayList originals; public ImageMap FusedImage { get { return (fusedImage); } } public void Fuse (string[] images, double inputDenoise) { DOFProcessing dof = new DOFProcessing (); foreach (string filename in images) { DisplayImage pic = new DisplayImage (filename); ImageMap map = pic.ConvertToImageMap (new DisplayImage.CanonicalPixelConverter ()); if (inputDenoise > 0.0) { Console.WriteLine ("Denoising input image \"{0}\"...", filename); map = Denoise.DenoiseSoft (map, inputDenoise); } dof.FuseOne (map); Console.WriteLine ("Fused in one image: {0}", filename); } fusedImage = dof.ProduceImage (); originals = dof.Originals; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -