資源簡介
C#圖像處理 灰度 拼接 銳化 平滑 灰度反轉 源碼簡單易學,很容易上手C#的圖像處理

代碼片段和文件信息
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?System.Drawing.Drawing2D;
using?System.Threading;
namespace?像素點處理
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????OpenFileDialog?imageopen?=?new?OpenFileDialog();
????????????imageopen.title?=?“請打開圖像文件“;
????????????imageopen.InitialDirectory?=?@“C:\Users\Administrator\Desktop“;
????????????imageopen.Filter?=?“(圖像文件)*.bmp;jepg;jpg;gif;png|*.bmp;*.jepg;*.jpg;*.gif;*.png“;
????????????imageopen.FilterIndex?=?1;
????????????imageopen.RestoreDirectory?=?true;
????????????if?(imageopen.ShowDialog()?==?DialogResult.OK)
????????????{
????????????????this.progressBar1.Value?=?100;
????????????????this.pictureBox1.Image?=?System.Drawing.Bitmap.FromFile(imageopen.FileName);
????????????}
????????}
????????private?void?button1_Click_1(object?sender?EventArgs?e)//灰度化一個圖像
????????{
????????????Form1?sample?=?new?Form1();
????????????ThreadStart?ts?=?new?ThreadStart(sample.XianC);
????????????Thread?t?=?new?Thread(ts);
????????????//?啟動.
????????????t.Start();
????????????Bitmap?bmp?=?(Bitmap)this.pictureBox1.Image;
????????????//Bitmap?bmp?=?new?Bitmap(@“C:\Users\Administrator\Desktop\a.jpg“);
???????????
????????????Rectangle?rect?=?new?Rectangle(0?0?bmp.Width?bmp.Height);//給定一個矩陣,括號里為對角線兩點的坐標
????????????System.Drawing.Imaging.BitmapData?bmpData?=?bmp.LockBits(rect?System.Drawing.Imaging.ImageLockMode.ReadWrite?bmp.PixelFormat);
????????????IntPtr?ptr?=?bmpData.Scan0;//獲取或設置位圖中第一個像素數據的地址。它也可以看成是位圖中的第一個掃描行。?
????????????int?bytes?=?bmp.Width?*?bmp.Height?*?3;//這是針對每像素24位圖的專用(3個字節)
????????????byte[]?rgbValues?=?new?byte[bytes];//聲明一個數組
????????????System.Runtime.InteropServices.Marshal.Copy(ptr?rgbValues?0?bytes);//把RGB空間的像素值COPY到這個數組
????????????double?colorTemp?=?0;
????????????/*for?(int?i?=?0;?i?????????????{
????????????????colorTemp?=?rgbValues[i?+?2]?*?0.299?+?rgbValues[i?+?1]?*?0.587?+?rgbValues[i]?*?0.114;
????????????????rgbValues[i]?=?rgbValues[i?+?1]?=?rgbValues[i?+?2]?=?(byte)colorTemp;
????????????}*/
????????????/*for?(int?counter?=?0;?counter?????????????????rgbValues[counter]?=?255;?//把紅色都改為255*/
????????????for?(int?counter?=?0;?counter?????????????{
????????????????//colorTemp?=?rgbValues[counter]?*?0.4;
????????????????//rgbValues[counter]?=?(byte)colorTemp;?//把0值都改為255
????????????????this.richTextBox1.Text?+=?Convert.ToString(rgbValues[counter])+“?“;
????????????????
????????????}
????????????this.progressBar1.Value?=?100;
????????????System.Runtime.InteropServices.Marsha
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????15360??2012-05-06?22:51??像素點處理\像素點處理\bin\Debug\像素點處理.exe
?????文件??????34304??2012-05-06?22:51??像素點處理\像素點處理\bin\Debug\像素點處理.pdb
?????文件??????11608??2012-05-07?13:23??像素點處理\像素點處理\bin\Debug\像素點處理.vshost.exe
?????文件????????490??2010-03-17?22:39??像素點處理\像素點處理\bin\Debug\像素點處理.vshost.exe.manifest
?????文件??????13655??2012-05-06?22:51??像素點處理\像素點處理\Form1.cs
?????文件??????11547??2012-05-06?22:51??像素點處理\像素點處理\Form1.Designer.cs
?????文件???????6020??2012-05-06?22:51??像素點處理\像素點處理\Form1.resx
?????文件???????6201??2012-05-06?22:51??像素點處理\像素點處理\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????534??2012-05-06?22:51??像素點處理\像素點處理\obj\x86\Debug\GenerateResource-ResGen.read.1.tlog
?????文件????????842??2012-05-06?22:51??像素點處理\像素點處理\obj\x86\Debug\GenerateResource-ResGen.write.1.tlog
?????文件???????1227??2012-05-07?13:23??像素點處理\像素點處理\obj\x86\Debug\像素點處理.csproj.FileListAbsolute.txt
?????文件??????15360??2012-05-06?22:51??像素點處理\像素點處理\obj\x86\Debug\像素點處理.exe
?????文件????????180??2012-05-06?22:51??像素點處理\像素點處理\obj\x86\Debug\像素點處理.Form1.resources
?????文件??????34304??2012-05-06?22:51??像素點處理\像素點處理\obj\x86\Debug\像素點處理.pdb
?????文件????????180??2012-03-28?22:37??像素點處理\像素點處理\obj\x86\Debug\像素點處理.Properties.Resources.resources
?????文件????????496??2012-03-28?22:27??像素點處理\像素點處理\Program.cs
?????文件???????1362??2012-03-28?22:27??像素點處理\像素點處理\Properties\AssemblyInfo.cs
?????文件???????2880??2012-03-28?22:27??像素點處理\像素點處理\Properties\Resources.Designer.cs
?????文件???????5612??2012-03-28?22:27??像素點處理\像素點處理\Properties\Resources.resx
?????文件???????1100??2012-03-28?22:27??像素點處理\像素點處理\Properties\Settings.Designer.cs
?????文件????????249??2012-03-28?22:27??像素點處理\像素點處理\Properties\Settings.settings
?????文件???????3582??2012-03-28?22:37??像素點處理\像素點處理\像素點處理.csproj
?????文件????????887??2012-03-28?22:27??像素點處理\像素點處理.sln
????..A..H.?????18944??2012-05-07?13:48??像素點處理\像素點處理.suo
?????目錄??????????0??2012-03-28?22:27??像素點處理\像素點處理\obj\x86\Debug\TempPE
?????目錄??????????0??2012-05-23?22:38??像素點處理\像素點處理\obj\x86\Debug
?????目錄??????????0??2012-05-23?22:38??像素點處理\像素點處理\bin\Debug
?????目錄??????????0??2012-05-23?22:38??像素點處理\像素點處理\obj\x86
?????目錄??????????0??2012-05-23?22:38??像素點處理\像素點處理\bin
?????目錄??????????0??2012-05-23?22:38??像素點處理\像素點處理\obj
............此處省略6個文件信息
評論
共有 條評論