public void SaveEpiImage(string basepath) { try { basepath = basepath + "_"; foreach (var item in EpiProcedImgDic) { string name = Enum.GetName(typeof(ImgIdxPos), item.Key); item.Value.Save(basepath + name + "_splited.bmp"); } IndexViewImg.Save(basepath + "Index.bmp"); } catch (Exception e) { e.ToString().Print(" SsveEpiImage Error");; } }
public async void EpiProcessing(int resolution, int areaUpLimit, int areaDwlimit, int outerexclude = 0) { try { Stopwatch stw = new Stopwatch(); stw.Start(); SampleResolution = resolution; if (outerexclude > 0) { OuterExcludeSize = outerexclude; } AreaUp = areaUpLimit; AreaDw = areaDwlimit; var totalImgSize = EpiGrayImgDic[ImgIdxPos.TL].Width + EpiGrayImgDic[ImgIdxPos.TM].Width + EpiGrayImgDic[ImgIdxPos.TR].Width; if (EpiGrayImgDic.Count != 6) { return; } ResetData(); EpiProcedImgDic = EpiColorImgDic.ToDictionary(x => x.Key , x => x.Value.Normalize(64).Gamma(1.4)); Offset = CreateOffset(EpiGrayImgDic [ImgIdxPos.TL].Height , EpiGrayImgDic [ImgIdxPos.TL].Width , EpiGrayImgDic [ImgIdxPos.TL].Width + EpiGrayImgDic [ImgIdxPos.TM].Width); var dfInfoDic = EpiGrayImgDic.ToDictionary( dic => dic.Key , dic => EpiProcFnList[dic.Key.ImgIdx2EpiMethod()] (dic.Value)) .ToDictionary( dic => dic.Key , dic => dic.Value.FindContour(AreaUp, AreaDw)) .ToDictionary( dic => dic.Key , dic => dic.Value.FindDefectInfo()); //a List <Task> resultTaskList = new List <Task>(); Enum.GetValues(typeof(ImgIdxPos)) .Cast <ImgIdxPos>() .ActLoop(pos => { resultTaskList.Add(Task.Run(( Action )(() => DrawCircleSequance( EpiProcedImgDic [pos] // Destination , dfInfoDic [pos] // box list , dfInfoDic [pos].Count())))); }) .ActLoop(pos => { resultTaskList.Add(Task.Run(( Action )(() => CreateResult( EpiProcResultDict [pos].DefectList // Destination , dfInfoDic [pos] // Src , dfInfoDic [pos].Count() , SampleResolution)))); }); Task all = Task.WhenAll(resultTaskList.ToArray()); try { await all; // Result Combine var combined = Enum.GetValues(typeof(ImgIdxPos)) .Cast <ImgIdxPos>() .Select(pos => EpiProcResultDict [pos].DefectList .ShiftDefectData(Offset, pos, SampleResolution)) .Aggregate((f, s) => f.Concate_H(s)) .Where(x => VectorLen((x.CenterX - Offset[OffsetPos.Row1]), (x.CenterY - Offset[OffsetPos.Row1])) < Offset[OffsetPos.Row1] - OuterExcludeSize) .Select(x => x) .ToList(); //.Act( x=> evtProgressTime( 85 )); // 컴바인 result EpiProcResult_FullScale.DefectList = new List <DefectData>(combined); EpiProcResul_IdxScale.DefectList = combined.Convert2IdxPos(totalImgSize, totalImgSize, waferIndexImgSize, SampleResolution); IndexViewImg = IndexViewImg.DrawIdxDefect(EpiProcResul_IdxScale.DefectList); // Draw Index View Image /* Start Side Effect */ evtTrsIdxImg(IndexViewImg); evtTrsResizedProcedImg(Origin2ResizedImg((double)waferIndexImgSize / (double)50000 , EpiColorImgDic.First().Value.Width , EpiColorImgDic.First().Value.Height , EpiProcedImgDic) .StackSplitted()); CreateStatisticResult(EpiProcResult_FullScale); evtStatistic(new int [] { EpiProcResult_FullScale.Size1Number , EpiProcResult_FullScale.Size2Number , EpiProcResult_FullScale.Size3Number , EpiProcResult_FullScale.Size4Number }); stw.Stop(); stw.ElapsedMilliseconds.Print(" Processing Time"); evtProcTime((int)stw.ElapsedMilliseconds); } catch (Exception e) { e.ToString().Print(" Main Processing Error "); } } catch (Exception e) { e.ToString().Print(" Main Processing Error "); } }