void ChangeFront2ImgProcStep() { btnStartProcssing.IsEnabled = true; Removeevent(canvasLT, canvasRB); ClearLRFrame(); while (canvas.Children.Count > 0) { canvas.Children.RemoveAt(canvas.Children.Count - 1); } // delect rect titleRB.Text = "Histogram"; titleLT.Text = "Indexing View"; Core.EstedChipPos = ImgPFunc.FnCreateEstedChipPos((Core.PData.EndImgPos[1] - Core.PData.StrImgPos[1]), (Core.PData.EndImgPos[0] - Core.PData.StrImgPos[0]), Core.PData.StrImgPos[1], Core.PData.StrImgPos[0]); Core.IndexViewImg = new Image <Bgr, byte>(Core.PData.ChipWNum, Core.PData.ChipHNum); Core.IndexViewImg.Data = MatPattern(Core.PData.ChipHNum, Core.PData.ChipWNum, 3); imgLT.ImageSource = BitmapSourceConvert.ToBitmapSource(Core.IndexViewImg); imgRB.ImageSource = null; //var passfun = curry(HistoFromImage(Core.BinSize))(Core.OriginImg); // Passing Form WinHost = CreateWinHost(canvasLT); HistoBox = new HistogramBox(); canvasRB.Children.Clear(); WinHost.Child = HistoBox; canvasRB.Children.Add(WinHost); }
public void InitFunc(Canvas canvas) { DoZoom = ImgPFunc.FnActZoom(zoom, zoomMax, zoomMin, zoomSpeed); CropImgLT = ImgPFunc.FnCropImg(0, 0, 35, 35); CropImgRB = ImgPFunc.FnCropImg(OriginImg.Width - 35, OriginImg.Height - 35, OriginImg.Width, OriginImg.Height); MapCanv2Img = ImgPFunc.FnMapCanv2Img(new double[2] { canvas.Width, canvas.Height }, new int[2] { OriginImg.Width, OriginImg.Height }); MapImg2Canv = ImgPFunc.FnMapImg2Canv(new double[2] { canvas.Width, canvas.Height }, new int[2] { OriginImg.Width, OriginImg.Height }); MapCanv2ImgLTRB = ImgPFunc.FnMapCanv2Img(new double[2] { canvas.Width, canvas.Height }, new int[2] { ( int )LTRBPixelNumberW, ( int )LTRBPixelNumberH }); SumBox = ImgPFunc.FnSumBox(OriginImg); }
void CreateFuncofProc() { double thres = Core.PData.ThresholdV; double areaup = Core.PData.UPAreaLimit; double areadw = Core.PData.DWAreaLimit; double cHnum = Core.PData.ChipHNum; double cWnum = Core.PData.ChipWNum; ThresholdMode mode = ckbThresMode.IsChecked.Value ? ThresholdMode.Auto : ThresholdMode.Manual; Core.SumAreaPoint = ImgPFunc.FnSumAreaPoint((int)Core.PData.ChipWSize, ( int )Core.PData.ChipHSize, Core.OriginImg); Core.FindPassContour = ImgPFunc.FnFindPassContour(thres, areaup, areadw, mode); Core.ApplyBox = ImgPFunc.FnApplyBox(Core.PData.UPBoxLimit, Core.PData.DWBoxLimit); }
void PorcessingStep1() { CreateFuncofProc(); //return Task.Run( () => //{ try { this.BeginInvoke(() => Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait); var temp = Core.PResult; Core.PResult = new ImgPResult(); /* For Simple Notation */ double cHnum = Core.PData.ChipHNum; double cWnum = Core.PData.ChipWNum; Image <Bgr, byte> targetimg = null; /* Create Data */ byte[,,] failchipDisplayData = MatPattern((int)cHnum, (int)cWnum, 3); byte[,,] passfailPosData = new byte[(int)cHnum, (int)cWnum, 1]; double[,,] estedChipP = Core.EstedChipPos(cHnum, cWnum); var passContours = Core.FindPassContour(Core.OriginImg); Core.passChipList = new List <System.Drawing.PointF>(); Core.failChipList = new List <System.Drawing.PointF>(); targetimg = Core.ColorOriImg.Clone(); /* Draw Contour and Save */ //targetimg = DrawContour( targetimg , passContours ); //targetimg.Save( TestFileSavePath.ContourName ); passContours = ImgPFunc.FnSortcontours(passContours)(); var boxlist = Core.ApplyBox(passContours); targetimg = DrawBox(targetimg, boxlist); //targetimg.Save( TestFileSavePath.BoxName ); // Draw EstedPoint on Image and Cavnas targetimg = DrawCenterPoint(targetimg, estedChipP); #region check pass fail var boximg = Core.ColorOriImg.Clone(); for (int j = 0; j < estedChipP.GetLength(1); j++) // col { for (int i = 0; i < estedChipP.GetLength(0); i++) // row { bool isFail = true; for (int k = 0; k < boxlist.Count; k++) { var inbox = ImgPFunc.FnInBox(boxlist[k], 1); if (inbox(estedChipP[i, j, 0], estedChipP[i, j, 1])) { Core.PResult.OutData.Add(new ExResult(j, i, true, Core.SumBox(boxlist[k]), CvInvoke.ContourArea(passContours[k]))); Core.passChipList.Add(new System.Drawing.PointF(( float )estedChipP[i, j, 0], ( float )estedChipP[i, j, 1])); isFail = false; break; } if (isFail) { double failboxInten = Core.SumAreaPoint((int)estedChipP[i, j, 0], (int)estedChipP[i, j, 1]); Core.PResult.OutData.Add(new ExResult(j, i, false, failboxInten, 0)); Core.failChipList.Add(new System.Drawing.PointF(( float )estedChipP[i, j, 0], ( float )estedChipP[i, j, 1])); failchipDisplayData[i, j, 0] = ( byte )(failchipDisplayData[i, j, 0] * 0.3); failchipDisplayData[i, j, 1] = ( byte )(failchipDisplayData[i, j, 1] * 0.5); failchipDisplayData[i, j, 2] = 200; } } } Core.IndexViewImg.Data = failchipDisplayData; Core.ProcedImg = targetimg; lblPassChipnum.BeginInvoke(() => lblPassChipnum.Content = Core.passChipList.Count()); lblFailChipnum.BeginInvoke(() => lblFailChipnum.Content = Core.failChipList.Count()); Core.PResult.ChipPassCount = Core.passChipList.Count(); Core.PResult.ChipFailCount = Core.failChipList.Count(); #endregion this.BeginInvoke(() => { imgPro.ImageSource = BitmapSourceConvert.ToBitmapSource(targetimg); imgLT.ImageSource = BitmapSourceConvert.ToBitmapSource(Core.IndexViewImg); Mouse.OverrideCursor = null; }); } } catch (Exception er) { System.Windows.Forms.MessageBox.Show(er.ToString()); } //} ); }