private void projection(Bitmap img, Graphics horizontal, Graphics vertical)
        {
            ProjectionFactory factory = new ProjectionFactory(img);

            factory.Threshold = (int)numericUpDown1.Value;

            drawHorizontal(horizontal, factory.getHorizontalProject());
            drawVertical(vertical, factory.getVerticalProject());
        }
示例#2
0
        private void calcRegionRange()
        {
            ProjectionFactory factory = new ProjectionFactory(_srcImg, _edgeValue - 1);

            int[] v = factory.getVerticalProject();
            for (int i = 0; i < v.Length; i++)
            {
                if (v[i] > 0)
                {
                    _regionfillStartWithVertical = i;
                    break;
                }
            }

            for (int i = v.Length - 1; i >= 0; i--)
            {
                if (v[i] > 0)
                {
                    _regionfillEndWithVertical = i + 1;
                    break;
                }
            }

            int[] h = factory.getHorizontalProject();
            for (int i = 0; i < v.Length; i++)
            {
                if (h[i] > 0)
                {
                    _regionfillStartWithHorizontal = i;
                    break;
                }
            }

            for (int i = h.Length - 1; i >= 0; i--)
            {
                if (h[i] > 0)
                {
                    _regionfillEndWithHorizontal = i + 1;
                    break;
                }
            }
        }
        private void projectionTest(Chart VerticalChart, Chart HorizontalChart, Bitmap img)
        {
            HorizontalChart.Series["Series1"].IsVisibleInLegend   = false;
            HorizontalChart.Series["Series1"].IsValueShownAsLabel = false;
            VerticalChart.Series["Series1"].IsVisibleInLegend     = false;
            VerticalChart.Series["Series1"].IsValueShownAsLabel   = false;


            ProjectionFactory factory = new ProjectionFactory(img);

            factory.Threshold = (int)numericUpDown1.Value;
            int[] horizontalProjection = factory.getHorizontalProject();
            int[] verticalProjection   = factory.getVerticalProject();
            for (int i = 0; i < horizontalProjection.Length; i++)
            {
                HorizontalChart.Series["Series1"].Points.AddXY(i, horizontalProjection[i]);
            }
            for (int i = 0; i < verticalProjection.Length; i++)
            {
                VerticalChart.Series["Series1"].Points.AddXY(i, verticalProjection[i]);
            }
        }