예제 #1
0
        public void ShowParametersWindow()
        {
            var algChooserWindow = new ParametrizedProcessorsSelectionWindow();
            algChooserWindow.AddProcessorFamily("Radial Distortion Model");
            algChooserWindow.AddToFamily("Radial Distortion Model", new Rational3RDModel());
            algChooserWindow.AddToFamily("Radial Distortion Model", new Taylor4Model());

            algChooserWindow.ShowDialog();
            if(algChooserWindow.Accepted)
            {
                DistortionModel = algChooserWindow.GetSelectedProcessor("Radial Distortion Model") as RadialDistortionModel;
                _minimalisation.DistortionModel = DistortionModel;
                _modelParams = DistortionModel.Parameters.Clone();
                ParamtersAccepted?.Invoke(this, new EventArgs());
            }
        }
예제 #2
0
        private void _butSegment_Click(object sender, RoutedEventArgs e)
        {
            if(_imageControl.ImageSource != null)
            {
                ColorImage img = new ColorImage();
                img.FromBitmapSource(_imageControl.ImageSource);

                var window = new ParametrizedProcessorsSelectionWindow();
                window.AddProcessorFamily("Segmentation");
                window.AddToFamily("Segmentation", new MeanShiftSegmentation());

                window.ShowDialog();
                if(window.Accepted)
                {
                    ImageSegmentation segmentation = (ImageSegmentation)window.GetSelectedProcessor("Segmentation");

                    GrayScaleImage imgGray = new GrayScaleImage();
                    imgGray.FromColorImage(img);

                    //segmentation.SegmentColor(img);
                    segmentation.SegmentGray(imgGray.ImageMatrix);

                    //var segments = segmentation.Segments_Color;
                    var segments = segmentation.Segments;
                    int[,] indices = segmentation.SegmentAssignments;

                    ColorImage imgFinal = new ColorImage();
                    imgFinal.ImageMatrix[0] = new DenseMatrix(img.RowCount, img.ColumnCount);
                    imgFinal.ImageMatrix[1] = new DenseMatrix(img.RowCount, img.ColumnCount);
                    imgFinal.ImageMatrix[2] = new DenseMatrix(img.RowCount, img.ColumnCount);

                    for(int r = 0; r < img.RowCount; ++r)
                    {
                        for(int c = 0; c < img.ColumnCount; ++c)
                        {
                            imgFinal[r, c, RGBChannel.Red] = ((ImageSegmentation.Segment_Gray)segments[indices[r, c]]).Value;
                            imgFinal[r, c, RGBChannel.Green] = ((ImageSegmentation.Segment_Gray)segments[indices[r, c]]).Value;
                            imgFinal[r, c, RGBChannel.Blue] = ((ImageSegmentation.Segment_Gray)segments[indices[r, c]]).Value;
                            //imgFinal[r, c, RGBChannel.Red] = segments[indices[r, c]].Red;
                            // imgFinal[r, c, RGBChannel.Green] = segments[indices[r, c]].Green;
                            //imgFinal[r, c, RGBChannel.Blue] = segments[indices[r, c]].Blue;
                        }
                    }

                    _imageControl.ImageSource = imgFinal.ToBitmapSource();
                }
            }
        }