示例#1
0
        public bool CreateShapeModelAct(HImage modelImage)
        {
            if (modelImage == null || !modelImage.IsInitialized())
            {
                return(false);
            }
            this.modelImage = modelImage;

            if (modelRegion == null || !modelRegion.IsInitialized())
            {
                return(false);
            }
            try
            {
                HImage ROIImage = new HImage();
                ROIImage.GenEmptyObj();
                ROIImage = modelImage.ReduceDomain(modelRegion);
                HImage temp = ROIImage.GaussFilter(7);
                ROIImage.Dispose();
                ROIImage    = temp;
                hShapeModel = ROIImage.CreateScaledShapeModel(
                    new HTuple(numLevels),
                    angleStart, angleExtent, new HTuple(angleStep),
                    scaleMin, scaleMax, new HTuple(scaleStep),
                    new HTuple(optimization).TupleConcat("no_pregeneration"),
                    metric,
                    ((new HTuple(contrastLow)).TupleConcat(contrastHigh)).TupleConcat(minLength),
                    new HTuple(minContrast));



                ROIImage.Dispose();
                double row, col;
                modelRegion.AreaCenter(out row, out col);
                refCoordinates   = new HTuple(row, col, 0);
                createNewModelID = false;
                //初始化modelContours
                if (modelXLDCont == null)
                {
                    modelXLDCont = new HXLDCont();
                }
                if (modelXLDCont != null && modelXLDCont.IsInitialized())
                {
                    modelXLDCont.Dispose();
                }
                modelXLDCont = hShapeModel.GetShapeModelContours(1);
            }
            catch
            {
                hShapeModel      = null;
                createNewModelID = true;
                return(false);
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Creates the shape-based model. If the region of interest
        /// <c>mROIModel</c> is missing or not well defined using the
        /// interactive ROIs, then an error message is returned.
        /// </summary>
        public bool createShapeModel()
        {
            if (mImage == null)
            {
                if (!onTimer)
                {
                    NotifyIconObserver(MatchingAssistant.ERR_NO_MODEL_DEFINED);
                }
                return(false);
            }

            try
            {
                ModelID = mImage.CreateScaledShapeModel(parameterSet.mNumLevel,
                                                        parameterSet.mStartingAngle,
                                                        parameterSet.mAngleExtent,
                                                        parameterSet.mAngleStep,
                                                        parameterSet.mMinScale,
                                                        parameterSet.mMaxScale,
                                                        parameterSet.mScaleStep,
                                                        parameterSet.mOptimization,
                                                        parameterSet.mMetric,
                                                        parameterSet.mContrast,
                                                        parameterSet.mMinContrast);
            }
            catch (HOperatorException e)
            {
                if (!onTimer)
                {
                    exceptionText = e.Message;
                    NotifyParamObserver(MatchingParam.H_ERR_MESSAGE);
                }
                return(false);
            }

            tResult.mContour = ModelID.GetShapeModelContours(1);

            createNewModelID = false;
            return(true);
        }