将Emgu图像转换为数组,从数组转换为图像

时间:2014-02-27 14:43:30

标签: image-processing emgucv itemgroup

我想让你知道从字节数组中获取图像的方法:

我正在使用这段代码,但如果大小超过100或者arary的长度,它会抛出异常,如果它小于50则会保存一个混乱的图像

Bitmap b = new Bitmap(@"C:/difflena.jpg");

             byte[] pixels = lolo(b);
          MemoryStream stream = new MemoryStream(pixels, 0, pixels.Length);
          Bitmap bitmap = new Bitmap(stream);
          Image<Gray, byte> image = new Image<Gray, byte>(60, 60);
          image.Bytes = pixels;
          image.Save(file + "face" + "t" + ".bmp");
          if (image != null) { Label1.Text = "yes";


 public byte[] lolo(Bitmap n)
      {

          /*ImageFormat imageFormat = n.RawFormat;

          byte[] Ret=null;
          try
          {
              using (MemoryStream ms = new MemoryStream())
              {
                  n.Save(ms, imageFormat);
                  Ret = ms.ToArray();
              }

          }
          catch (Exception) { Label1.Text = "no"; }

          return Ret;}

0 个答案:

没有答案
相关问题