Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i want cut the image from pattern
the output of this algorithm is array of bit that image pixel has 1 value and pattern has 0 value,more this algorithm used in fingerPrint or face detection.
Can help me???
thank's
Posted
Updated 8-Sep-11 23:30pm
v2

1 solution

Your question isn't clear but I think I understand what your attempting to do. Well it's one of two things. I will assume that you have only one finger print or face within the image. If you have more you will have to separate each one to perform the second operation correctly.

1st:
If you want to find the original image data from a binary map (the output of 1's and 0's) you need to loop through your output data and simply reference it's x,y data to the image:

C#
//somewhere to store it
//Assume orginal image in Bitmap called original_image
//and output image in Bitmap called output_data

Bitmap my_new_image = new Bitmap(original_image.Width,  original_image.Height);

for (int y = 0; y < myImage.Height; y++)
{
   for (int x = 0; x < myImage.Width; x++)
   {
        Color c = output_data.GetPixel(x, y); //Assuming it is in a picturebox this may need to be change depending on image format
        if(output_data.R == 255 && output_data.G == 255 && output_data.B == 255)//Same here depends on image format
        {
              my_new_Image.SetPixel(x, y, original_image.GetPixel(x, y););
        }
        myImage.SetPixel(x, y, Color.FromArgb(luma, luma, luma));
   }
}



2nd:
Now the alternative is you want a rectangle where the finger or face is located within the original image. Again you have to loop through your result data instead here you want to record the top left position of data and the bottom right position of data it's easily done.

C#
//this deceleration important as if X_min = 0 for example will never hold the correct value for minimum X position

int X_min = myImage.Width, X_max = 0;
int Y_min = myImage.Height, Y_max = 0;

for (int y = 0; y < myImage.Height; y++)
{
    for (int x = 0; x < myImage.Width; x++)
    {
        Color c = output_data.GetPixel(x, y); //Same assumptions made as above
        if(output_data.R == 255 && output_data.G == 255 && output_data.B == 255)
        {
             if(x>X_max) X_max = x; //record max X position
             if(x             if(x>Y_max) Y_max = y; //record max Y position
             if(x>Y_min) Y_min = y; //record min Y position
        }
    }
}
Rectangle location = new Rectangle(X_min, Y_min, X_max, Y_max); //you can use this data to draw a rectangle on your original image.


Since you mention face detection and you are doing complex image processing in c# I would recommend transferring to EMGU [^] which is c# wrapper for opencv image processing library. It will allow simpler programming of image processing algorithms and the Haar Classifiers for face detection are more efficient and output location like the 2nd process I have mentioned here is a good article Multiple face detection and recognition in real time[^].

I hope this helps,
Cheers
Chris
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900