コード例 #1
0
        /**************************************************************************/
        /**************************************************************************/
        private void performIPTask()
        {
            string    color, drawMode, lineWidth;
            Hashtable lastState;
            HImage    mean, particlesRed;
            HRegion   large, largeDilation, notLarge, smallRaw, small, smallConnection;

            color = drawMode = lineWidth = "";
            IconiclistBox.Items.Clear();
            IconicDisplayStack.Items.Clear();

            lastState = viewControl.getGraphicContext();

            if (lastState.ContainsKey(GraphicsContext.GC_COLOR))
            {
                color = (string)lastState[GraphicsContext.GC_COLOR];
            }
            else if (lastState.ContainsKey(GraphicsContext.GC_COLORED))
            {
                color = "colored" + (int)lastState[GraphicsContext.GC_COLORED];
            }

            if (lastState.ContainsKey(GraphicsContext.GC_DRAWMODE))
            {
                drawMode = (string)lastState[GraphicsContext.GC_DRAWMODE];
            }

            if (lastState.ContainsKey(GraphicsContext.GC_LINEWIDTH))
            {
                lineWidth = "" + (int)lastState[GraphicsContext.GC_LINEWIDTH];
            }

            /* ip task */
            large           = image.Threshold(110.0, 255.0);
            largeDilation   = large.DilationCircle(7.5d);
            notLarge        = largeDilation.Complement();
            particlesRed    = image.ReduceDomain(notLarge);
            mean            = particlesRed.MeanImage(31, 31);
            smallRaw        = particlesRed.DynThreshold(mean, 3.0, "light");
            small           = smallRaw.OpeningCircle(2.5);
            smallConnection = small.Connection();

            /* add for display*/
            addToStack("Image", image, true, color, lineWidth, drawMode);

            viewControl.changeGraphicSettings(GraphicsContext.GC_COLOR, "green");
            color = "green";
            addToStack("Large", large, true, color, lineWidth, drawMode);

            viewControl.changeGraphicSettings(GraphicsContext.GC_LINEWIDTH, 3);
            viewControl.changeGraphicSettings(GraphicsContext.GC_DRAWMODE, "margin");
            viewControl.changeGraphicSettings(GraphicsContext.GC_COLOR, "yellow");
            color     = "yellow";
            lineWidth = "3";
            drawMode  = "margin";
            addToStack("LargeDilation", largeDilation, true, color, lineWidth, drawMode);

            viewControl.changeGraphicSettings(GraphicsContext.GC_COLOR, "red");
            color = "red";
            addToStack("Small", small, true, color, lineWidth, drawMode);

            viewControl.changeGraphicSettings(GraphicsContext.GC_DRAWMODE, "fill");
            viewControl.changeGraphicSettings(GraphicsContext.GC_COLORED, 12);
            color    = "colored12";
            drawMode = "fill";
            addToStack("SmallConnection", smallConnection, true, color, lineWidth, drawMode);

            /* display last settings in combobox*/
            locked = true;
            LineWidthComboBox.SelectedIndex = LineWidthComboBox.Items.IndexOf("3");
            DrawModeComboBox.SelectedIndex  = DrawModeComboBox.Items.IndexOf("fill");
            ColorComboBox.SelectedIndex     = ColorComboBox.Items.IndexOf("colored12");
            locked = false;
        }