Ejemplo n.º 1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            BinaryObject1 = tanimoto.getBinaryObjectByName(comboBox1.Text.ToString());
            Flag1 = true;

            if (Flag2)
            {
                BinaryObject1 = tanimoto.Scalar(BinaryObject1, BinaryObject2.Height, BinaryObject2.Width);
                tanimoto.tanimotoDistance(BinaryObject1, BinaryObject2);
            }

            LogicBasicProcessor processor = new LogicBasicProcessor(BinaryObject1.Width, BinaryObject1.Height, BinaryObject1.Pixels);
            pictureBox1.Image = processor.getImageMap();
        }
        public Dictionary<int, DTOBinaryObject> generateBinaryObjects()
        {
            segmentation();

            for (int iteratorHeight = 0; iteratorHeight < Height; iteratorHeight++)
            {
                for (int iteratorWidth = 0; iteratorWidth < Width; iteratorWidth++)
                {
                    int it = iteratorHeight * Width + iteratorWidth;
                    DTOBinaryObject binaryObject;

                    if (Colors[it] != -1) {
                        if(BinaryObjects.TryGetValue(Colors[it], out binaryObject)){
                            binaryObject.checkPoint(iteratorWidth,iteratorHeight);
                        } else {
                            binaryObject = new DTOBinaryObject(Colors[it], iteratorWidth, iteratorHeight);
                            BinaryObjects[Colors[it]] = binaryObject;
                        }
                    }
                }
            }

            foreach (var binaryObject in BinaryObjects) {

                binaryObject.Value.computeSize();
                int ptr = 0;
                binaryObject.Value.Pixels = new int[binaryObject.Value.Height * binaryObject.Value.Width];

                for (int iteratorPositionY = binaryObject.Value.Points.PosY ;
                    iteratorPositionY <= binaryObject.Value.BottomPoint.PosY ;
                    iteratorPositionY++)
                {
                    for (int i = binaryObject.Value.Points.PosX; i <= binaryObject.Value.BottomPoint.PosX; i++)
                    {
                        int it = iteratorPositionY * Width + i;
                        binaryObject.Value.Pixels[ptr++]  = Colors[it];
                    }
                }

                binaryObject.Value.setCenterOfMass();

            }

            return BinaryObjects;
        }