예제 #1
0
 private Image <Gray, byte> GetMaskOfDefects(int a1, int a2, int b1, int b2, Image <Gray, float> sourceImage)
 {
     ProgressManager.AddSteps(3);
     using (Image <Gray, byte> cannyImg1 = sourceImage.Convert <Gray, byte>().Canny(a1, a2))
     {
         ProgressManager.DoStep();
         using (Image <Gray, byte> cannyImg2 = sourceImage.Convert <Gray, byte>().Canny(b1, b2))
         {
             ProgressManager.DoStep();
             using (Image <Gray, byte> cannyImg = cannyImg1.Add(cannyImg2))
             {
                 ProgressManager.DoStep();
                 return(MorphologicalProcessing.Dilate(cannyImg, new Size(3, 3), 3));
             }
         }
     }
 }
예제 #2
0
        public static Image <Bgr, byte> CombineTwoImages(Image <Bgr, byte> image, Image <Bgr, byte> imagePattern, Image <Gray, byte> mask, bool dilate = true)
        {
            ProgressManager.AddSteps(4);
            if (dilate)
            {
                mask = Dilate(mask, new Size(2, 2), 2);
            }

            //imagePattern.Image = imagePattern.Image.SmoothBlur(3, 3);

            ProgressManager.DoStep();
            using (Image <Bgr, byte> image1 = MultipleMaskAndImage(imagePattern, mask))
            {
                ProgressManager.DoStep();
                using (Image <Bgr, byte> image2 = MultipleMaskAndImage(image, GenerateBinaryImageNegative(mask)))
                {
                    ProgressManager.DoStep();
                    Image <Bgr, byte> outImage = image1.Add(image2);

                    ProgressManager.DoStep();
                    return(outImage);
                }
            }
        }