Exemple #1
0
        public static void Contrast(ByteImage btm)
        {
            PrimitiveContrast pc = new PrimitiveContrast(30, 255, 255, 0);

            for (int x = 0; x < btm.Width; x++)
            {
                for (int y = 0; y < btm.Height; y++)
                {
                    btm.setPixel(x, y, pc.GetColor(btm.getPixel(x, y)));
                }
            }
        }
Exemple #2
0
        public static void IrisContrast(ByteImage newBmpTbl)
        {
            PrimitiveContrast pc = new PrimitiveContrast(0, 255, 185, 0);

            for (int x = 0; x < newBmpTbl.Width; x++)
            {
                for (int y = 0; y < newBmpTbl.Height; y++)
                {
                    newBmpTbl.setPixel(x, y, pc.GetColor(newBmpTbl.getPixel(x, y)));
                }
            }
        }
Exemple #3
0
 public static void GrayScale(ByteImage btm)
 {
     for (int x = 0; x < btm.Width; x++)
     {
         for (int y = 0; y < btm.Height; y++)
         {
             byte[] oldColour;
             oldColour = btm.getPixel(x, y);
             var value = (0.2 * (double)oldColour[1]) + (0.7 * (double)oldColour[2]) + (0.1 * (double)oldColour[3]);
             btm.setPixel(x, y, oldColour[0], (byte)value, (byte)value, (byte)value);
         }
     }
 }
Exemple #4
0
        public static void RemoveSingleNoises(ByteImage btm)
        {
            ByteImage tempPict = new ByteImage(btm);
            int       counter  = 0;

            for (int x = 0; x < btm.Width; x++)
            {
                for (int y = 0; y < btm.Height; y++)
                {
                    var oldColour = btm.getPixel(x, y);
                    if (oldColour[1] == 0)
                    {
                        bool isAlone = true;

                        for (int x2 = -1; x2 <= 1; x2++)
                        {
                            for (int y2 = -1; y2 <= 1; y2++)
                            {
                                if (x + x2 >= 0 && x + x2 < btm.Width && y + y2 >= 0 && y + y2 < btm.Height)
                                {
                                    var col = btm.Pixels[btm.getPixelIndex(x + x2, y + y2) + 1];
                                    if (col == 0)
                                    {
                                        isAlone = false;
                                        break;
                                    }
                                }
                            }
                        }

                        if (isAlone)
                        {
                            tempPict.setPixel(x, y, 255, 0, 0, 0);
                        }
                    }
                }
            }
            Console.WriteLine(counter + " pixels removed");
            for (int x = 0; x < btm.Width; x++)
            {
                for (int y = 0; y < btm.Height; y++)
                {
                    btm.setPixel(x, y, tempPict.getPixel(x, y));
                }
            }
        }
Exemple #5
0
        public static void RunFullBlack(ByteImage newBmpTbl)
        {
            int bigCounter = 3;

            while (bigCounter > 2)
            {
                ByteImage tempPict = new ByteImage(newBmpTbl);
                bigCounter = 0;
                for (int x = 0; x < newBmpTbl.Width; x++)
                {
                    for (int y = 0; y < newBmpTbl.Height; y++)
                    {
                        int counter = 0;
                        for (int x2 = -1; x2 < 2; x2++)
                        {
                            for (int y2 = -1; y2 < 2; y2++)
                            {
                                if (newBmpTbl.Pixels[newBmpTbl.getPixelIndex(x, y) + 1] != 0 && x + x2 >= 0 && y + y2 >= 0 && x + x2 < newBmpTbl.Width && y + y2 < newBmpTbl.Height && newBmpTbl.Pixels[newBmpTbl.getPixelIndex(x + x2, y + y2) + 1] <= (255 / 6))
                                {
                                    counter++;
                                }
                            }
                        }
                        if (counter >= 5)
                        {
                            tempPict.setPixel(x, y, 255, 0, 0, 0);
                            bigCounter++;
                        }
                    }
                }
                Console.WriteLine("Blacked " + bigCounter + " pixels.");
                for (int x = 0; x < newBmpTbl.Width; x++)
                {
                    for (int y = 0; y < newBmpTbl.Height; y++)
                    {
                        newBmpTbl.setPixel(x, y, tempPict.getPixel(x, y));
                    }
                }
            }
        }