从眼睛图像生成裁剪和蒙版的IRIS

时间:2019-05-17 09:36:00

标签: c# opencv eye-detection iris-recognition

我正在使用c#和opencv,我想根据给定的眼睛图像生成以下类型的图像。

所需的输出:  enter image description here

我成功生成了以下类型的图像,但找不到找到所需图像的方法。

到目前为止,我取得了以下成就:  enter image description here

private void SegmentIris()
{
//Clone the filled contour
        Image<Gray, Byte> InputImageCloneOne = FilledContourForSegmentation.Clone();

        Image<Gray, Byte> InputImageCloneTwo = FilledContourForSegmentation.Clone();
        MCvScalar k = new MCvScalar(255, 255, 255);

        //Draw the circle for mask in white
        CvInvoke.cvCircle(mask, PupilCenter, OuterBoundaryRadius, IrisConstants.WhiteColor, -1, Emgu.CV.CvEnum.LINE_TYPE.CV_AA, 0);

        //Create the optimised circle using pupil center and outer boundary iris -> so that circles appear proper around the iris
        if (IsContourDetectionSatisfactory)
        {
            OptimisedIrisBoundaries = FilledContourForSegmentation.Clone();
            CvInvoke.cvCircle(OptimisedIrisBoundaries, PupilCenter, OuterBoundaryRadius, IrisConstants.WhiteColor, 2, Emgu.CV.CvEnum.LINE_TYPE.CV_AA, 0);
        }
        else
        {
            OptimisedIrisBoundaries = ApproximatedPupilImage.Clone();
            CvInvoke.cvCircle(OptimisedIrisBoundaries, PupilCenter, OuterBoundaryRadius, IrisConstants.WhiteColor, 2, Emgu.CV.CvEnum.LINE_TYPE.CV_AA, 0);
        }

        //now make the mask circle black
        CvInvoke.cvNot(mask, mask);

        //Subtract the input image and filled contour image over the mask created
        CvInvoke.cvSub(InputImage, InputImageCloneOne, InputImageCloneTwo, mask);

        //Put clonetwo to segmented image
        CvInvoke.cvCopy(InputImageCloneTwo, SegmentedIrisImage, new IntPtr(0));

    }

0 个答案:

没有答案