// Procedures
    public void ChangeDomainForRectangle(HObject ho_InputImage, out HObject ho_ImageResult,
                                         HTuple hv_LineStartPoint_Row, HTuple hv_LineStartPoint_Column, HTuple hv_LineEndPoint_Row,
                                         HTuple hv_LineEndPoint_Column, HTuple hv_RoiWidthLen, HTuple hv_DilationWidth,
                                         HTuple hv_DilationHeight)
    {
        // Local iconic variables

        HObject ho_Rectangle, ho_RegionDilation;


        // Local control variables

        HTuple hv_TmpCtrl_Row = null, hv_TmpCtrl_Column = null;
        HTuple hv_TmpCtrl_Dr = null, hv_TmpCtrl_Dc = null, hv_TmpCtrl_Phi = null;
        HTuple hv_TmpCtrl_Len1 = null, hv_TmpCtrl_Len2 = null;

        // Initialize local and output iconic variables
        HOperatorSet.GenEmptyObj(out ho_ImageResult);
        HOperatorSet.GenEmptyObj(out ho_Rectangle);
        HOperatorSet.GenEmptyObj(out ho_RegionDilation);

        //Measure 01: Convert coordinates to rectangle2 type
        hv_TmpCtrl_Row    = 0.5 * (hv_LineStartPoint_Row + hv_LineEndPoint_Row);
        hv_TmpCtrl_Column = 0.5 * (hv_LineStartPoint_Column + hv_LineEndPoint_Column);
        hv_TmpCtrl_Dr     = hv_LineStartPoint_Row - hv_LineEndPoint_Row;
        hv_TmpCtrl_Dc     = hv_LineEndPoint_Column - hv_LineStartPoint_Column;
        hv_TmpCtrl_Phi    = hv_TmpCtrl_Dr.TupleAtan2(hv_TmpCtrl_Dc);
        hv_TmpCtrl_Len1   = 0.5 * ((((hv_TmpCtrl_Dr * hv_TmpCtrl_Dr) + (hv_TmpCtrl_Dc * hv_TmpCtrl_Dc))).TupleSqrt()
                                   );
        hv_TmpCtrl_Len2 = hv_RoiWidthLen.Clone();
        ho_Rectangle.Dispose();
        HOperatorSet.GenRectangle2(out ho_Rectangle, hv_TmpCtrl_Row, hv_TmpCtrl_Column,
                                   hv_TmpCtrl_Phi, hv_TmpCtrl_Len1, hv_TmpCtrl_Len2);

        ho_RegionDilation.Dispose();
        HOperatorSet.DilationRectangle1(ho_Rectangle, out ho_RegionDilation, hv_DilationWidth,
                                        hv_DilationHeight);

        ho_ImageResult.Dispose();
        HOperatorSet.ChangeDomain(ho_InputImage, ho_RegionDilation, out ho_ImageResult
                                  );

        ho_Rectangle.Dispose();
        ho_RegionDilation.Dispose();

        return;
    }
Example #2
0
    // Procedures
    // Local procedures
    public void EnhanceEdgeAreaByScaleDual(HObject ho_InputImage, out HObject ho_EnhancedImage,
                                           out HObject ho_EnhancedEdge, HTuple hv_MeanMaskWidth, HTuple hv_MeanMaskHeight,
                                           HTuple hv_EdgeAreaLightDark, HTuple hv_SelectAreaMin, HTuple hv_SelectAreaMax,
                                           HTuple hv_EdgeLightDark, HTuple hv_ScaleAdd1, HTuple hv_EmpMaskWidth, HTuple hv_EmpMaskHeight,
                                           HTuple hv_EmpFactor, HTuple hv_ScaleAdd2, HTuple hv_OpeningWidth, HTuple hv_OpeningHeight,
                                           HTuple hv_ClosingWidth, HTuple hv_ClosingHeight)
    {
        // Local iconic variables

        HObject ho_Domain, ho_ImageMean, ho_Region;
        HObject ho_ConnectedRegions, ho_SelectedRegions, ho_RegionUnion;
        HObject ho_RegionTrans, ho_ImageReduced, ho_Domain1, ho_ImageScaled = null;
        HObject ho_ImageScaleMax, ho_Region2, ho_ImageReduced1;
        HObject ho_ImageEmphasize, ho_ImageScaled2 = null, ho_ImageScaleMax2;
        HObject ho_Region1, ho_RegionOpening, ho_RegionFillUp, ho_ImageNew;
        HObject ho_RegionComplement;

        // Local control variables

        HTuple hv_Width = null, hv_Height = null, hv_UsedThreshold = null;
        HTuple hv_Value = null, hv_UsedThreshold2 = null, hv_UsedThreshold1 = null;

        // Initialize local and output iconic variables
        HOperatorSet.GenEmptyObj(out ho_EnhancedImage);
        HOperatorSet.GenEmptyObj(out ho_EnhancedEdge);
        HOperatorSet.GenEmptyObj(out ho_Domain);
        HOperatorSet.GenEmptyObj(out ho_ImageMean);
        HOperatorSet.GenEmptyObj(out ho_Region);
        HOperatorSet.GenEmptyObj(out ho_ConnectedRegions);
        HOperatorSet.GenEmptyObj(out ho_SelectedRegions);
        HOperatorSet.GenEmptyObj(out ho_RegionUnion);
        HOperatorSet.GenEmptyObj(out ho_RegionTrans);
        HOperatorSet.GenEmptyObj(out ho_ImageReduced);
        HOperatorSet.GenEmptyObj(out ho_Domain1);
        HOperatorSet.GenEmptyObj(out ho_ImageScaled);
        HOperatorSet.GenEmptyObj(out ho_ImageScaleMax);
        HOperatorSet.GenEmptyObj(out ho_Region2);
        HOperatorSet.GenEmptyObj(out ho_ImageReduced1);
        HOperatorSet.GenEmptyObj(out ho_ImageEmphasize);
        HOperatorSet.GenEmptyObj(out ho_ImageScaled2);
        HOperatorSet.GenEmptyObj(out ho_ImageScaleMax2);
        HOperatorSet.GenEmptyObj(out ho_Region1);
        HOperatorSet.GenEmptyObj(out ho_RegionOpening);
        HOperatorSet.GenEmptyObj(out ho_RegionFillUp);
        HOperatorSet.GenEmptyObj(out ho_ImageNew);
        HOperatorSet.GenEmptyObj(out ho_RegionComplement);
        ho_Domain.Dispose();
        HOperatorSet.GetDomain(ho_InputImage, out ho_Domain);
        HOperatorSet.RegionFeatures(ho_Domain, "width", out hv_Width);
        HOperatorSet.RegionFeatures(ho_Domain, "height", out hv_Height);

        ho_ImageMean.Dispose();
        HOperatorSet.MeanImage(ho_InputImage, out ho_ImageMean, hv_MeanMaskWidth, hv_MeanMaskHeight);

        ho_Region.Dispose();
        HOperatorSet.BinaryThreshold(ho_ImageMean, out ho_Region, "max_separability",
                                     hv_EdgeAreaLightDark, out hv_UsedThreshold);

        ho_ConnectedRegions.Dispose();
        HOperatorSet.Connection(ho_Region, out ho_ConnectedRegions);
        ho_SelectedRegions.Dispose();
        HOperatorSet.SelectShape(ho_ConnectedRegions, out ho_SelectedRegions, "area",
                                 "and", hv_SelectAreaMin, hv_SelectAreaMax);
        ho_RegionUnion.Dispose();
        HOperatorSet.Union1(ho_SelectedRegions, out ho_RegionUnion);
        ho_RegionTrans.Dispose();
        HOperatorSet.ShapeTrans(ho_RegionUnion, out ho_RegionTrans, "convex");
        ho_ImageReduced.Dispose();
        HOperatorSet.ReduceDomain(ho_ImageMean, ho_RegionTrans, out ho_ImageReduced);

        ho_Domain1.Dispose();
        HOperatorSet.GetDomain(ho_ImageReduced, out ho_Domain1);
        HOperatorSet.GrayFeatures(ho_Domain1, ho_ImageReduced, "mean", out hv_Value);
        if ((int)(new HTuple(hv_EdgeLightDark.TupleEqual("dark"))) != 0)
        {
            ho_ImageScaled.Dispose();
            HOperatorSet.ScaleImage(ho_ImageReduced, out ho_ImageScaled, 1, (255 - hv_Value) + hv_ScaleAdd1);
        }
        else if ((int)(new HTuple(hv_EdgeLightDark.TupleEqual("light"))) != 0)
        {
            ho_ImageScaled.Dispose();
            HOperatorSet.ScaleImage(ho_ImageReduced, out ho_ImageScaled, 1, (-hv_Value) + hv_ScaleAdd1);
        }
        ho_ImageScaleMax.Dispose();
        HOperatorSet.ScaleImageMax(ho_ImageScaled, out ho_ImageScaleMax);

        ho_Region2.Dispose();
        HOperatorSet.BinaryThreshold(ho_ImageScaleMax, out ho_Region2, "max_separability",
                                     hv_EdgeLightDark, out hv_UsedThreshold2);
        ho_ImageReduced1.Dispose();
        HOperatorSet.ReduceDomain(ho_ImageScaleMax, ho_Region2, out ho_ImageReduced1);

        ho_ImageEmphasize.Dispose();
        HOperatorSet.Emphasize(ho_ImageReduced1, out ho_ImageEmphasize, hv_EmpMaskWidth,
                               hv_EmpMaskHeight, hv_EmpFactor);

        HOperatorSet.GrayFeatures(ho_Region2, ho_ImageEmphasize, "mean", out hv_Value);
        if ((int)(new HTuple(hv_EdgeLightDark.TupleEqual("dark"))) != 0)
        {
            ho_ImageScaled2.Dispose();
            HOperatorSet.ScaleImage(ho_ImageEmphasize, out ho_ImageScaled2, 1, (255 - hv_Value) + hv_ScaleAdd2);
        }
        else if ((int)(new HTuple(hv_EdgeLightDark.TupleEqual("light"))) != 0)
        {
            ho_ImageScaled2.Dispose();
            HOperatorSet.ScaleImage(ho_ImageEmphasize, out ho_ImageScaled2, 1, (-hv_Value) + hv_ScaleAdd2);
        }
        ho_ImageScaleMax2.Dispose();
        HOperatorSet.ScaleImageMax(ho_ImageScaled2, out ho_ImageScaleMax2);

        ho_Region1.Dispose();
        HOperatorSet.BinaryThreshold(ho_ImageScaleMax2, out ho_Region1, "max_separability",
                                     hv_EdgeLightDark, out hv_UsedThreshold1);
        ho_RegionOpening.Dispose();
        HOperatorSet.OpeningRectangle1(ho_Region1, out ho_RegionOpening, hv_OpeningWidth,
                                       hv_MeanMaskHeight);
        ho_EnhancedEdge.Dispose();
        HOperatorSet.ClosingRectangle1(ho_RegionOpening, out ho_EnhancedEdge, hv_ClosingWidth,
                                       hv_ClosingHeight);
        ho_RegionFillUp.Dispose();
        HOperatorSet.FillUp(ho_EnhancedEdge, out ho_RegionFillUp);

        ho_ImageNew.Dispose();
        HOperatorSet.ChangeDomain(ho_InputImage, ho_Domain, out ho_ImageNew);
        ho_RegionComplement.Dispose();
        HOperatorSet.Complement(ho_RegionFillUp, out ho_RegionComplement);
        ho_EnhancedImage.Dispose();
        HOperatorSet.PaintRegion(ho_RegionFillUp, ho_ImageNew, out ho_EnhancedImage,
                                 255, "fill");
        HOperatorSet.OverpaintRegion(ho_EnhancedImage, ho_RegionComplement, 0, "fill");

        ho_Domain.Dispose();
        ho_ImageMean.Dispose();
        ho_Region.Dispose();
        ho_ConnectedRegions.Dispose();
        ho_SelectedRegions.Dispose();
        ho_RegionUnion.Dispose();
        ho_RegionTrans.Dispose();
        ho_ImageReduced.Dispose();
        ho_Domain1.Dispose();
        ho_ImageScaled.Dispose();
        ho_ImageScaleMax.Dispose();
        ho_Region2.Dispose();
        ho_ImageReduced1.Dispose();
        ho_ImageEmphasize.Dispose();
        ho_ImageScaled2.Dispose();
        ho_ImageScaleMax2.Dispose();
        ho_Region1.Dispose();
        ho_RegionOpening.Dispose();
        ho_RegionFillUp.Dispose();
        ho_ImageNew.Dispose();
        ho_RegionComplement.Dispose();

        return;
    }
    // Procedures
    // Local procedures
    public void EnhanceEdgeArea4(HObject ho_InputImage, out HObject ho_EnhancedImage,
                                 out HObject ho_EnhancedEdge, HTuple hv_MeanMaskWidth, HTuple hv_MeanMaskHeight,
                                 HTuple hv_FirstMinGray, HTuple hv_FirstMaxGray, HTuple hv_SortOrder, HTuple hv_EmpMaskWidth,
                                 HTuple hv_EmpMaskHeight, HTuple hv_EmpMaskFactor, HTuple hv_LastMinGray, HTuple hv_LastMaxGray)
    {
        // Local iconic variables

        HObject ho_Domain, ho_ImageMean, ho_Regions;
        HObject ho_ConnectedRegions1, ho_SelectedRegions2 = null;
        HObject ho_SortedRegions = null, ho_ObjectSelected = null, ho_RegionFillUp;
        HObject ho_ImageReduced, ho_ImageScaleMax, ho_ImageMean2;
        HObject ho_ImageEmphasize, ho_Regions2, ho_ConnectedRegions;
        HObject ho_SelectedRegions = null, ho_RegionDifference;

        // Local control variables

        HTuple hv_Width = null, hv_Height = null;

        // Initialize local and output iconic variables
        HOperatorSet.GenEmptyObj(out ho_EnhancedImage);
        HOperatorSet.GenEmptyObj(out ho_EnhancedEdge);
        HOperatorSet.GenEmptyObj(out ho_Domain);
        HOperatorSet.GenEmptyObj(out ho_ImageMean);
        HOperatorSet.GenEmptyObj(out ho_Regions);
        HOperatorSet.GenEmptyObj(out ho_ConnectedRegions1);
        HOperatorSet.GenEmptyObj(out ho_SelectedRegions2);
        HOperatorSet.GenEmptyObj(out ho_SortedRegions);
        HOperatorSet.GenEmptyObj(out ho_ObjectSelected);
        HOperatorSet.GenEmptyObj(out ho_RegionFillUp);
        HOperatorSet.GenEmptyObj(out ho_ImageReduced);
        HOperatorSet.GenEmptyObj(out ho_ImageScaleMax);
        HOperatorSet.GenEmptyObj(out ho_ImageMean2);
        HOperatorSet.GenEmptyObj(out ho_ImageEmphasize);
        HOperatorSet.GenEmptyObj(out ho_Regions2);
        HOperatorSet.GenEmptyObj(out ho_ConnectedRegions);
        HOperatorSet.GenEmptyObj(out ho_SelectedRegions);
        HOperatorSet.GenEmptyObj(out ho_RegionDifference);
        ho_Domain.Dispose();
        HOperatorSet.GetDomain(ho_InputImage, out ho_Domain);
        HOperatorSet.RegionFeatures(ho_Domain, "width", out hv_Width);
        HOperatorSet.RegionFeatures(ho_Domain, "height", out hv_Height);

        ho_ImageMean.Dispose();
        HOperatorSet.MeanImage(ho_InputImage, out ho_ImageMean, hv_MeanMaskWidth, hv_MeanMaskHeight);
        ho_Regions.Dispose();
        HOperatorSet.Threshold(ho_ImageMean, out ho_Regions, hv_FirstMinGray, hv_FirstMaxGray);
        ho_ConnectedRegions1.Dispose();
        HOperatorSet.Connection(ho_Regions, out ho_ConnectedRegions1);

        if ((int)(new HTuple(hv_MeanMaskWidth.TupleGreater(hv_MeanMaskHeight))) != 0)
        {
            ho_SelectedRegions2.Dispose();
            HOperatorSet.SelectShape(ho_ConnectedRegions1, out ho_SelectedRegions2, "width",
                                     "and", hv_Width * 0.9, hv_Width);
            ho_SortedRegions.Dispose();
            HOperatorSet.SortRegion(ho_SelectedRegions2, out ho_SortedRegions, "upper_left",
                                    hv_SortOrder, "row");
            ho_ObjectSelected.Dispose();
            HOperatorSet.SelectObj(ho_SortedRegions, out ho_ObjectSelected, 1);
        }
        else
        {
            ho_SelectedRegions2.Dispose();
            HOperatorSet.SelectShape(ho_ConnectedRegions1, out ho_SelectedRegions2, "height",
                                     "and", hv_Height * 0.9, hv_Height);
            ho_SortedRegions.Dispose();
            HOperatorSet.SortRegion(ho_SelectedRegions2, out ho_SortedRegions, "upper_left",
                                    hv_SortOrder, "column");
            ho_ObjectSelected.Dispose();
            HOperatorSet.SelectObj(ho_SortedRegions, out ho_ObjectSelected, 1);
        }

        ho_RegionFillUp.Dispose();
        HOperatorSet.FillUp(ho_ObjectSelected, out ho_RegionFillUp);

        ho_ImageReduced.Dispose();
        HOperatorSet.ReduceDomain(ho_ImageMean, ho_RegionFillUp, out ho_ImageReduced);
        ho_ImageScaleMax.Dispose();
        HOperatorSet.ScaleImageMax(ho_ImageReduced, out ho_ImageScaleMax);

        ho_ImageMean2.Dispose();
        HOperatorSet.MeanImage(ho_ImageScaleMax, out ho_ImageMean2, hv_MeanMaskWidth,
                               hv_MeanMaskHeight);
        ho_ImageEmphasize.Dispose();
        HOperatorSet.Emphasize(ho_ImageMean2, out ho_ImageEmphasize, hv_EmpMaskWidth,
                               hv_EmpMaskHeight, hv_EmpMaskFactor);

        ho_Regions2.Dispose();
        HOperatorSet.Threshold(ho_ImageEmphasize, out ho_Regions2, hv_LastMinGray, hv_LastMaxGray);
        ho_ConnectedRegions.Dispose();
        HOperatorSet.Connection(ho_Regions2, out ho_ConnectedRegions);

        if ((int)(new HTuple(hv_MeanMaskWidth.TupleGreater(hv_MeanMaskHeight))) != 0)
        {
            ho_SelectedRegions.Dispose();
            HOperatorSet.SelectShape(ho_ConnectedRegions, out ho_SelectedRegions, "width",
                                     "and", hv_Width * 0.1, hv_Width);
        }
        else
        {
            ho_SelectedRegions.Dispose();
            HOperatorSet.SelectShape(ho_ConnectedRegions, out ho_SelectedRegions, "height",
                                     "and", hv_Height * 0.1, hv_Height);
        }

        ho_EnhancedEdge.Dispose();
        HOperatorSet.MoveRegion(ho_SelectedRegions, out ho_EnhancedEdge, 0, 0);

        ho_EnhancedImage.Dispose();
        HOperatorSet.ChangeDomain(ho_ImageEmphasize, ho_Domain, out ho_EnhancedImage);

        ho_RegionDifference.Dispose();
        HOperatorSet.Difference(ho_Domain, ho_SelectedRegions, out ho_RegionDifference
                                );

        HOperatorSet.OverpaintRegion(ho_EnhancedImage, ho_RegionDifference, 255, "fill");

        ho_Domain.Dispose();
        ho_ImageMean.Dispose();
        ho_Regions.Dispose();
        ho_ConnectedRegions1.Dispose();
        ho_SelectedRegions2.Dispose();
        ho_SortedRegions.Dispose();
        ho_ObjectSelected.Dispose();
        ho_RegionFillUp.Dispose();
        ho_ImageReduced.Dispose();
        ho_ImageScaleMax.Dispose();
        ho_ImageMean2.Dispose();
        ho_ImageEmphasize.Dispose();
        ho_Regions2.Dispose();
        ho_ConnectedRegions.Dispose();
        ho_SelectedRegions.Dispose();
        ho_RegionDifference.Dispose();

        return;
    }
    // Procedures
    // Local procedures
    public void EnhanceEdgeAreaByBinaryThresholdWithMean(HObject ho_InputImage, out HObject ho_EnhancedImage,
                                                         out HObject ho_EnhancedRegion, HTuple hv_MeanMaskWidth, HTuple hv_MeanMaskHeight,
                                                         HTuple hv_EmpWidth, HTuple hv_EmpHeight, HTuple hv_EmpFactor, HTuple hv_LightDark,
                                                         HTuple hv_AreaMin, HTuple hv_AreaMax, HTuple hv_ClosingWidth, HTuple hv_ClosingHeight,
                                                         HTuple hv_DilationRadius)
    {
        // Stack for temporary objects
        HObject[] OTemp = new HObject[20];

        // Local iconic variables

        HObject ho_Domain, ho_ImageMean, ho_ImageEmphasize;
        HObject ho_Regions, ho_ConnectedRegions, ho_SelectedRegions;
        HObject ho_RegionFillUp, ho_RegionUnion, ho_ImageNew, ho_RegionComplement;

        // Local control variables

        HTuple hv_Width = null, hv_Height = null, hv_UsedThreshold = null;

        // Initialize local and output iconic variables
        HOperatorSet.GenEmptyObj(out ho_EnhancedImage);
        HOperatorSet.GenEmptyObj(out ho_EnhancedRegion);
        HOperatorSet.GenEmptyObj(out ho_Domain);
        HOperatorSet.GenEmptyObj(out ho_ImageMean);
        HOperatorSet.GenEmptyObj(out ho_ImageEmphasize);
        HOperatorSet.GenEmptyObj(out ho_Regions);
        HOperatorSet.GenEmptyObj(out ho_ConnectedRegions);
        HOperatorSet.GenEmptyObj(out ho_SelectedRegions);
        HOperatorSet.GenEmptyObj(out ho_RegionFillUp);
        HOperatorSet.GenEmptyObj(out ho_RegionUnion);
        HOperatorSet.GenEmptyObj(out ho_ImageNew);
        HOperatorSet.GenEmptyObj(out ho_RegionComplement);
        ho_Domain.Dispose();
        HOperatorSet.GetDomain(ho_InputImage, out ho_Domain);
        HOperatorSet.RegionFeatures(ho_Domain, "width", out hv_Width);
        HOperatorSet.RegionFeatures(ho_Domain, "height", out hv_Height);

        ho_ImageMean.Dispose();
        HOperatorSet.MeanImage(ho_InputImage, out ho_ImageMean, hv_MeanMaskWidth, hv_MeanMaskHeight);
        ho_ImageEmphasize.Dispose();
        HOperatorSet.Emphasize(ho_ImageMean, out ho_ImageEmphasize, hv_EmpWidth, hv_EmpHeight,
                               hv_EmpFactor);
        ho_Regions.Dispose();
        HOperatorSet.BinaryThreshold(ho_ImageEmphasize, out ho_Regions, "max_separability",
                                     hv_LightDark, out hv_UsedThreshold);
        ho_ConnectedRegions.Dispose();
        HOperatorSet.Connection(ho_Regions, out ho_ConnectedRegions);
        ho_SelectedRegions.Dispose();
        HOperatorSet.SelectShape(ho_ConnectedRegions, out ho_SelectedRegions, "area",
                                 "and", hv_AreaMin, hv_AreaMax);
        ho_RegionFillUp.Dispose();
        HOperatorSet.FillUp(ho_SelectedRegions, out ho_RegionFillUp);

        if ((int)((new HTuple(hv_ClosingWidth.TupleGreater(0))).TupleAnd(new HTuple(hv_ClosingHeight.TupleGreater(
                                                                                        0)))) != 0)
        {
            {
                HObject ExpTmpOutVar_0;
                HOperatorSet.ClosingRectangle1(ho_RegionFillUp, out ExpTmpOutVar_0, hv_ClosingWidth,
                                               hv_ClosingHeight);
                ho_RegionFillUp.Dispose();
                ho_RegionFillUp = ExpTmpOutVar_0;
            }
        }

        if ((int)(new HTuple(hv_DilationRadius.TupleGreater(0))) != 0)
        {
            {
                HObject ExpTmpOutVar_0;
                HOperatorSet.DilationCircle(ho_RegionFillUp, out ExpTmpOutVar_0, hv_DilationRadius);
                ho_RegionFillUp.Dispose();
                ho_RegionFillUp = ExpTmpOutVar_0;
            }
        }

        ho_RegionUnion.Dispose();
        HOperatorSet.Union1(ho_RegionFillUp, out ho_RegionUnion);
        ho_EnhancedRegion.Dispose();
        HOperatorSet.MoveRegion(ho_RegionUnion, out ho_EnhancedRegion, 0, 0);

        ho_ImageNew.Dispose();
        HOperatorSet.ChangeDomain(ho_InputImage, ho_Domain, out ho_ImageNew);
        ho_RegionComplement.Dispose();
        HOperatorSet.Complement(ho_RegionFillUp, out ho_RegionComplement);
        ho_EnhancedImage.Dispose();
        HOperatorSet.PaintRegion(ho_RegionFillUp, ho_ImageNew, out ho_EnhancedImage,
                                 255, "fill");
        HOperatorSet.OverpaintRegion(ho_EnhancedImage, ho_RegionComplement, 0, "fill");

        ho_Domain.Dispose();
        ho_ImageMean.Dispose();
        ho_ImageEmphasize.Dispose();
        ho_Regions.Dispose();
        ho_ConnectedRegions.Dispose();
        ho_SelectedRegions.Dispose();
        ho_RegionFillUp.Dispose();
        ho_RegionUnion.Dispose();
        ho_ImageNew.Dispose();
        ho_RegionComplement.Dispose();

        return;
    }
    // Procedures
    public void EnhanceEdgeAreaByScale(HObject ho_InputImage, out HObject ho_EnhancedImage,
                                       out HObject ho_EnhancedEdge, HTuple hv_MeanMaskWidth, HTuple hv_MeanMaskHeight,
                                       HTuple hv_EdgeAreaLightDark, HTuple hv_ScaleAdd, HTuple hv_OpeningWidth, HTuple hv_OpeningHeight,
                                       HTuple hv_ClosingWidth, HTuple hv_ClosingHeight)
    {
        // Local iconic variables

        HObject ho_Domain, ho_ImageMean, ho_Region;
        HObject ho_ImageReduced, ho_ImageScaled = null, ho_Region1;
        HObject ho_RegionOpening, ho_RegionFillUp, ho_ImageNew;
        HObject ho_RegionComplement;

        // Local control variables

        HTuple hv_Width = null, hv_Height = null, hv_UsedThreshold = null;
        HTuple hv_Value = null, hv_UsedThreshold1 = null;

        // Initialize local and output iconic variables
        HOperatorSet.GenEmptyObj(out ho_EnhancedImage);
        HOperatorSet.GenEmptyObj(out ho_EnhancedEdge);
        HOperatorSet.GenEmptyObj(out ho_Domain);
        HOperatorSet.GenEmptyObj(out ho_ImageMean);
        HOperatorSet.GenEmptyObj(out ho_Region);
        HOperatorSet.GenEmptyObj(out ho_ImageReduced);
        HOperatorSet.GenEmptyObj(out ho_ImageScaled);
        HOperatorSet.GenEmptyObj(out ho_Region1);
        HOperatorSet.GenEmptyObj(out ho_RegionOpening);
        HOperatorSet.GenEmptyObj(out ho_RegionFillUp);
        HOperatorSet.GenEmptyObj(out ho_ImageNew);
        HOperatorSet.GenEmptyObj(out ho_RegionComplement);
        ho_Domain.Dispose();
        HOperatorSet.GetDomain(ho_InputImage, out ho_Domain);
        HOperatorSet.RegionFeatures(ho_Domain, "width", out hv_Width);
        HOperatorSet.RegionFeatures(ho_Domain, "height", out hv_Height);

        ho_ImageMean.Dispose();
        HOperatorSet.MeanImage(ho_InputImage, out ho_ImageMean, hv_MeanMaskWidth, hv_MeanMaskHeight);

        ho_Region.Dispose();
        HOperatorSet.BinaryThreshold(ho_ImageMean, out ho_Region, "max_separability",
                                     hv_EdgeAreaLightDark, out hv_UsedThreshold);
        ho_ImageReduced.Dispose();
        HOperatorSet.ReduceDomain(ho_ImageMean, ho_Region, out ho_ImageReduced);

        HOperatorSet.GrayFeatures(ho_Region, ho_ImageReduced, "mean", out hv_Value);

        if ((int)(new HTuple(hv_EdgeAreaLightDark.TupleEqual("dark"))) != 0)
        {
            ho_ImageScaled.Dispose();
            HOperatorSet.ScaleImage(ho_ImageReduced, out ho_ImageScaled, 1, (-hv_Value) + hv_ScaleAdd);
        }
        else if ((int)(new HTuple(hv_EdgeAreaLightDark.TupleEqual("light"))) != 0)
        {
            ho_ImageScaled.Dispose();
            HOperatorSet.ScaleImage(ho_ImageReduced, out ho_ImageScaled, 1, (255 - hv_Value) + hv_ScaleAdd);
        }

        ho_Region1.Dispose();
        HOperatorSet.BinaryThreshold(ho_ImageScaled, out ho_Region1, "max_separability",
                                     hv_EdgeAreaLightDark, out hv_UsedThreshold1);

        ho_RegionOpening.Dispose();
        HOperatorSet.OpeningRectangle1(ho_Region1, out ho_RegionOpening, hv_OpeningWidth,
                                       hv_MeanMaskHeight);
        ho_EnhancedEdge.Dispose();
        HOperatorSet.ClosingRectangle1(ho_RegionOpening, out ho_EnhancedEdge, hv_ClosingWidth,
                                       hv_ClosingHeight);
        ho_RegionFillUp.Dispose();
        HOperatorSet.FillUp(ho_EnhancedEdge, out ho_RegionFillUp);

        ho_ImageNew.Dispose();
        HOperatorSet.ChangeDomain(ho_InputImage, ho_Domain, out ho_ImageNew);
        ho_RegionComplement.Dispose();
        HOperatorSet.Complement(ho_RegionFillUp, out ho_RegionComplement);
        ho_EnhancedImage.Dispose();
        HOperatorSet.PaintRegion(ho_RegionFillUp, ho_ImageNew, out ho_EnhancedImage,
                                 255, "fill");
        HOperatorSet.OverpaintRegion(ho_EnhancedImage, ho_RegionComplement, 0, "fill");

        ho_Domain.Dispose();
        ho_ImageMean.Dispose();
        ho_Region.Dispose();
        ho_ImageReduced.Dispose();
        ho_ImageScaled.Dispose();
        ho_Region1.Dispose();
        ho_RegionOpening.Dispose();
        ho_RegionFillUp.Dispose();
        ho_ImageNew.Dispose();
        ho_RegionComplement.Dispose();

        return;
    }