public static void Main() { const string basePath = "..\\..\\..\\..\\images"; var destImageName = "pm1.png"; var srcImageName = "pm2.png"; // this is our input data. var destImage = GetLabImage(basePath, destImageName); var srcImage = GetLabImage(basePath, srcImageName); var input = new PmData(destImage, srcImage) { Settings = { PatchSize = 5, IterationsAmount = 2 } }; var patchMatchNnfBuilder = new PatchMatchNnfBuilder(); var pipeline = new PatchMatchPipeline(patchMatchNnfBuilder, ImagePatchDistance.Cie2000); pipeline.SetInput(input); var data = pipeline.Process() .Output[0]; var nnf = data.Nnf; // Restore dest image from the NNF and source image. nnf .RestoreImage(srcImage, 3, input.Settings.PatchSize) .FromLabToRgb() .FromRgbToBitmap() .SaveTo(@"..\..\..\restored.png", ImageFormat.Png); // Convert the NNF to an image, save and show it nnf .ToRgbImage() .FromRgbToBitmap() .SaveTo(@"..\..\..\nnf.png", ImageFormat.Png) .ShowFile(); Console.WriteLine($"PatchMatchPipeline processing is finished."); }
public void DrawMonth(int year) { AtomData.Clear(); SoilData.Clear(); SoilData.Add(new PieModel { title = "", value = 0 }); RainData.Clear(); PmData.Clear(); var data = Db.Table <DataModel>().ToList().Where(p => p.Time.Year == year); for (int i = 1; i <= 12; i++) { var temp = data.Where(p => p.Time.Month == i); if (temp.Count() > 0) { AtomData.Add(new GraphModel { Line = temp.Max(p => p.Temp), Line2 = temp.Average(p => p.Temp), Line3 = temp.Min(p => p.Temp) }); } } var count = data.Count(); var soil = (double)data.Count(p => p.Soil == 0) / count; var rain = (double)data.Count(p => p.Rain == 0) / count; var pm = (double)data.Count(p => p.Pm25 == 0) / count; SoilData.Add(new PieModel { title = "干燥", value = soil }); SoilData.Add(new PieModel { title = "湿润", value = 1 - soil }); RainData.Add(new PieModel { title = "有雨", value = 1 - rain }); RainData.Add(new PieModel { title = "无雨", value = rain }); PmData.Add(new PieModel { title = "超标", value = 1 - pm }); PmData.Add(new PieModel { title = "良好", value = pm }); }
/// <summary> /// Returns the post mortem data on all known task graph executions. This data indicates the vertices /// and edges that fired and those that did not fire. It is typically fed into the Diagnostics class' /// DumpPostMortemData(...) API. /// </summary> /// <returns>A Hashtable of postmortem data.</returns> public Hashtable GetPostMortems() { Hashtable postmortems = new Hashtable(); #if DEBUG if (s_managePostMortemData) { foreach (TaskProcessor tp in TaskProcessors) { foreach (IDictionary graphContext in tp.GraphContexts) { PmData pmData = (PmData)graphContext["PostMortemData"]; postmortems.Add(tp.Name, pmData); } } } #endif //DEBUG return(postmortems); }
public void DrawHour(int year, int month, int day) { SoilData.Clear(); RainData.Clear(); PmData.Clear(); AtomData.Clear(); SoilData.Add(new PieModel { title = "", value = 0 }); var list = Db.Table <DataModel>().ToList(); var data = list.Where(p => p.Time.Year == year && p.Time.Month == month && p.Time.Day == day); for (int i = 0; i < 24; i++) { var temp = data.First(p => p.Time.Hour == i); AtomData.Add(new GraphModel { Line = temp.Temp }); } var count = data.Count(); var soil = (double)data.Count(p => p.Soil == 0) / count; var rain = (double)data.Count(p => p.Rain == 0) / count; var pm = (double)data.Count(p => p.Pm25 == 0) / count; SoilData.Add(new PieModel { title = "干燥", value = soil }); SoilData.Add(new PieModel { title = "湿润", value = 1 - soil }); RainData.Add(new PieModel { title = "有雨", value = 1 - rain }); RainData.Add(new PieModel { title = "无雨", value = rain }); PmData.Add(new PieModel { title = "超标", value = 1 - pm }); PmData.Add(new PieModel { title = "良好", value = pm }); }
/// <summary> /// In a debug build, post-mortems of a task graph can be dumped, describing which /// vertices and edges fired. This method performs that activity. The post mortems /// are retrieved from the model through the GetPostMortems(){ ... } API. /// </summary> /// <param name="postMortems">PostMortem data that can be acquired from the model via the GetPostMortems() API.</param> public static void DumpPostMortems(Hashtable postMortems) { #if DEBUG foreach (DictionaryEntry de in postMortems) { PmData pmData = (PmData)de.Value; _Debug.WriteLine("PostMortem of Context associated with " + de.Key); _Debug.WriteLine("Vertices that fired:"); foreach (Vertex v in pmData.VerticesFired) { _Debug.WriteLine("\t" + v.Name); } _Debug.WriteLine("Edges that fired:"); foreach (Edge e in pmData.EdgesFired) { _Debug.WriteLine("\t" + e.Name); } } #endif }
private void SetLevelMessage() { DateTime date = new DateTime(int.Parse(year), int.Parse(month), int.Parse(day)); PmData data = new PmData(); data.Pdate = date; switch (service.GetPmLevelByDate(data)) { case 0: resultLabel.Text = "优秀"; resultLabel.ForeColor = Color.Green; break; case 1: resultLabel.Text = "良好"; resultLabel.ForeColor = Color.LightGreen; break; case 2: resultLabel.Text = "轻度污染"; resultLabel.ForeColor = Color.Black; break; case 3: resultLabel.Text = "中度污染"; resultLabel.ForeColor = Color.MediumVioletRed; break; case 4: resultLabel.Text = "重度污染"; resultLabel.ForeColor = Color.Red; break; case 5: resultLabel.Text = "严重污染"; resultLabel.ForeColor = Color.DarkRed; break; } ; }