与图像相比,哪个像素或字节数组更快 [英] Which is faster pixel or byte array with image in comparison

查看:118
本文介绍了与图像相比,哪个像素或字节数组更快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将图像转换为字节数组或将图像转换为像素的速度更快.比较起来,包括
感谢您的帮助
我开发了通过网络摄像头控制动作的应用程序
我比较了第一张图片和第二张图片
因此使用像素或字节数组时速度很慢
字节数组的校验差异不严格
如果您有其他方法请PLZ告诉我
感谢您的帮助.

Which is faster to convert the image to byte array or convert the image to pixel. In comparison, including
thanks for help
i developed application to controlling actions by web cam
i compared first image by second with next image
so i have slow when using pixel or byte array
byte array is not strict in check difference
if you have other way plz tell me
Thanks for any help

推荐答案

可以从这样的图像中获取字节数组..(来自MSDN)

Can get the byte array from the image like this..(from MSDN)

// Create a new bitmap.
Bitmap bmp = new Bitmap("Flower1.jpg");

// Lock the bitmap's bits.
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
System.Drawing.Imaging.BitmapData bmpData =
    bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite,
    bmp.PixelFormat);

// Get the address of the first line.
IntPtr ptr = bmpData.Scan0;

// Declare an array to hold the bytes of the bitmap.
// This code is specific to a bitmap with 24 bits per pixels.
int bytes = bmp.Width * bmp.Height*3 ;
byte[] rgbValues = new byte[bytes];

// Copy the RGB values into the array.
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);


一旦获得数组,就需要遍历数组并使用算法进行比较.

比较图像的更简单方法是比较图像直方图.在频域中也有一些方法.为什么因为在强光和暗光下拍摄的同一帧区域具有不同的像素值,但是或多或少地具有相同的直方图形状.对于这个简单的事实,将字节与字节(或像素与像素)进行比较.那里有很多高级算法,有些使用图像的熵内容.尽管算法很多,但没有硬性规定,哪一种更好.因此,您需要尝试使用那些流行的算法进行研究

您可以使用Accord.net或Aforge.net之类的库,它们已经开发了对您有用的算法.

http://www.aforgenet.com/framework/ [ http://accord-net.origo.ethz.ch/ [


Once get the array need to loop through the array and use the algorithm for comparison.

The simpler way for comparing images would be comparing the image histogram. There are ways in the frequency domain as well. Why because the same frame area taken in bright light and dim light has different pixel values, but more or less same histogram shape. For this simple fact comparing byte to byte (or pixel to pixel). There are many advance algorithms over there, some use the entropy content of the image. Though there many algorithms there is no hard and fast rules which one is better. So you need research trying those popular algorithms

You may use libraries like Accord.net or Aforge.net, they have already developed algorithms which may useful for you.

http://www.aforgenet.com/framework/[^]

http://accord-net.origo.ethz.ch/[^]


在托管代码中,几乎可以肯定是字节数组. GetPixel非常非常慢.
In managed code almost certainly a byte-array. GetPixel is very, very slow.


这篇关于与图像相比,哪个像素或字节数组更快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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