惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
Tenable Blog
Project Zero
Project Zero
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
S
Schneier on Security
Scott Helme
Scott Helme
S
Securelist
Know Your Adversary
Know Your Adversary
Vercel News
Vercel News
IT之家
IT之家
V
V2EX
F
Fortinet All Blogs
Simon Willison's Weblog
Simon Willison's Weblog
K
Kaspersky official blog
博客园_首页
T
Tailwind CSS Blog
The GitHub Blog
The GitHub Blog
Spread Privacy
Spread Privacy
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
The Register - Security
The Register - Security
有赞技术团队
有赞技术团队
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
The Hacker News
The Hacker News
L
LINUX DO - 热门话题
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CXSECURITY Database RSS Feed - CXSecurity.com
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
S
SegmentFault 最新的问题
AWS News Blog
AWS News Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost

博客园 - Lance Yang

批量插入Oracle,遇到CLob字段慢的解决办法 c#,利用WPF的ScaleTransform和TranslateTransform实现图片的缩放效果 自定义控件如何给特殊类型的属性添加默认值 z(转) Oracle 12c心得 Entity Framework Code First (八)迁移 Migrations EF Code First学习笔记 C#判断程序是由Windows服务启动还是用户启动 全方位掌握 NSIS 的操作 NSIS学习笔记(转) C#开源框架(整理) 十大前端开发框架(转) .Net 学习 C# 实现无焦点窗体(转载) C++C#时间转换 C#调用C++导出类(转) Socket异步发送的同步控制 自己编码实现数据库的映射实体的代码生成器 C# P/Invoke中传递数组参数 Digital image processing In C#
C#数字图像处理(摘录)
Lance Yang · 2012-10-27 · via 博客园 - Lance Yang

namespace ImageProcessor

{

    class RGBImage

    {

        private Bitmap bitmap;

        public RGBImage(Bitmap bitmap)

        {

            this.bitmap = bitmap;

        }

        private int GetWidth()

        {

            return this.bitmap.Size.Width;

        }

        private int GetHeight()

        {

            return this.bitmap.Size.Height;

        }

        private Color RuleRGBValue(int r,int g,int b)

        {

            Color c = new Color();

            if (r > 255) r = 255;

            if (r < 0) r = 0;

            if (g > 255) g = 255;

            if (g < 0) g = 0;

            if (b > 255) b = 255;

            if (b < 0) b = 0;

            c = Color.FromArgb(r, g, b);

            return c;

        }

        /// <summary>

        /// 单色蓝图片

        /// </summary>

        /// <returns></returns>

        public Bitmap ToBlueImage()

        {

            Color c = new Color();

            Color c1 = new Color();

            Bitmap rtBitmap = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);

            for (int i = 0; i < bitmap.Size.Width; i++)

            {

                for (int j = 0; j < bitmap.Size.Height; j++)

                {

                    c = bitmap.GetPixel(i, j);

                    c1 = Color.FromArgb(c.B, c.B, c.B);

                    rtBitmap.SetPixel(i, j, c1);

                }

            }

            return rtBitmap;

        }

        /// <summary>

        /// 单色绿图片

        /// </summary>

        /// <returns></returns>

        public Bitmap ToGreenImage()

        {

            Color c = new Color();

            Color c1 = new Color();

            Bitmap rtBitmap = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);

            for (int i = 0; i < bitmap.Size.Width; i++)

            {

                for (int j = 0; j < bitmap.Size.Height; j++)

                {

                    c = bitmap.GetPixel(i, j);

                    c1 = Color.FromArgb(c.R, c.R, c.R);

                    rtBitmap.SetPixel(i, j, c1);

                }

            }

            return rtBitmap;

        }

        /// <summary>

        /// 单色红图片

        /// </summary>

        /// <returns></returns>

        public Bitmap ToRedImage()

        {

            Color c = new Color();

            Color c1 = new Color();

            Bitmap rtBitmap = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);

            for (int i = 0; i < bitmap.Size.Width; i++)

            {

                for (int j = 0; j < bitmap.Size.Height; j++)

                {

                    c = bitmap.GetPixel(i, j);

                    c1 = Color.FromArgb(255-c.B, 255-c.B, 255-c.B);

                    rtBitmap.SetPixel(i, j, c1);

                }

            }

            return rtBitmap;

        }

        /// <summary>

        /// 单亮度图片

        /// </summary>

        /// <returns></returns>

        public Bitmap ToBrightnessImage()

        {

            Bitmap rtBitmap = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);

            Color c = new Color();

            Color c1 = new Color();

            int y;

            for (int i = 0; i < bitmap.Size.Width; i++)

            {

                for (int j = 0; j < bitmap.Size.Height; j++)

                {

                    c = bitmap.GetPixel(i, j);

                    y = (int)(0.31 * c.R + 0.59 * c.G + 0.11 * c.B);

                    c1 = RuleRGBValue(y, y, y);

                    rtBitmap.SetPixel(i, j, c1);

                }

            }

            return rtBitmap;

        }

        /// <summary>

        /// 灰度图片

        /// </summary>

        /// <param name="n"></param>

        /// <returns></returns>

        public Bitmap ToGrayImage(int n)

        {

            Bitmap rtBitmap = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);

            Color c = new Color();

            Color c1 = new Color();

            int y;

            for (int i = 0; i < bitmap.Size.Width; i++)

            {

                for (int j = 0; j < bitmap.Size.Height; j++)

                {

                    c = bitmap.GetPixel(i, j);

                    y = (int)((c.R + c.G + c.B)/n);

                    c1 = RuleRGBValue(y, y, y);

                    rtBitmap.SetPixel(i, j, c1);

                }

            }

            return rtBitmap; 

        }

        /// <summary>

        /// 逆反图片

        /// </summary>

        /// <returns></returns>

        public Bitmap ToInverseImage()

        {

            Bitmap rtBitmap = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);

            Color c = new Color();

            Color c1 = new Color();

            for (int i = 0; i < bitmap.Size.Width; i++)

            {

                for (int j = 0; j < bitmap.Size.Height; j++)

                {

                    c = bitmap.GetPixel(i, j);

                    c1 = Color.FromArgb(255-c.R, 255-c.G, 255-c.B);

                    rtBitmap.SetPixel(i, j, c1);

                }

            }

            return rtBitmap;

        }

        /// <summary>

        /// 平滑图片

        /// </summary>

        /// <param name="nn"></param>

        /// <returns></returns>

        public Bitmap ToSmoothImage(int nn)

        {

            Bitmap rtBitmap = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);

            Color c = new Color();

            Color c1 = new Color();

            int mm = (nn - 1) / 2;

            for (int i = mm; i < bitmap.Size.Width - mm; i++)

            {

                for (int j = mm; j < bitmap.Size.Height - mm; j++)

                {

                    int r = 0, g = 0, b = 0;

                    for (int m = i - mm; m <= i + mm; m++)

                    {

                        for (int n = j - mm; n <= j + mm; n++)

                        {

                            c = bitmap.GetPixel(m, n);

                            r = r + c.R;

                            g = g + c.G;

                            b = b + c.B;

                        }

                    }

                    r = r / (nn*nn);

                    g = g / (nn * nn);

                    b = b / (nn * nn);

                    c1 = RuleRGBValue(r, g, b);

                    rtBitmap.SetPixel(i, j, c1);

                }

            }

            return rtBitmap;

        }

        /// <summary>

        /// 霓虹图片

        /// </summary>

        /// <returns></returns>

        public Bitmap ToNeonImage()

        {

            Bitmap rtBitmap = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);

            Color c = new Color();

            Color c1 = new Color();

            Color c2 = new Color();

            Color c3 = new Color();

            int r1, r2, g1, g2, b1, b2;

            int r,g,b;

            for (int i = 0; i < bitmap.Size.Width-1; i++)

            {

                for (int j = 0; j < bitmap.Size.Height-1; j++)

                {

                    c1 = bitmap.GetPixel(i, j);

                    c2 = bitmap.GetPixel(i + 1, j);

                    c3 = bitmap.GetPixel(i, j + 1);

                    r1 = (c1.R - c2.R) ^ 2;

                    g1 = (c1.G - c2.G) ^ 2;

                    b1 = (c1.B - c2.B) ^ 2;

                    r2 = (c1.R - c3.R) ^ 2;

                    g2 = (c1.G - c3.G) ^ 2;

                    b2 = (c1.B - c3.B) ^ 2;

                    r = (int)(2 * Math.Sqrt(r1 +r2));

                    g = (int)(2 * Math.Sqrt(g1 + g2));

                    b = (int)(2 * Math.Sqrt(b1 + b2));

                    c = RuleRGBValue(r, g, b);

                    rtBitmap.SetPixel(i, j, c);

                }

            }

            return rtBitmap;

        }

        /// <summary>

        /// 锐化图片

        /// </summary>

        /// <param name="n"></param>

        /// <returns></returns>

        public Bitmap ToSharpeningImage(double n)

        {

            Bitmap rtBitmap = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);

            Color c = new Color();

            Color c1 = new Color();

            Color c2 = new Color();

            int r, g, b;

            for (int i = 1; i < bitmap.Size.Width; i++)

            {

                for (int j = 1; j < bitmap.Size.Height; j++)

                {

                    c1 = bitmap.GetPixel(i, j);

                    c2 = bitmap.GetPixel(i-1,j-1);

                    r = (int)(c1.R + n * Math.Abs(c1.R - c2.R));

                    g = (int)(c1.G + n * Math.Abs(c1.G - c2.G));

                    b = (int)(c1.B + n * Math.Abs(c1.B - c2.B));

                    c = RuleRGBValue(r,g,b);

                    rtBitmap.SetPixel(i, j, c);

                }

            }

            return rtBitmap;

        }

        /// <summary>

        /// 浮雕图片

        /// </summary>

        /// <param name="n"></param>

        /// <returns></returns>

        public Bitmap ToReliefImage(int n)

        {

            if (n < 0) n = 0;

            if (n > 255) n = 255;

            Bitmap rtBitmap = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);

            Color c = new Color();

            Color c1 = new Color();

            Color c2 = new Color();

            int r, g, b;

            for (int i = 1; i < bitmap.Size.Width; i++)

            {

                for (int j = 0; j < bitmap.Size.Height; j++)

                {

                    c1 = bitmap.GetPixel(i, j);

                    c2 = bitmap.GetPixel(i - 1, j);

                    r = c1.R - c2.R + n;

                    g = c1.G - c2.G + n;

                    b = c1.B - c2.B + n;

                    c = RuleRGBValue(r, g, b);

                    rtBitmap.SetPixel(i, j, c);

                }

            }

            return rtBitmap;

        }

        /// <summary>

        /// 镶嵌图片

        /// </summary>

        /// <param name="nn"></param>

        /// <returns></returns>

        public Bitmap ToMosaicImage(int nn)

        {

            if (nn < 0) nn = 3;

            int mm = (nn - 1) / 2;

            Bitmap rtBitmap = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);

            Color c = new Color();

            Color c1 = new Color();

            for (int i = mm; i < bitmap.Size.Width - mm; i++)

            {

                for (int j = mm; j < bitmap.Size.Height - mm; j++)

                {

                    int r = 0, g = 0, b = 0;

                    for (int m = i - mm; m <= i + mm; m++)

                    {

                        for (int n = j - mm; n <= j + mm; n++)

                        {

                            c = bitmap.GetPixel(m, n);

                            r = r + c.R;

                            g = g + c.G;

                            b = b + c.B;

                        }

                    }

                    r = r / (nn*nn);

                    g = g / (nn * nn);

                    b = b / (nn * nn);

                    c1 = RuleRGBValue(r, g, b);

                    for (int m = i - mm; m <= i + mm; m++)

                    {

                        for (int n = j - mm; n <= j + mm; n++)

                        {

                            rtBitmap.SetPixel(m, n, c1);

                        }

                    }

                }

            }

            return rtBitmap;

        }

        /// <summary>

        /// 平移图片

        /// </summary>

        /// <param name="n"></param>

        /// <returns></returns>

        public Bitmap TranslationImage(int n)

        {

            if (n < 0|| n>255) n = 20;

            Bitmap rtBitmap=new Bitmap (bitmap.Width,bitmap.Height);

            Color c=new Color ();

            for(int i=0;i<bitmap.Size.Width-n;i++)

            {

                for(int j=0;j<bitmap.Size.Height-n;j++)

                {

                    c=bitmap.GetPixel(i,j);

                    rtBitmap.SetPixel(i + n, j + n, c);

                }

            }

            return rtBitmap;

        }

        /// <summary>

        /// 

        /// </summary>

        /// <param name="n"></param>

        /// <returns></returns>

        public Bitmap ResizeImage(double n)

        {

            Bitmap rtBitmap = new Bitmap((int)(bitmap.Size.Width*n),(int)(bitmap.Size.Height*n));

            Color c = new Color();

            int x, y; 

            for (int i = 0; i < bitmap.Size.Width; i++)

            {

                for (int j = 0; j < bitmap.Size.Height; j++)

                {

                    c = bitmap.GetPixel(i, j);

                    x = Convert.ToInt16(i * n);

                    y = Convert.ToInt16(j * n);

                    if (x < 0) x = 0;

                    if (x >= rtBitmap.Size.Width) x = rtBitmap.Size.Width-1;

                    if (y < 0) y = 0;

                    if (y >= rtBitmap.Size.Height) y = rtBitmap.Size.Height-1;

                    rtBitmap.SetPixel(x,y, c);

                }

            }

            return rtBitmap;

        }

        /// <summary>

        /// 

        /// </summary>

        /// <returns></returns>

        public Bitmap LRFlipImage()

        {

            Bitmap rtBitmap =new Bitmap (bitmap.Width,bitmap.Height );

            Color c = new Color();

            for (int i = 0; i < bitmap.Width; i++)

            {

                for (int j = 0; j < bitmap.Height; j++)

                {

                    c = bitmap.GetPixel(i, j);

                    rtBitmap.SetPixel(bitmap.Width - 1 - i, j, c);

                }

            }

            return rtBitmap;

        }

        public Bitmap UDFlipImage()

        {

            Bitmap rtBitmap = new Bitmap(bitmap.Width, bitmap.Height);

            Color c = new Color();

            for (int i = 0; i < bitmap.Width; i++)

            {

                for (int j = 0; j < bitmap.Height; j++)

                {

                    c = bitmap.GetPixel(i, j);

                    rtBitmap.SetPixel(i, bitmap.Height-1-j, c);

                }

            }

            return rtBitmap;

        }

        public Bitmap RotateImage(double n)

        {

            if (n < 0) n = 1;

            if (n > 360) n = 360;

            double nn = 180 / n;

            Bitmap rtBitmap = new Bitmap(bitmap.Width,bitmap.Height);

            int x,y;

            double pi = Math.PI;

            for (int i = 0; i < bitmap.Width; i++)

            {

                for (int j = 0; j < bitmap.Height; j++)

                {

                    x =(int)( i * Math.Cos(pi / nn) - j * Math.Sin(pi / nn));

                    y=(int)(i*Math.Sin(pi/6)+j*Math.Cos(pi/6));

                    if(x>0&& x<bitmap.Width&&y>0&&y<bitmap.Height)

                    rtBitmap.SetPixel(x, y, bitmap.GetPixel(i, j));

                }

            }

            return rtBitmap;

        }

        public Bitmap HistImage()

        {

            RGBImage rgb = new RGBImage(this.bitmap);

            Bitmap tempBitmap = rgb.ToGrayImage(3);

            Color c =Color.FromA#ffffff;

            int[] times = new int[256];

            for (int i = 0; i < tempBitmap.Width; i++)

            {

                for (int j = 0; j < tempBitmap.Height; j++)

                {

                    c = tempBitmap.GetPixel(i, j);

                    times[c.R]++;

                }

            }

            int max = times[0];

            for (int i = 1; i < 256; i++)

            {

                if (times[i] > max) max = times[i];

            }

            for (int i = 0; i < 256; i++)

            {

                times[i] = Convert.ToInt16(((double)(times[i]) /(double)( max))*100);

            }

            Bitmap rtBitmap = new Bitmap(256, 110);

            for (int i = 0; i < rtBitmap.Width; i++)

            {

                for (int j = 0; j < rtBitmap.Height; j++)

                {

                    for (int m = 0; m <= times[i]; m++)

                    {

                        rtBitmap.SetPixel(i, m, c);

                    }

                }

            }

            RGBImage rimage = new RGBImage(rtBitmap);

            Bitmap s=rimage.UDFlipImage();

            return s;

        }

    }

}

        private void btnToBlueImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            Bitmap bBitmap = rgbBitmap.ToBlueImage();

            ShowImage showImage = new ShowImage(bBitmap,"单色蓝图片");

            showImage.Show();

        }

        private void btnToGreenImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            Bitmap bBitmap = rgbBitmap.ToGreenImage();

            ShowImage showImage = new ShowImage(bBitmap, "单色绿图片");

            showImage.Show();

        }

        private void btnToRedImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            Bitmap bBitmap = rgbBitmap.ToRedImage();

            ShowImage showImage = new ShowImage(bBitmap, "单色红图片");

            showImage.Show();

        }

        private void btnToBrightnessImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            Bitmap bitmap = rgbBitmap.ToBrightnessImage();

            ShowImage s = new ShowImage(bitmap, "单亮度图片");

            s.Show();

        }

        private void btnToGrayImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            InputDialog inputDialog = new InputDialog("请输入采用的模板大小:", "模板大小","3");

            inputDialog.ShowDialog();

            if (inputDialog.result != "")

            {

                int n = Convert.ToInt16(inputDialog.result);

                Bitmap bitmap = rgbBitmap.ToGrayImage(n);

                ShowImage s = new ShowImage(bitmap, "灰度图片");

                s.Show();

            }

            else

            {

                MessageBox.Show("对不起,你的输入参数错误!");

            }

        }

        private void btnInverseImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            Bitmap bitmap = rgbBitmap.ToInverseImage();

            ShowImage s = new ShowImage(bitmap, "逆反图片");

            s.Show();

        }

        private void btnSmoothImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            InputDialog inputDialog = new InputDialog("请输入采用的模板大小:", "模板大小", "3");

            inputDialog.ShowDialog();

            if (inputDialog.result != "")

            {

                int n = Convert.ToInt16(inputDialog.result);

                Bitmap bitmap = rgbBitmap.ToSmoothImage(n);

                ShowImage s = new ShowImage(bitmap, "平滑图片");

                s.Show();

            }

            else

            {

                MessageBox.Show("对不起,你的输入参数错误!");

            }

        }

        private void btnNeonImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            Bitmap bitmap = rgbBitmap.ToNeonImage();

            ShowImage s = new ShowImage(bitmap, "霓虹图片");

            s.Show();

        }

        private void btnSharpenImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            InputDialog inputDialog = new InputDialog("请输入锐化系数:", "输入参数", "0.25");

            inputDialog.ShowDialog();

            if (inputDialog.result != "")

            {

                double n = Convert.ToDouble(inputDialog.result);

                Bitmap bitmap = rgbBitmap.ToSharpeningImage(n);

                ShowImage s = new ShowImage(bitmap, "锐化图片");

                s.Show();

            }

            else

            {

                MessageBox.Show("对不起,你的输入参数错误!");

            }

        }

        private void btnReliefImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            InputDialog nn=new InputDialog ("输入浮雕值:","输入参数","128");

            nn.ShowDialog();

            if (nn.result != "")

            {

                int n = Convert.ToInt16(nn.result);

                Bitmap bitmap = rgbBitmap.ToReliefImage(n);

                ShowImage s = new ShowImage(bitmap, "浮雕图片");

                s.Show();

            }

            else

            {

                MessageBox.Show("对不起,你的输入参数错误!");

            }

        }

        private void btnMosaicImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            InputDialog nn=new InputDialog ("输入模板大小:","输入参数","3");

            nn.ShowDialog();

            if (nn.result != "")

            {

                int n = Convert.ToInt16(nn.result);

                Bitmap bitmap = rgbBitmap.ToMosaicImage(n);

                ShowImage s = new ShowImage(bitmap, "镶嵌图片");

                s.Show();

            }

            else

            {

                MessageBox.Show("对不起,你的输入参数错误!");

            }

        }

        private void btnTranslationImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            InputDialog nn=new InputDialog ("输入平移的像素数:","输入参数","20");

            nn.ShowDialog();

            if (nn.result != "")

            {

                int n = Convert.ToInt16(nn.result);

                Bitmap bitmap = rgbBitmap.TranslationImage(n);

                ShowImage s = new ShowImage(bitmap, "平移图片");

                s.Show();

            }

            else

            {

                MessageBox.Show("对不起,你的输入参数错误!");

            }

        }

        private void btnLargerImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            InputDialog nn=new InputDialog ("输入放大倍数:","输入参数","2");

            nn.ShowDialog();

            if (nn.result != "")

            {

                double n = Convert.ToDouble(nn.result);

                Bitmap bitmap = rgbBitmap.ResizeImage(n);

                ShowImage s = new ShowImage(bitmap, "放大图片");

                s.Show();

            }

            else

            {

                MessageBox.Show("对不起,你的输入参数错误!");

            }

        }

        private void btnSmallerImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            InputDialog nn=new InputDialog ("输入缩小倍数:","输入参数","0.5");

            nn.ShowDialog();

            if (nn.result != "")

            {

                double n = Convert.ToDouble(nn.result);

                Bitmap bitmap = rgbBitmap.ResizeImage(n);

                ShowImage s = new ShowImage(bitmap, "缩小图片");

                s.Show();

            }

            else

            {

                MessageBox.Show("对不起,你的输入参数错误!");

            }

        }

        private void btnLRFlipImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            Bitmap bitmap = rgbBitmap.LRFlipImage();

            ShowImage s = new ShowImage(bitmap, "左右翻转");

            s.Show();

        }

        private void btnUDFlipImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            Bitmap bitmap = rgbBitmap.UDFlipImage();

            ShowImage s = new ShowImage(bitmap, "上下翻转");

            s.Show();

        }

        private void ImageProcessor_Load(object sender, EventArgs e)

        {

            this.MaximumSize = new Size(this.Width, this.Height);

            this.MinimumSize = this.MaximumSize;

        }

        private void btnRotateImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            InputDialog nn=new InputDialog ("输入旋转度数:","输入参数","30");

            nn.ShowDialog();

            if (nn.result != "")

            {

                double n = Convert.ToDouble(nn.result);

                Bitmap bitmap = rgbBitmap.RotateImage(n);

                ShowImage s = new ShowImage(bitmap, "旋转图片");

                s.Show();

            }

            else

            {

                MessageBox.Show("对不起,你的输入参数错误!");

            }

        }

        private void btnHistImage_Click(object sender, EventArgs e)

        {

            RGBImage rgbBitmap = new RGBImage(bmp);

            Bitmap bitmap = rgbBitmap.HistImage();

            ShowImage s = new ShowImage(bitmap, "直方图");

            s.Show();

        }