예제 #1
0
        private void Part3Button_Click(object sender, RoutedEventArgs e)
        {
            if (!_part3Complete)
            {
                _rawLayers         = Layering.Convert(_colorGroups, _loadedImage.Width, _loadedImage.Height, ImageTracer.Palette);
                _part3Complete     = true;
                _filteredRawLayers =
                    _rawLayers.Where(cl => cl.Value.Nodes.Any(r => r.Any(n => n.IsLight())))
                    .ToDictionary(cl => cl.Key, cl => cl.Value);

                //http://www.wpf-tutorial.com/list-controls/combobox-control/
                //http://stackoverflow.com/questions/7719164/databinding-a-color-in-wpf-datatemplate
                Part3ComboBox.ItemsSource = _filteredRawLayers.Keys.Select((k, i) => new ColorSelectionItem(k, i)).ToList();
                Part3Button.IsEnabled     = false;
                LayerCount.Content        = _filteredRawLayers.Count;
            }
        }
예제 #2
0
        ////////////////////////////////////////////////////////////

        // Tracing ImageData, then returning PaddedPaletteImage with tracedata in layers
        private static TracedImage PaddedPaletteImageToTraceData(Bitmap image, Tracing tracing, SvgRendering rendering)
        {
            // Selective Gaussian blur preprocessing
            //if (options.Blur.BlurRadius > 0)
            //{
            //    // TODO: This seems to not work currently.
            //    imgd = Blur(imgd, options.Blur.BlurRadius, options.Blur.BlurDelta);
            //}

            // 1. Color quantization
            var colors      = image.ChangeFormat(PixelFormat.Format32bppArgb).ToColorReferences();
            var colorGroups = ColorGrouping.Convert(colors, image.Width, image.Height, Palette);
            // 2. Layer separation and edge detection
            var rawLayers = Layering.Convert(colorGroups, image.Width, image.Height, Palette);
            // 3. Batch pathscan
            var pathPointLayers = rawLayers.ToDictionary(cl => cl.Key, cl => new Layer <PathPointPath>
            {
                Paths = Pathing.Scan(cl.Value, tracing.PathOmit).ToList()
            });
            // 4. Batch interpollation
            var interpolationPointLayers = pathPointLayers.ToDictionary(cp => cp.Key, cp => Interpolation.Convert(cp.Value));
            // 5. Batch tracing
            var sequenceLayers = interpolationPointLayers.ToDictionary(ci => ci.Key, ci => new Layer <SequencePath>
            {
                Paths = ci.Value.Paths.Select(path => new SequencePath
                {
                    Path      = path,
                    Sequences = Sequencing.Create(path.Points.Select(p => p.Direction).ToList()).ToList()
                }).ToList()
            });

            var segmentLayers = sequenceLayers.ToDictionary(ci => ci.Key, ci => new Layer <SegmentPath>
            {
                Paths = ci.Value.Paths.Select(path => new SegmentPath
                {
                    Segments = path.Sequences.Select(s => Segmentation.Fit(path.Path.Points, s, tracing, rendering)).SelectMany(s => s).ToList()
                }).ToList()
            });

            return(new TracedImage(segmentLayers, image.Width, image.Height));
        }