Exemplo n.º 1
0
        public void GlobalTest10()
        {
            MainViewModel     mvm = MainViewModelTest.GetInstance();
            PipelineViewModel pvm = mvm.PipelineViewModel;

            // Step 1: The user clicks "New" to create a new pipeline
            mvm.Clear();
            Assert.Empty(mvm.Model.Graph.Nodes);
            var mock = new Mock <IDragEventInfo>();

            // Step 2: Create each type of node once by drag-and-drop
            VideoInputNode    vin = (VideoInputNode)AddNode <VideoInputNode>(pvm, mock, new Point(10, 30));
            AdditiveMergeNode amn = (AdditiveMergeNode)AddNode <AdditiveMergeNode>(pvm, mock, new Point(30, 30));
            BlurNode          bn  = (BlurNode)AddNode <BlurNode>(pvm, mock, new Point(50, 30));
            BrightnessContrastSaturationNode bcsn =
                (BrightnessContrastSaturationNode)AddNode <BrightnessContrastSaturationNode>(pvm, mock, new Point(70, 30));
            ColorInputNode            cin   = (ColorInputNode)AddNode <ColorInputNode>(pvm, mock, new Point(10, 50));
            DelayNode                 dln   = (DelayNode)AddNode <DelayNode>(pvm, mock, new Point(90, 30));
            DiagramNode               dgn   = (DiagramNode)AddNode <DiagramNode>(pvm, mock, new Point(110, 30));
            DifferenceNode            dfn   = (DifferenceNode)AddNode <DifferenceNode>(pvm, mock, new Point(30, 50));
            HistogramNode             hn    = (HistogramNode)AddNode <HistogramNode>(pvm, mock, new Point(50, 50));
            ImageInputNode            imin  = (ImageInputNode)AddNode <ImageInputNode>(pvm, mock, new Point(70, 50));
            InverterNode              invn  = (InverterNode)AddNode <InverterNode>(pvm, mock, new Point(90, 50));
            NoiseInputNode            nin   = (NoiseInputNode)AddNode <NoiseInputNode>(pvm, mock, new Point(110, 50));
            OverlayNode               on    = (OverlayNode)AddNode <OverlayNode>(pvm, mock, new Point(10, 70));
            RgbSplitNode              rgbsn = (RgbSplitNode)AddNode <RgbSplitNode>(pvm, mock, new Point(30, 70));
            WeightedAveragedMergeNode wamn  =
                (WeightedAveragedMergeNode)AddNode <WeightedAveragedMergeNode>(pvm, mock, new Point(50, 70));

            // Step 3: Create the edges
            mvm.Model.Graph.AddEdge(vin.Outputs[0], bn.Inputs[0]);
            Assert.Equal(vin.Outputs[0], bn.Inputs[0].Source);
            amn.Inputs.Add(new Node.Input());
            mvm.Model.Graph.AddEdge(vin.Outputs[0], amn.Inputs[0]);
            Assert.Equal(vin.Outputs[0], amn.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(bn.Outputs[0], dln.Inputs[0]);
            Assert.Equal(bn.Outputs[0], dln.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(dln.Outputs[0], dfn.Inputs[0]);
            Assert.Equal(dln.Outputs[0], dfn.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(imin.Outputs[0], dfn.Inputs[1]);
            Assert.Equal(imin.Outputs[0], dfn.Inputs[1].Source);
            mvm.Model.Graph.AddEdge(dfn.Outputs[0], invn.Inputs[0]);
            Assert.Equal(dfn.Outputs[0], invn.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(invn.Outputs[0], on.Inputs[0]);
            Assert.Equal(invn.Outputs[0], on.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(vin.Outputs[0], on.Inputs[1]);
            Assert.Equal(vin.Outputs[0], on.Inputs[1].Source);
            mvm.Model.Graph.AddEdge(vin.Outputs[0], rgbsn.Inputs[0]);
            Assert.Equal(vin.Outputs[0], rgbsn.Inputs[0].Source);
            mvm.Model.Graph.AddEdge(rgbsn.Outputs[2], hn.Inputs[0]);
            Assert.Equal(rgbsn.Outputs[2], hn.Inputs[0].Source);
        }
Exemplo n.º 2
0
        public void TestHistogramNodeRGB()
        {
            // Generates an array of 1 Frame with randomly filled Data
            YuvKA.VideoModel.Size testSize = new YuvKA.VideoModel.Size(5, 5);
            Frame[] inputs = { new Frame(testSize) };
            for (int x = 0; x < testSize.Width; x++)
            {
                for (int y = 0; y < testSize.Height; y++)
                {
                    inputs[0][x, y] = new Rgb((byte)(x + y), (byte)(x + y), (byte)(x + y));
                }
            }

            // Generate all RGB HistogramNode once
            HistogramNode histNodeR = new HistogramNode();

            histNodeR.Type = HistogramType.R;
            HistogramNode histNodeG = new HistogramNode();

            histNodeG.Type = HistogramType.G;
            HistogramNode histNodeB = new HistogramNode();

            histNodeB.Type = HistogramType.B;

            histNodeR.Process(inputs, 0);
            histNodeG.Process(inputs, 0);
            histNodeB.Process(inputs, 0);

            // Calculate expected results independently from Histogram methods.
            int[] value = new int[3];
            int[,] intData = new int[256, 3];
            for (int x = 0; x < inputs[0].Size.Width; x++)
            {
                for (int y = 0; y < inputs[0].Size.Height; y++)
                {
                    value[0] = inputs[0][x, y].R;
                    value[1] = inputs[0][x, y].G;
                    value[2] = inputs[0][x, y].B;
                    intData[value[0], 0]++;
                    intData[value[1], 1]++;
                    intData[value[2], 2]++;
                }
            }
            int numberOfPixels = inputs[0].Size.Height * inputs[0].Size.Width;

            for (int i = 0; i < 256; i++)
            {
                Assert.Equal(histNodeR.Data[i], (double)intData[i, 0] / numberOfPixels);
                Assert.Equal(histNodeG.Data[i], (double)intData[i, 1] / numberOfPixels);
                Assert.Equal(histNodeB.Data[i], (double)intData[i, 2] / numberOfPixels);
            }
        }
Exemplo n.º 3
0
        public void TestHistogramNodeValue()
        {
            // Generates an array of 1 Frame with randomly filled Data
            YuvKA.VideoModel.Size testSize = new YuvKA.VideoModel.Size(5, 5);
            Frame[] inputs = { new Frame(testSize) };
            for (int x = 0; x < testSize.Width; x++)
            {
                for (int y = 0; y < testSize.Height; y++)
                {
                    inputs[0][x, y] = new Rgb((byte)(x + y), (byte)(x + y), (byte)(x + y));
                }
            }

            // Generate Value HistogramNode once
            HistogramNode histNodeValue = new HistogramNode();

            histNodeValue.Type = HistogramType.Value;

            histNodeValue.Process(inputs, 0);

            // Calculate expected results independently from Histogram method.
            Color rgbValue;
            int   value;

            int[] intData = new int[256];
            for (int x = 0; x < inputs[0].Size.Width; x++)
            {
                for (int y = 0; y < inputs[0].Size.Height; y++)
                {
                    rgbValue = Color.FromArgb(inputs[0][x, y].R, inputs[0][x, y].G, inputs[0][x, y].B);
                    value    = (int)(rgbValue.GetBrightness() * 255);
                    intData[value]++;
                }
            }
            int numberOfPixels = inputs[0].Size.Height * inputs[0].Size.Width;

            for (int i = 0; i < 256; i++)
            {
                Assert.Equal(histNodeValue.Data[i], (double)intData[i] / numberOfPixels);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a new HistogramViewMode with the given HistogramNode.
 /// </summary>
 public HistogramViewModel(HistogramNode nodeModel)
     : base(nodeModel, null)
 {
 }