我的图像SHADING算法和5x5滤波

我的图像SHADING算法和5x5滤波

本人直接使用Markdown编辑器,用它写博客玩一玩的哦:

  • 目录

项目3
定义 C
定义 D

定义D内容

代码块

下面我的图像SHADING算法和5x5滤波的C#代码:

if (mImage == null)
            {
   
                MessageBox.Show("Please open or snap an image first.");
                return;
            }
            if (mRectangle.Width == 0)
            {
   
                MessageBox.Show("Please add a rectangele area first.");
                return;
            }
            //----------------------------------------------------------------------
            // 将源图像内存区域锁定
            Rectangle rect = new Rectangle(0, 0, mImage.Width, mImage.Height);
            BitmapData bmpData = mImage.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed);


            // 获取图像参数
            int width = bmpData.Width;
            int height = bmpData.Height;
            int stride = bmpData.Stride;                // 扫描线的宽度,比实际图片要大 (RGB用)
            //int offset = stride - width * 3;            // 显示宽度与扫描线宽度的间隙  (RGB用)
            IntPtr ptr = bmpData.Scan0;                   // 获取bmpData的内存起始位置的指针
            int scanBytesLength = stride * height;     // 用stride宽度,表示这是内存区域的大小 (RGB用)


            int mBigRectangle = mRectangle.Width * mRectangle.Height;
            iCellGrayValue = new double[mBigRectangle];
            ClassCommon.iCellGrayShadingRate = new double[mBigRectangle];
            ClassCommon.iCellGrayShadingRateFinal = new double[mBigRectangle];

            int mSmallRectangle = mRectMean.Width * mRectMean.Height;
            iCellGrayValueOfSmall = new double[mSmallRectangle];


            int posScan = 0;
            int ordinal = 0;
            byte[] curGrayValue = new byte[scanBytesLength];  // 为目标数组分配内存
            Marshal.Copy(ptr, curGrayValue, 0, scanBytesLength)
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值