Ejemplo de cálculo de varianza y media de imagen de C#

Este artículo muestra un ejemplo del cálculo de la media y la varianza de la imagen, y realiza los métodos de cálculo de la imagen RGB y la imagen de un solo canal de 8 bits, respectivamente.

El código de implementación es el siguiente:

#region 方法 RGB图像均值 直接操作内存快
        /// <summary>
        /// 定义RGB图像均值函数
        /// </summary>
        /// <param name="bmp"></param>
        /// <returns></returns>
        public static double MyBitmapMeanValue(Bitmap bmp)
        {
            Bitmap bmpNew = MyBitmapClone(bmp);//需要克隆要不原图像变化了
            double returnValue = 0;
            Rectangle rect = new Rectangle(0, 0, bmpNew.Width, bmpNew.Height);
            //锁定bitmap到内存
            System.Drawing.Imaging.BitmapData bmpData = bmpNew.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            unsafe
            {
                byte* pIn = (byte*)bmpData.Scan0.ToPointer();
                

Supongo que te gusta

Origin blog.csdn.net/qq_30725967/article/details/132179892
Recomendado
Clasificación