find a color in an image in c# -


I have paused in this YouTube video that someone finds that Firefox is I want to copy that author, but I'm not sure how to do some image processing.

It seems that the AForge.NET framework allows you to pull down from the video source image in a bitmap format. My question is whether someone has guided me in the direction or provided some guidelines, In which bitmap object can you get a specific color to inquire it? (For example - if the image is 'red' or 'purple' for 'X', then I have an incident 'Color Detected' or so ...)

Any suggestions to anyone

P>

-r.

Edit: Do I have to run the whole bitmap object and inquire each pixel for color? As::

OK, you can always use the GDI + method.

  bitmap b = new bitmap ("some path"); Color x = bg pixels (x, y); However, GetPixel is actually very slow to try it this way first, but if you need to scan several large images it can not work for you. In that case, use lockbits to get in a connective memory section. You can loop through the image immediately, but you should know to manipulate the signature, although this is not very complicated.  

Edit: Using lockbits to see each pixel:

  bitmap b = new bitmap ("some path"); Bitmapdata data = B Lockbits (new rectangle (0, 0, B. Wide, B. Height), Image Lock MOD Reedonly, B. Pixel Format); // Make sure that you check pixel format because you are seeing directly in unsafe memory {byte * ptrSrc = (byte *) data. Scan 0; // Examples 24bpp takes the image (int y = 0; y & lt; data. Heights; ++ y) For better data terrain, need to verify your pixel depth // loop by line ({int X = 0; x & lt; data.Width; + + X) {// Windows Store BGR Pixel Order Byte R = PTRSRC [2]; Byte G = PTRSRC [1]; Byte B = PTRSRC [0]; // next pixel in line ptrSrc + = 3; }}} B.UnlockBits (data);  

If your images finally get tickled then you can use bitmapdata.traad property to start each new line (otherwise you may be reading some junk and your offset Screws).


Comments