/// <summary>
        /// Extracts the calibration plate and the marks on this plate
        /// for the supplied image
        /// </summary>
        public void find_caltab_edges(HObject ho_Image,
                                      out HObject ho_Caltab,
                                      out HObject ho_Marks,
                                      HTuple hv_DescriptionFileName)
        {
            // Stack for temporary objects
            HObject[] OTemp = new HObject[20];
            long      SP_O  = 0;

            // Local iconic variables

            HObject ho_ImageMean, ho_RegionDynThresh, ho_RegionBorder;
            HObject ho_RegionOpening1, ho_ConnectedRegions1, ho_SelectedRegions4;
            HObject ho_SelectedRegions5, ho_RegionBorder2, ho_RegionTrans;
            HObject ho_RegionErosion, ho_RegionBorder1, ho_RegionDilation2;
            HObject ho_RegionDifference1, ho_RegionOpening, ho_ConnectedRegions;
            HObject ho_SelectedRegions2, ho_SelectedRegions, ho_RegionFillUp;
            HObject ho_SelectedRegions1, ho_RegionIntersection, ho_RegionFillUp1;
            HObject ho_RegionDifference, ho_CaltabCandidates, ho_ObjectSelected = null;
            HObject ho_ConnectedMarks = null, ho_ObjectSelectedCaltab = null;
            HObject ho_RegionFillUpCand, ho_MarksCand, ho_RegionDilation1;
            HObject ho_ImageReduced, ho_DefaultEdges, ho_UnionContours;
            HObject ho_SelectedXLD, ho_SelectedXLD1;


            // Local control variables

            HTuple hv_ExpDefaultCtrlDummyVar, hv_Width;
            HTuple hv_Height, hv_EstimatedCaltabSize, hv_EstimatedMarkSize;
            HTuple hv_Number, hv_X, hv_Y, hv_Z, hv_NumDescrMarks, hv_Index;
            HTuple hv_NumberMarks = new HTuple(), hv_Anisometry = new HTuple();
            HTuple hv_Bulkiness = new HTuple(), hv_StructureFactor = new HTuple();
            HTuple hv_AreaMarks = new HTuple(), hv_Row = new HTuple();
            HTuple hv_Column = new HTuple(), hv_Rectangularity, hv_SortedIndex;
            HTuple hv_IndexBest, hv_MinContrast, hv_NumberCand, hv_Area;
            HTuple hv_Dummy, hv_DummyS, hv_AreaMedian;

            // Initialize local and output iconic variables
            HOperatorSet.GenEmptyObj(out ho_Caltab);
            HOperatorSet.GenEmptyObj(out ho_Marks);
            HOperatorSet.GenEmptyObj(out ho_ImageMean);
            HOperatorSet.GenEmptyObj(out ho_RegionDynThresh);
            HOperatorSet.GenEmptyObj(out ho_RegionBorder);
            HOperatorSet.GenEmptyObj(out ho_RegionOpening1);
            HOperatorSet.GenEmptyObj(out ho_ConnectedRegions1);
            HOperatorSet.GenEmptyObj(out ho_SelectedRegions4);
            HOperatorSet.GenEmptyObj(out ho_SelectedRegions5);
            HOperatorSet.GenEmptyObj(out ho_RegionBorder2);
            HOperatorSet.GenEmptyObj(out ho_RegionTrans);
            HOperatorSet.GenEmptyObj(out ho_RegionErosion);
            HOperatorSet.GenEmptyObj(out ho_RegionBorder1);
            HOperatorSet.GenEmptyObj(out ho_RegionDilation2);
            HOperatorSet.GenEmptyObj(out ho_RegionDifference1);
            HOperatorSet.GenEmptyObj(out ho_RegionOpening);
            HOperatorSet.GenEmptyObj(out ho_ConnectedRegions);
            HOperatorSet.GenEmptyObj(out ho_SelectedRegions2);
            HOperatorSet.GenEmptyObj(out ho_SelectedRegions);
            HOperatorSet.GenEmptyObj(out ho_RegionFillUp);
            HOperatorSet.GenEmptyObj(out ho_SelectedRegions1);
            HOperatorSet.GenEmptyObj(out ho_RegionIntersection);
            HOperatorSet.GenEmptyObj(out ho_RegionFillUp1);
            HOperatorSet.GenEmptyObj(out ho_RegionDifference);
            HOperatorSet.GenEmptyObj(out ho_CaltabCandidates);
            HOperatorSet.GenEmptyObj(out ho_ObjectSelected);
            HOperatorSet.GenEmptyObj(out ho_ConnectedMarks);
            HOperatorSet.GenEmptyObj(out ho_ObjectSelectedCaltab);
            HOperatorSet.GenEmptyObj(out ho_RegionFillUpCand);
            HOperatorSet.GenEmptyObj(out ho_MarksCand);
            HOperatorSet.GenEmptyObj(out ho_RegionDilation1);
            HOperatorSet.GenEmptyObj(out ho_ImageReduced);
            HOperatorSet.GenEmptyObj(out ho_DefaultEdges);
            HOperatorSet.GenEmptyObj(out ho_UnionContours);
            HOperatorSet.GenEmptyObj(out ho_SelectedXLD);
            HOperatorSet.GenEmptyObj(out ho_SelectedXLD1);

            //
            ho_Marks.Dispose();
            HOperatorSet.GenEmptyObj(out ho_Marks);
            ho_Caltab.Dispose();
            HOperatorSet.GenEmptyObj(out ho_Caltab);
            HOperatorSet.GetImagePointer1(ho_Image, out hv_ExpDefaultCtrlDummyVar, out hv_ExpDefaultCtrlDummyVar,
                                          out hv_Width, out hv_Height);
            hv_EstimatedCaltabSize = (((((hv_Width.TupleConcat(hv_Height))).TupleMax()) / 2.5)).TupleRound()
            ;
            hv_EstimatedMarkSize = ((hv_EstimatedCaltabSize / 12.0)).TupleRound();
            ho_ImageMean.Dispose();
            HOperatorSet.MeanImage(ho_Image, out ho_ImageMean, hv_EstimatedMarkSize * 3, hv_EstimatedMarkSize * 3);
            ho_RegionDynThresh.Dispose();
            HOperatorSet.DynThreshold(ho_Image, ho_ImageMean, out ho_RegionDynThresh, 3,
                                      "light");
            ho_RegionBorder.Dispose();
            HOperatorSet.DynThreshold(ho_Image, ho_ImageMean, out ho_RegionBorder, 20, "dark");
            ho_RegionOpening1.Dispose();
            HOperatorSet.OpeningCircle(ho_RegionBorder, out ho_RegionOpening1, 1.5);
            ho_ConnectedRegions1.Dispose();
            HOperatorSet.Connection(ho_RegionOpening1, out ho_ConnectedRegions1);
            ho_SelectedRegions4.Dispose();
            HOperatorSet.SelectShape(ho_ConnectedRegions1, out ho_SelectedRegions4, "compactness",
                                     "and", 17, 50);
            ho_SelectedRegions5.Dispose();
            HOperatorSet.SelectShape(ho_SelectedRegions4, out ho_SelectedRegions5, "anisometry",
                                     "and", 1, 1.4);
            ho_RegionBorder2.Dispose();
            HOperatorSet.Boundary(ho_SelectedRegions5, out ho_RegionBorder2, "outer");
            ho_SelectedRegions5.Dispose();
            HOperatorSet.SelectShape(ho_RegionBorder2, out ho_SelectedRegions5, "circularity",
                                     "and", 0.006, 1);
            ho_RegionTrans.Dispose();
            HOperatorSet.ShapeTrans(ho_SelectedRegions5, out ho_RegionTrans, "rectangle2");
            ho_RegionErosion.Dispose();
            HOperatorSet.ErosionCircle(ho_RegionTrans, out ho_RegionErosion, (hv_Width / 640.0) * 5.5);
            ho_RegionBorder1.Dispose();
            HOperatorSet.Boundary(ho_RegionErosion, out ho_RegionBorder1, "inner");
            ho_RegionDilation2.Dispose();
            HOperatorSet.DilationCircle(ho_RegionBorder1, out ho_RegionDilation2, 3.5);
            ho_RegionDifference1.Dispose();
            HOperatorSet.Difference(ho_RegionDynThresh, ho_RegionDilation2, out ho_RegionDifference1
                                    );
            ho_RegionOpening.Dispose();
            HOperatorSet.OpeningCircle(ho_RegionDifference1, out ho_RegionOpening, (hv_Width / 640) * 1.5);
            ho_ConnectedRegions.Dispose();
            HOperatorSet.Connection(ho_RegionOpening, out ho_ConnectedRegions);
            ho_SelectedRegions2.Dispose();
            HOperatorSet.SelectShape(ho_ConnectedRegions, out ho_SelectedRegions2, "area",
                                     "and", (hv_EstimatedCaltabSize.TuplePow(2)) / 10, (hv_EstimatedCaltabSize.TuplePow(
                                                                                            2)) * 5);
            ho_SelectedRegions.Dispose();
            HOperatorSet.SelectShape(ho_SelectedRegions2, out ho_SelectedRegions, "compactness",
                                     "and", 1.4, 10);
            ho_RegionFillUp.Dispose();
            HOperatorSet.FillUp(ho_SelectedRegions, out ho_RegionFillUp);
            ho_SelectedRegions1.Dispose();
            HOperatorSet.SelectShape(ho_RegionFillUp, out ho_SelectedRegions1, "rectangularity",
                                     "and", 0.6, 1);
            ho_RegionIntersection.Dispose();
            HOperatorSet.Intersection(ho_SelectedRegions1, ho_RegionDynThresh, out ho_RegionIntersection
                                      );
            ho_RegionFillUp1.Dispose();
            HOperatorSet.FillUp(ho_RegionIntersection, out ho_RegionFillUp1);
            ho_RegionDifference.Dispose();
            HOperatorSet.Difference(ho_RegionFillUp1, ho_RegionIntersection, out ho_RegionDifference
                                    );
            HOperatorSet.CountObj(ho_RegionDifference, out hv_Number);
            ho_CaltabCandidates.Dispose();
            HOperatorSet.GenEmptyObj(out ho_CaltabCandidates);
            HOperatorSet.CaltabPoints(hv_DescriptionFileName, out hv_X, out hv_Y, out hv_Z);
            hv_NumDescrMarks = new HTuple(hv_X.TupleLength());
            for (hv_Index = 1; hv_Index.Continue(hv_Number, 1); hv_Index = hv_Index.TupleAdd(1))
            {
                ho_ObjectSelected.Dispose();
                HOperatorSet.SelectObj(ho_RegionDifference, out ho_ObjectSelected, hv_Index);
                ho_ConnectedMarks.Dispose();
                HOperatorSet.Connection(ho_ObjectSelected, out ho_ConnectedMarks);
                HOperatorSet.CountObj(ho_ConnectedMarks, out hv_NumberMarks);
                HOperatorSet.Eccentricity(ho_ConnectedMarks, out hv_Anisometry, out hv_Bulkiness,
                                          out hv_StructureFactor);
                HOperatorSet.AreaCenter(ho_ConnectedMarks, out hv_AreaMarks, out hv_Row, out hv_Column);
                ho_ObjectSelectedCaltab.Dispose();
                HOperatorSet.SelectObj(ho_RegionIntersection, out ho_ObjectSelectedCaltab,
                                       hv_Index);
                if ((int)((new HTuple((new HTuple((new HTuple(hv_NumberMarks.TupleGreaterEqual(
                                                                  10))).TupleAnd(new HTuple(hv_NumberMarks.TupleLess(hv_NumDescrMarks + 20))))).TupleAnd(
                                          new HTuple(((((hv_Anisometry.TupleSort())).TupleSelect((new HTuple(hv_Anisometry.TupleLength()
                                                                                                             )) / 2))).TupleLess(2))))).TupleAnd(new HTuple((new HTuple(hv_AreaMarks.TupleMean()
                                                                                                                                                                        )).TupleGreater(20)))) != 0)
                {
                    OTemp[SP_O] = ho_CaltabCandidates.CopyObj(1, -1);
                    SP_O++;
                    ho_CaltabCandidates.Dispose();
                    HOperatorSet.ConcatObj(OTemp[SP_O - 1], ho_ObjectSelectedCaltab, out ho_CaltabCandidates
                                           );
                    OTemp[SP_O - 1].Dispose();
                    SP_O = 0;
                }
            }
            ho_RegionFillUpCand.Dispose();
            HOperatorSet.FillUp(ho_CaltabCandidates, out ho_RegionFillUpCand);
            HOperatorSet.Rectangularity(ho_RegionFillUpCand, out hv_Rectangularity);
            if ((int)(new HTuple((new HTuple(hv_Rectangularity.TupleLength())).TupleEqual(
                                     0))) != 0)
            {
                ho_ImageMean.Dispose();
                ho_RegionDynThresh.Dispose();
                ho_RegionBorder.Dispose();
                ho_RegionOpening1.Dispose();
                ho_ConnectedRegions1.Dispose();
                ho_SelectedRegions4.Dispose();
                ho_SelectedRegions5.Dispose();
                ho_RegionBorder2.Dispose();
                ho_RegionTrans.Dispose();
                ho_RegionErosion.Dispose();
                ho_RegionBorder1.Dispose();
                ho_RegionDilation2.Dispose();
                ho_RegionDifference1.Dispose();
                ho_RegionOpening.Dispose();
                ho_ConnectedRegions.Dispose();
                ho_SelectedRegions2.Dispose();
                ho_SelectedRegions.Dispose();
                ho_RegionFillUp.Dispose();
                ho_SelectedRegions1.Dispose();
                ho_RegionIntersection.Dispose();
                ho_RegionFillUp1.Dispose();
                ho_RegionDifference.Dispose();
                ho_CaltabCandidates.Dispose();
                ho_ObjectSelected.Dispose();
                ho_ConnectedMarks.Dispose();
                ho_ObjectSelectedCaltab.Dispose();
                ho_RegionFillUpCand.Dispose();
                ho_MarksCand.Dispose();
                ho_RegionDilation1.Dispose();
                ho_ImageReduced.Dispose();
                ho_DefaultEdges.Dispose();
                ho_UnionContours.Dispose();
                ho_SelectedXLD.Dispose();
                ho_SelectedXLD1.Dispose();

                return;
            }
            hv_SortedIndex = hv_Rectangularity.TupleSortIndex();
            hv_IndexBest   = (((hv_SortedIndex.TupleInverse())).TupleSelect(0)) + 1;
            ho_Caltab.Dispose();
            HOperatorSet.SelectObj(ho_RegionFillUpCand, out ho_Caltab, hv_IndexBest);
            ho_RegionFillUp.Dispose();
            HOperatorSet.FillUp(ho_Caltab, out ho_RegionFillUp);
            ho_MarksCand.Dispose();
            HOperatorSet.Difference(ho_RegionFillUp, ho_RegionDynThresh, out ho_MarksCand
                                    );
            ho_RegionBorder.Dispose();
            HOperatorSet.Boundary(ho_MarksCand, out ho_RegionBorder, "inner");
            ho_RegionDilation1.Dispose();
            HOperatorSet.DilationCircle(ho_RegionBorder, out ho_RegionDilation1, 9.5);
            ho_ImageReduced.Dispose();
            HOperatorSet.ReduceDomain(ho_Image, ho_RegionDilation1, out ho_ImageReduced);
            hv_MinContrast = 10;
            ho_DefaultEdges.Dispose();
            HOperatorSet.EdgesSubPix(ho_ImageReduced, out ho_DefaultEdges, "canny", 2, hv_MinContrast / 2,
                                     hv_MinContrast);
            HOperatorSet.CountObj(ho_DefaultEdges, out hv_NumberCand);
            if ((int)(new HTuple(hv_NumberCand.TupleLess(10))) != 0)
            {
                ho_ImageMean.Dispose();
                ho_RegionDynThresh.Dispose();
                ho_RegionBorder.Dispose();
                ho_RegionOpening1.Dispose();
                ho_ConnectedRegions1.Dispose();
                ho_SelectedRegions4.Dispose();
                ho_SelectedRegions5.Dispose();
                ho_RegionBorder2.Dispose();
                ho_RegionTrans.Dispose();
                ho_RegionErosion.Dispose();
                ho_RegionBorder1.Dispose();
                ho_RegionDilation2.Dispose();
                ho_RegionDifference1.Dispose();
                ho_RegionOpening.Dispose();
                ho_ConnectedRegions.Dispose();
                ho_SelectedRegions2.Dispose();
                ho_SelectedRegions.Dispose();
                ho_RegionFillUp.Dispose();
                ho_SelectedRegions1.Dispose();
                ho_RegionIntersection.Dispose();
                ho_RegionFillUp1.Dispose();
                ho_RegionDifference.Dispose();
                ho_CaltabCandidates.Dispose();
                ho_ObjectSelected.Dispose();
                ho_ConnectedMarks.Dispose();
                ho_ObjectSelectedCaltab.Dispose();
                ho_RegionFillUpCand.Dispose();
                ho_MarksCand.Dispose();
                ho_RegionDilation1.Dispose();
                ho_ImageReduced.Dispose();
                ho_DefaultEdges.Dispose();
                ho_UnionContours.Dispose();
                ho_SelectedXLD.Dispose();
                ho_SelectedXLD1.Dispose();

                return;
            }
            ho_UnionContours.Dispose();
            HOperatorSet.UnionCocircularContoursXld(ho_DefaultEdges, out ho_UnionContours,
                                                    0.5, 0.1, 0.2, 30, 10, 10, "true", 1);
            ho_SelectedXLD.Dispose();
            HOperatorSet.SelectShapeXld(ho_UnionContours, out ho_SelectedXLD, "area", "and",
                                        30, 10000);
            ho_SelectedXLD1.Dispose();
            HOperatorSet.SelectShapeXld(ho_SelectedXLD, out ho_SelectedXLD1, "circularity",
                                        "and", 0.4, 1);
            ho_MarksCand.Dispose();
            HOperatorSet.SelectShapeXld(ho_SelectedXLD1, out ho_MarksCand, "compactness",
                                        "and", 1, 1.5);
            HOperatorSet.AreaCenterXld(ho_MarksCand, out hv_Area, out hv_Dummy, out hv_Dummy,
                                       out hv_DummyS);
            HOperatorSet.CountObj(ho_MarksCand, out hv_Number);
            if ((int)(new HTuple(hv_Number.TupleLess(4))) != 0)
            {
                ho_ImageMean.Dispose();
                ho_RegionDynThresh.Dispose();
                ho_RegionBorder.Dispose();
                ho_RegionOpening1.Dispose();
                ho_ConnectedRegions1.Dispose();
                ho_SelectedRegions4.Dispose();
                ho_SelectedRegions5.Dispose();
                ho_RegionBorder2.Dispose();
                ho_RegionTrans.Dispose();
                ho_RegionErosion.Dispose();
                ho_RegionBorder1.Dispose();
                ho_RegionDilation2.Dispose();
                ho_RegionDifference1.Dispose();
                ho_RegionOpening.Dispose();
                ho_ConnectedRegions.Dispose();
                ho_SelectedRegions2.Dispose();
                ho_SelectedRegions.Dispose();
                ho_RegionFillUp.Dispose();
                ho_SelectedRegions1.Dispose();
                ho_RegionIntersection.Dispose();
                ho_RegionFillUp1.Dispose();
                ho_RegionDifference.Dispose();
                ho_CaltabCandidates.Dispose();
                ho_ObjectSelected.Dispose();
                ho_ConnectedMarks.Dispose();
                ho_ObjectSelectedCaltab.Dispose();
                ho_RegionFillUpCand.Dispose();
                ho_MarksCand.Dispose();
                ho_RegionDilation1.Dispose();
                ho_ImageReduced.Dispose();
                ho_DefaultEdges.Dispose();
                ho_UnionContours.Dispose();
                ho_SelectedXLD.Dispose();
                ho_SelectedXLD1.Dispose();

                return;
            }
            hv_AreaMedian = ((hv_Area.TupleSort())).TupleSelect(hv_Number / 2);
            ho_Marks.Dispose();
            HOperatorSet.SelectShapeXld(ho_MarksCand, out ho_Marks, "area", "and", hv_AreaMedian - (hv_AreaMedian * 0.5),
                                        hv_AreaMedian + (hv_AreaMedian * 0.5));
            ho_ImageMean.Dispose();
            ho_RegionDynThresh.Dispose();
            ho_RegionBorder.Dispose();
            ho_RegionOpening1.Dispose();
            ho_ConnectedRegions1.Dispose();
            ho_SelectedRegions4.Dispose();
            ho_SelectedRegions5.Dispose();
            ho_RegionBorder2.Dispose();
            ho_RegionTrans.Dispose();
            ho_RegionErosion.Dispose();
            ho_RegionBorder1.Dispose();
            ho_RegionDilation2.Dispose();
            ho_RegionDifference1.Dispose();
            ho_RegionOpening.Dispose();
            ho_ConnectedRegions.Dispose();
            ho_SelectedRegions2.Dispose();
            ho_SelectedRegions.Dispose();
            ho_RegionFillUp.Dispose();
            ho_SelectedRegions1.Dispose();
            ho_RegionIntersection.Dispose();
            ho_RegionFillUp1.Dispose();
            ho_RegionDifference.Dispose();
            ho_CaltabCandidates.Dispose();
            ho_ObjectSelected.Dispose();
            ho_ConnectedMarks.Dispose();
            ho_ObjectSelectedCaltab.Dispose();
            ho_RegionFillUpCand.Dispose();
            ho_MarksCand.Dispose();
            ho_RegionDilation1.Dispose();
            ho_ImageReduced.Dispose();
            ho_DefaultEdges.Dispose();
            ho_UnionContours.Dispose();
            ho_SelectedXLD.Dispose();
            ho_SelectedXLD1.Dispose();

            return;
        }