• 大小: 1.29M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-02
  • 语言: 其他
  • 标签: 其他  

资源简介

BGRtoGRAY.rar

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.CV.Structure;
using System.Runtime.InteropServices;


namespace BGRtoGRAY
{
    public partial class ToGrayImage : Form
    {
        public ToGrayImage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {

                //IntPtr ptrImage = CvInvoke.cvLoadImage(openFileDialog1.FileName LOAD_IMAGE_TYPE.CV_LOAD_IMAGE_UNCHANGED);

                /* IplImage* 转换为Bitmap */
                //图片读取
                Image image = new Image(openFileDialog1.FileName);

                pictureBox1.Image = image.Bitmap;//ConvertIntPrToBitmap(ptrImage);

                Image imageGray = image.Convert();
                imageGray.Save(@“C:\temp\b.bmp“);

                pictureBox2.Image = imageGray.Bitmap;

                //显示灰度图像

                //IntPtr grayImage = CvInvoke.cvCreateImage(CvInvoke.cvGetSize(ptrImage) IPL_DEPTH.IPL_DEPTH_8U 1);

                //CvInvoke.cvCvtColor(ptrImage grayImage COLOR_CONVERSION.CV_BGR2GRAY);



                ////pictureBox2.Image = ConvertIntPrToBitmap(grayImage); //用该方法灰度图像会有三个图片

                //MIplImage mi = (MIplImage)Marshal.PtrToStructure(grayImage typeof(MIplImage));

                //Image image = new Image(mi.width mi.height mi.widthStep mi.imageData);

                //pictureBox2.Image = image.ToBitmap();

                //CvInvoke.cvReleaseImage(ref ptrImage);
                //CvInvoke.cvReleaseImage(ref grayImage);

            }
        }


        /// 将IplImage*转换为Bitmap(注:在OpenCV中IplImage* 对应EmguCV的IntPtr类型)        
        public static Bitmap ConvertIntPrToBitmap(IntPtr ptrImage)
        {

            //将IplImage指针转换成MIplImage结构

            MIplImage mi = (MIplImage)Marshal.PtrToStructure(ptrImage typeof(MIplImage));

            Image image = new Image(mi.width mi.height mi.widthStep mi.imageData);

            return image.ToBitmap();

        }



    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       5875  2014-08-27 20:14  BGRtoGRAY\BGRtoGRAY\BGRtoGRAY.csproj

     文件     828478  2014-08-27 20:20  BGRtoGRAY\BGRtoGRAY\bin\Debug\a.bmp

     文件       9728  2014-11-10 16:51  BGRtoGRAY\BGRtoGRAY\bin\Debug\BGRtoGRAY.exe

     文件      32256  2014-11-10 16:51  BGRtoGRAY\BGRtoGRAY\bin\Debug\BGRtoGRAY.pdb

     文件      11600  2014-11-10 16:51  BGRtoGRAY\BGRtoGRAY\bin\Debug\BGRtoGRAY.vshost.exe

     文件        490  2010-03-17 22:39  BGRtoGRAY\BGRtoGRAY\bin\Debug\BGRtoGRAY.vshost.exe.manifest

     文件     322048  2014-04-16 12:18  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.dll

     文件      42496  2014-04-16 12:18  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.GPU.dll

     文件     112128  2014-04-16 12:18  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.GPU.pdb

     文件     148820  2014-04-16 12:18  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.GPU.xml

     文件      36864  2013-09-23 20:41  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.ML.dll

     文件     146004  2013-09-23 20:41  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.ML.xml

     文件       8192  2014-04-16 12:18  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.OCR.dll

     文件      15872  2014-04-16 12:18  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.OCR.pdb

     文件       9792  2014-04-16 12:18  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.OCR.xml

     文件      40960  2013-09-23 20:41  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.OpenCL.dll

     文件      94430  2013-09-23 20:41  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.OpenCL.xml

     文件     929280  2014-04-16 12:18  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.pdb

     文件       5632  2014-04-16 12:18  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.Stitching.dll

     文件      13824  2014-04-16 12:18  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.Stitching.pdb

     文件       1153  2014-04-16 12:18  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.Stitching.xml

     文件     113664  2014-04-16 12:18  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.UI.dll

     文件     140800  2014-04-16 12:18  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.UI.pdb

     文件      35149  2014-04-16 12:18  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.UI.xml

     文件    1227431  2014-04-16 12:18  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.CV.xml

     文件      25088  2014-04-16 12:17  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.Util.dll

     文件      58880  2014-04-16 12:17  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.Util.pdb

     文件      22455  2014-04-16 12:17  BGRtoGRAY\BGRtoGRAY\bin\Debug\Emgu.Util.xml

     文件     307200  2013-02-09 07:33  BGRtoGRAY\BGRtoGRAY\bin\Debug\ZedGraph.dll

     文件    1492968  2013-02-09 07:33  BGRtoGRAY\BGRtoGRAY\bin\Debug\ZedGraph.xml

............此处省略38个文件信息

评论

共有 条评论