Exemple #1
0
        public void Test_Census()
        {
            CensusCostComputer costCpu = new CensusCostComputer();
            costCpu.MaskHeight = 1;
            costCpu.MaskWidth = 1;
            costCpu.ImageBase = new GrayScaleImage() { ImageMatrix = _imageLeft };
            costCpu.ImageMatched = new GrayScaleImage() { ImageMatrix = _imageRight };

            costCpu.Init();

            // Expected census in points (base):
            // [0,0] : 0000_0000, [0,1] : 0100_0101, [1,1] : 1101_1011, [2,2] : 0101_0001
            IBitWord c00 = BitWord.CreateBitWord(new uint[1] { 0 });
            IBitWord c10 = BitWord.CreateBitWord(new uint[1] { 1 << 8 | 0 << 7 | 1 << 6 | 0 << 5 | 0 << 4 | 0 << 3 | 0 << 2 | 1 << 1 | 0 << 0 });
            IBitWord c11 = BitWord.CreateBitWord(new uint[1] { 1 << 8 | 1 << 7 | 0 << 6 | 1 << 5 | 0 << 4 | 1 << 3 | 0 << 2 | 1 << 1 | 1 << 0 });
            IBitWord c22 = BitWord.CreateBitWord(new uint[1] { 1 << 8 | 0 << 7 | 0 << 6 | 0 << 5 | 0 << 4 | 1 << 3 | 0 << 2 | 1 << 1 | 0 << 0 });
            int diff = costCpu.CensusBase[0, 0].GetHammingDistance(c00);
            Assert.IsTrue(diff == 0,
                "Wrong census transform in point [0,0]. Census: " + costCpu.CensusBase[0, 0].ToString());
            diff = costCpu.CensusBase[0, 1].GetHammingDistance(c10);
            Assert.IsTrue(diff == 0,
                "Wrong census transform in point [0,1]. Census: " + costCpu.CensusBase[0, 1].ToString());
            diff = costCpu.CensusBase[1, 1].GetHammingDistance(c11);
            Assert.IsTrue(diff == 0,
                "Wrong census transform in point [1,1]. Census: " + costCpu.CensusBase[1, 1].ToString());
            diff = costCpu.CensusBase[2, 2].GetHammingDistance(c22);
            Assert.IsTrue(diff == 0,
                "Wrong census transform in point [2,2]. Census: " + costCpu.CensusBase[2, 2].ToString());

            // Expected matching cost in points (base, matched):
            // ([2,2], [3,2]) : 3
            // ([2,2], [4,2]) : 0
            // ([2,2], [2,2]) : 3
            double cost = costCpu.GetCost(new IntVector2(2, 2), new IntVector2(3, 2));
            Assert.IsTrue(cost.Round() == 3, "Wrong rank cost in points ([2,2],[3,2]). Expected: 3; Actual: " + cost);
            cost = costCpu.GetCost(new IntVector2(2, 2), new IntVector2(4, 2));
            Assert.IsTrue(cost.Round() == 0, "Wrong rank cost in points ([2,2],[4,2]). Expected: 0; Actual: " + cost);
            cost = costCpu.GetCost(new IntVector2(2, 2), new IntVector2(2, 2));
            Assert.IsTrue(cost.Round() == 3, "Wrong rank cost in points ([2,2],[2,2]). Expected: 3; Actual: " + cost);
        }
Exemple #2
0
        public void Test_BSGM_NoNoise()
        {
            SGMAggregator agg = new SGMAggregator();
            CensusCostComputer cost = new CensusCostComputer();
            WTADisparityComputer dispComp = new WTADisparityComputer();

            cost.ImageBase = new GrayScaleImage() { ImageMatrix = _imageLeft };
            cost.ImageMatched = new GrayScaleImage() { ImageMatrix = _imageRight };
            cost.MaskWidth = 3;
            cost.MaskHeight = 3;
            agg.CostComp = cost;

            dispComp.ConfidenceComp.UsedConfidenceMethod = ConfidenceMethod.TwoAgainstTwo;
            dispComp.CostComp = cost;
            dispComp.ImageBase = cost.ImageBase;
            dispComp.ImageMatched = cost.ImageMatched;
            agg.DispComp = dispComp;

            DisparityMap disp = new DisparityMap(_imageLeft.RowCount, _imageLeft.ColumnCount);
            agg.DisparityMap = disp;
            dispComp.DisparityMap = disp;

            agg.ImageBase = cost.ImageBase;
            agg.ImageMatched = cost.ImageMatched;
            agg.IsLeftImageBase = true;
            agg.Fundamental = _F;

               // agg.PathsLength = 10;
            agg.LowPenaltyCoeff = 0.02;
            agg.HighPenaltyCoeff = 0.04;
            agg.MaxDisparity = 10;
            agg.MinDisparity = 1;

            dispComp.Init();
            agg.Init();
            agg.ComputeMatchingCosts();
        }
Exemple #3
0
        public virtual void InitParameters()
        {
            // Add all available cost computers
            ParametrizedObjectParameter costParam =
                new ParametrizedObjectParameter("Matching Cost Computer", "COST");

            costParam.Parameterizables = new List<IParameterizable>();
            var cens = new CensusCostComputer();
            cens.InitParameters();
            costParam.Parameterizables.Add(cens);
            var rank = new RankCostComputer();
            rank.InitParameters();
            costParam.Parameterizables.Add(rank);

            _params.Add(costParam);
        }