zoukankan      html  css  js  c++  java
  • 图象处理算法(八)

    八、抖动
     1        public static bool Jitter(Bitmap b, int Offset)
     2        {
     3            BitmapData bmData = b.LockBits(new Rectangle(00, b.Width, b.Height), 
     4                ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
     5            int stride = bmData.Stride;
     6            System.IntPtr Scan0 = bmData.Scan0;
     7            unsafe
     8            {
     9                byte * p = (byte *)(void *)Scan0;
    10                byte * p1 = p;
    11                int nOffset = stride - b.Width*3;
    12                Random rad = new Random();
    13                for(int y=0;y<b.Height;++y)
    14                {
    15                    for(int x=0; x < b.Width; ++x )
    16                    {
    17                        int xIn = rad.Next(2 * Offset + 1- Offset + x;
    18                        int yIn = rad.Next(2 * Offset + 1- Offset + y;
    19                        if((xIn >= 0&& (yIn >= 0&& (xIn < b.Width) && (yIn < b.Height))
    20                        {
    21                         byte * pTemp = p1 + stride * yIn + xIn * 3;
    22                            for (int i = 0; i < 3; i++, p++)
    23                            {
    24                                *= pTemp[i];
    25                            }

    26                        }

    27                        else
    28                        {
    29                            p += 3;
    30                        }

    31                    }

    32                    p += nOffset;
    33                }

    34            }

    35            b.UnlockBits(bmData);
    36            return true;
    37        }
  • 相关阅读:
    Some interesting problems in Group theory
    Abstract Harmonic Analysis Lecture Notes
    郭懋正《实变函数与泛函分析》课后题答案
    江泽坚《泛函分析》第二版 参考答案
    国外著名数学杂志
    郑继明等《数值分析》习题解答
    《摩诃般若波罗蜜多心经》新译 何新 译
    炼静
    金刚经原文
    道德经全文
  • 原文地址:https://www.cnblogs.com/faib/p/664395.html
Copyright © 2011-2022 走看看