示例#1
0
        /*******************************************************
         * luvSegmentation()
         *
         * LUV color model based picture segmentation
         *
         * input: original image(Bgr), min values vector, max values vector
         * output: new modified image
         * ******************************************************/
        public Image <Bgr, Byte> luvSegmentation(Image <Bgr, Byte> srcImg, mVector3 min, mVector3 max)
        {
            Image <Luv, float> lImg   = srcImg.Convert <Luv, float>();
            Image <Bgr, Byte>  newImg = srcImg;

            for (int i = 0; i < lImg.Width; i++)
            {
                for (int j = 0; j < lImg.Height; j++)
                {
                    if (
                        ((lImg[j, i].X >= max.x) || (lImg[j, i].X <= min.x)) ||
                        ((lImg[j, i].Y >= max.y) || (lImg[j, i].Y <= min.y)) ||
                        ((lImg[j, i].Z >= max.z) || (lImg[j, i].Z <= min.z))
                        )
                    {
                        /*            if (
                         * ((lImg[j, i].X >= (border.X + tolerance)) || (lImg[j, i].X <= (border.X - tolerance))) ||
                         * ((lImg[j, i].Y >= (border.Y + toleranc/)) || (lImg[j, i].Y <= (border.Y - tolerance))) ||
                         * ((lImg[j, i].Z >= (border.Z+tolerance)) || (lImg[j, i].Z <= (border.Z - tolerance)))
                         * )
                         * {*/


                        newImg[j, i] = new Bgr(255.0f, 255.0f, 255.0f);
                    }
                }
            }

            return(newImg);
        }
        /*******************************************************
         * luvSegmentation()
         * 
         * LUV color model based picture segmentation
         * 
         * input: original image(Bgr), min values vector, max values vector
         * output: new modified image
         * ******************************************************/
        public Image<Bgr, Byte> luvSegmentation(Image<Bgr, Byte> srcImg, mVector3 min, mVector3 max)
        {
            Image<Luv, float> lImg = srcImg.Convert<Luv, float>();
            Image<Bgr, Byte> newImg = srcImg;

            for (int i = 0; i < lImg.Width; i++)
            {
                for (int j = 0; j < lImg.Height; j++)
                {
                    if (
                        ((lImg[j, i].X >= max.x) || (lImg[j, i].X <= min.x)) ||
                        ((lImg[j, i].Y >= max.y) || (lImg[j, i].Y <= min.y)) ||
                        ((lImg[j, i].Z >= max.z) || (lImg[j, i].Z <= min.z))
                        )
                    {

                        /*            if (
                ((lImg[j, i].X >= (border.X + tolerance)) || (lImg[j, i].X <= (border.X - tolerance))) ||
                ((lImg[j, i].Y >= (border.Y + toleranc/)) || (lImg[j, i].Y <= (border.Y - tolerance))) ||
                ((lImg[j, i].Z >= (border.Z+tolerance)) || (lImg[j, i].Z <= (border.Z - tolerance)))
                )
            {*/


                        newImg[j, i] = new Bgr(255.0f, 255.0f, 255.0f);
                    }
                }
            }

            return newImg;
        }