Beispiel #1
0
        public void DeterminModel()
        {
            if (ModelImg == null || !ModelImg.IsInitialized())
            {
                return;
            }
            if (ModelRegion == null || !ModelRegion.IsInitialized())
            {
                return;
            }

            double vald;
            int    vali, count;
            HTuple paramValue = new HTuple();
            HTuple paramList  = new HTuple();

            try
            {
                HImage img = ModelImg.ReduceDomain(ModelRegion);
                HTuple num = "auto";
                if (!shapeParam.IsAuto(ShapeParam.AUTO_NUM_LEVEL))
                {
                    num = shapeParam.mNumLevel;
                }

                paramList = img.DetermineShapeModelParams(num,
                                                          (double)shapeParam.mStartingAngle,
                                                          (double)shapeParam.mAngleExtent,
                                                          shapeParam.mMinScale,
                                                          shapeParam.mMaxScale,
                                                          shapeParam.mOptimization,
                                                          shapeParam.mMetric,
                                                          (int)shapeParam.mContrast,
                                                          (int)shapeParam.mMinContrast,
                                                          shapeParam.GetAutoParList(),
                                                          out paramValue);
                img.Dispose();
            }
            catch (HOperatorException e)
            {
                return;
            }

            count = paramList.Length;

            for (int i = 0; i < count; i++)
            {
                switch ((string)paramList[i])
                {
                case ShapeParam.AUTO_ANGLE_STEP:
                    vald = (double)paramValue[i];

                    if (vald > angleStepUpB)
                    {
                        vald = angleStepUpB;
                    }
                    else if (vald < angleStepLowB)
                    {
                        vald = angleStepLowB;
                    }

                    shapeParam.mAngleStep = vald;
                    break;

                case ShapeParam.AUTO_CONTRAST:
                    vali = (int)paramValue[i];

                    if (vali > contrastUpB)
                    {
                        vali = contrastUpB;
                    }
                    else if (vali < contrastLowB)
                    {
                        vali = contrastLowB;
                    }

                    minContrastUpB       = vali;
                    shapeParam.mContrast = vali;

                    //inspectShapeModel();
                    break;

                case ShapeParam.AUTO_MIN_CONTRAST:
                    vali = (int)paramValue[i];

                    if (vali > minContrastUpB)
                    {
                        vali = minContrastUpB;
                    }
                    else if (vali < minContrastLowB)
                    {
                        vali = minContrastLowB;
                    }

                    shapeParam.mMinContrast = vali;
                    break;

                case ShapeParam.AUTO_NUM_LEVEL:
                    vali = (int)paramValue[i];

                    if (vali > pyramLevUpB)
                    {
                        vali = pyramLevUpB;
                    }
                    else if (vali < pyramLevLowB)
                    {
                        vali = pyramLevLowB;
                    }

                    shapeParam.mNumLevel = vali;
                    break;

                case ShapeParam.AUTO_OPTIMIZATION:
                    shapeParam.mOptimization = (string)paramValue[i];
                    break;

                case ShapeParam.AUTO_SCALE_STEP:
                    vald = (double)paramValue[i];

                    if (vald > scaleStepUpB)
                    {
                        vald = scaleStepUpB;
                    }
                    else if (vald < scaleStepLowB)
                    {
                        vald = scaleStepLowB;
                    }

                    shapeParam.mScaleStep = vald;
                    break;

                default:
                    break;
                }
            }


            if (count != 0)
            {
                createNewModelID = true;
            }
        }
        /// <summary>
        /// Adjusts the range of ScaleStep and AngleStep according to the
        /// current set of matching parameters.
        /// </summary>
        public void determineStepRanges()
        {
            double vald       = 0.0;
            HTuple paramValue = new HTuple();
            HTuple paramList  = new HTuple();

            string [] paramRange = { "scale_step", "angle_step" };

            if (mImage == null)
            {
                NotifyIconObserver(MatchingAssistant.ERR_NO_MODEL_DEFINED);
                return;
            }

            try
            {
                paramList = mImage.DetermineShapeModelParams(parameterSet.mNumLevel,
                                                             (double)parameterSet.mStartingAngle,
                                                             (double)parameterSet.mAngleExtent,
                                                             parameterSet.mMinScale,
                                                             parameterSet.mMaxScale,
                                                             parameterSet.mOptimization,
                                                             parameterSet.mMetric,
                                                             (int)parameterSet.mContrast,
                                                             (int)parameterSet.mMinContrast,
                                                             paramRange,
                                                             out paramValue);
            }
            catch (HOperatorException e)
            {
                exceptionText = e.Message;
                NotifyParamObserver(MatchingParam.H_ERR_MESSAGE);
                return;
            }

            for (int i = 0; i < paramList.Length; i++)
            {
                switch ((string)paramList[i])
                {
                case MatchingParam.AUTO_ANGLE_STEP:
                    vald = (double)paramValue[i];

                    angleStepUpB            = vald * 3.0;
                    angleStepLowB           = vald / 3.0;
                    parameterSet.mAngleStep = vald;
                    NotifyParamObserver(MatchingParam.RANGE_ANGLE_STEP);
                    break;

                case MatchingParam.AUTO_SCALE_STEP:
                    vald = (double)paramValue[i];

                    scaleStepUpB            = vald * 3.0;
                    scaleStepLowB           = vald / 3.0;
                    parameterSet.mScaleStep = vald;
                    NotifyParamObserver(MatchingParam.RANGE_SCALE_STEP);
                    break;

                default:
                    break;
                }        //end of switch
            }            //end of for
        }
Beispiel #3
0
        public void DetermineStepRanges()
        {
            if (ModelImg == null || !ModelImg.IsInitialized())
            {
                return;
            }
            if (ModelRegion == null || !ModelRegion.IsInitialized())
            {
                return;
            }

            double vald       = 0.0;
            HTuple paramValue = new HTuple();
            HTuple paramList  = new HTuple();

            string[] paramRange = { "scale_step", "angle_step" };

            try
            {
                HImage img = ModelImg.ReduceDomain(ModelRegion);
                paramList = img.DetermineShapeModelParams(shapeParam.mNumLevel,
                                                          (double)shapeParam.mStartingAngle,
                                                          (double)shapeParam.mAngleExtent,
                                                          shapeParam.mMinScale,
                                                          shapeParam.mMaxScale,
                                                          shapeParam.mOptimization,
                                                          shapeParam.mMetric,
                                                          (int)shapeParam.mContrast,
                                                          (int)shapeParam.mMinContrast,
                                                          paramRange,
                                                          out paramValue);
                img.Dispose();
            }
            catch (HOperatorException e)
            {
                return;
            }

            for (int i = 0; i < paramList.Length; i++)
            {
                switch ((string)paramList[i])
                {
                case ShapeParam.AUTO_ANGLE_STEP:
                    vald = (double)paramValue[i];

                    angleStepUpB  = vald * 3.0;
                    angleStepLowB = vald / 3.0;
                    if (shapeParam.IsAuto(ShapeParam.AUTO_ANGLE_STEP))
                    {
                        shapeParam.mAngleStep = vald;
                    }

                    break;

                case ShapeParam.AUTO_SCALE_STEP:
                    vald = (double)paramValue[i];

                    scaleStepUpB  = vald * 3.0;
                    scaleStepLowB = vald / 3.0;
                    if (shapeParam.IsAuto(ShapeParam.AUTO_SCALE_STEP))
                    {
                        shapeParam.mScaleStep = vald;
                    }

                    break;

                default:
                    break;
                }
            }
        }