快速图像处理c# [英] fast image processing c#

查看:109
本文介绍了快速图像处理c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我更快地处理它..

这里是我的代码..

please help me to process it more faster..
here''s my code..

int height = pictureBox1.Image.Height;
int width = pictureBox1.Image.Width;

for (int i = 0; i < height; i++)
{

    for (int j = 0; j < width; j++)
    {

         if ((bmp.GetPixel(j, i) == bmp1.GetPixel(22, 16))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(50, 17))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(89, 16))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(116, 18))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(157, 21))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(185, 17))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(216, 17))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(258, 16))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(289, 19))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(23, 54))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(51, 52))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(85, 51))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(126, 48))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(159, 51))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(191, 52))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(223, 50))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(259, 50))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(288, 49))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(26, 82))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(56, 82))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(89, 85))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(125, 85))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(154, 82))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(186, 85))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(214, 83))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(248, 83))
             || (bmp.GetPixel(j, i) == bmp1.GetPixel(285, 81)))
        {
             MessageBox.Show("color found");
             break;
        }
                          
    }
                       if (IsColorFound == true)
                       {
                           break;
                       }
                   }

                   if (IsColorFound == false)
                   {
                       listBox1.Items.Add("None");
                       // MessageBox.Show("No color found.");
                   }

               }
               else
               {
                   MessageBox.Show("Image is not loaded");
               }

推荐答案

你没有设置 IsColorFound 当你找到颜色所以外循环永远不会破坏
You''re not setting IsColorFound when you find the colour so the outer loop never breaks


HTe的问题是你使用的是GetPixel,这是非常慢的。我建议在文章中搜索由Christian Graus编写的一系列文章,图像处理傻瓜。他们会告诉你更快的方式来查看单个像素。
HTe problem is that you''re using GetPixel, which is extremely slow. I suggest searching the articles for a series of them written by Christian Graus, "Image processing for dummies". They''ll show you a MUCH faster way of looking at individual pixels.


你可能会寻求一个C ++解决方案吗?

干杯

Andi
You might seek for a C++ solution?
Cheers
Andi


这篇关于快速图像处理c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆