getpixel

Get Pixel color fastest way?

早过忘川 提交于 2019-11-27 01:11:42
问题 I'm trying to make an auto-cliker for an windows app. It works well, but it's incredibly slow! I'm currently using the method "getPixel" which reloads an array everytime it's called. Here is my current code: hdc = GetDC(HWND_DESKTOP); bx = GetSystemMetrics(SM_CXSCREEN); by = GetSystemMetrics(SM_CYSCREEN); start_bx = (bx/2) - (MAX_WIDTH/2); start_by = (by/2) - (MAX_HEIGHT/2); end_bx = (bx/2) + (MAX_WIDTH/2); end_by = (by/2) + (MAX_HEIGHT/2); for(y=start_by; y<end_by; y+=10) { for(x=start_bx; x

How to compare a Color by the GetPixel Method and a Color passed in a method like Color.Black?

旧城冷巷雨未停 提交于 2019-11-26 18:37:32
问题 I have a loop that gets pixelcolors from an image and try to see if they are the same as the Color I passed into the method as parameter. I tried the Equals method but it doesn't work. I also tried the ToKnown method. It looks like that match doesn't work beacuse the values that synthesize the two colors don't match. Example: With GetPixel: {Name=ff000000, ARGB=(255, 0, 0, 0)} Color.Black: {Name=Black, ARGB=(255, 0, 0, 0)} if (pixelColor.ToArgb().Equals(startingOffsetColor.ToArgb())) { } The

OpenCV get pixel channel value from Mat image

巧了我就是萌 提交于 2019-11-26 11:13:59
Maybe I'm not looking hard enough, but everything seems to want me to use an array. Thus, how do I get the channel value for a particular pixel for foo if foo is something like Mat foo = imread("bar.png") ? mevatron Assuming the type is CV_8UC3 you would do this: for(int i = 0; i < foo.rows; i++) { for(int j = 0; j < foo.cols; j++) { Vec3b bgrPixel = foo.at<Vec3b>(i, j); // do something with BGR values... } } Here is the documentation for Vec3b. Hope that helps! Also, don't forget OpenCV stores things internally as BGR not RGB. EDIT : For performance reasons, you may want to use direct access

OpenCV get pixel channel value from Mat image

倖福魔咒の 提交于 2019-11-26 02:19:09
问题 Maybe I\'m not looking hard enough, but everything seems to want me to use an array. Thus, how do I get the channel value for a particular pixel for foo if foo is something like Mat foo = imread(\"bar.png\") ? 回答1: Assuming the type is CV_8UC3 you would do this: for(int i = 0; i < foo.rows; i++) { for(int j = 0; j < foo.cols; j++) { Vec3b bgrPixel = foo.at<Vec3b>(i, j); // do something with BGR values... } } Here is the documentation for Vec3b. Hope that helps! Also, don't forget OpenCV

C# - Faster Alternatives to SetPixel and GetPixel for Bitmaps for Windows Forms App

丶灬走出姿态 提交于 2019-11-26 00:37:41
问题 I am trying to teach myself C# and have heard from a variety of sources that the functions get and setpixel can be horribly slow. What are some of the alternatives and is the performance improvement really that significant? Thanks in advance! A chunk of my code for reference: public static Bitmap Paint(Bitmap _b, Color f) { Bitmap b = new Bitmap(_b); for (int x = 0; x < b.Width; x++) { for (int y = 0; y < b.Height; y++) { Color c = b.GetPixel(x, y); b.SetPixel(x, y, Color.FromArgb(c.A, f.R, f