亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? fft.cs

?? 2維fft用于數字圖像處理 C# dll裝配件
?? CS
字號:
using System;
using System.Drawing;


namespace MyApp.FFT
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	/// 	
	public class complexd
	{
		public double real;
		public double im;
		public complexd(double x,double y)
		{
			real=x;
			im=y;
		}
	}
	public class MyFFT
	{
		private int myHeight;
		private int myWidth;
		private double[][] BitIll;

		public MyFFT()
		{
			InitialBitIll();
		}
		private void InitialBitIll()
		{
			BitIll=new double[5][];
			BitIll[0]=new double[5];
			BitIll[0][0]=0;
			BitIll[0][1]=1;
			BitIll[0][2]=2;
			BitIll[0][3]=1;
			BitIll[0][4]=0;
			BitIll[1]=new double[5];
			BitIll[1][0]=1;
			BitIll[1][1]=4;
			BitIll[1][2]=8;
			BitIll[1][3]=4;
			BitIll[1][4]=1;
			BitIll[2]=new double[5];
			BitIll[2][0]=2;
			BitIll[2][1]=8;
			BitIll[2][2]=16;
			BitIll[2][3]=8;
			BitIll[2][4]=2;
			BitIll[3]=new double[5];
			BitIll[3][0]=1;
			BitIll[3][1]=4;
			BitIll[3][2]=8;
			BitIll[3][3]=4;
			BitIll[3][4]=1;
			BitIll[4]=new double[5];
			BitIll[4][0]=0;
			BitIll[4][1]=1;
			BitIll[4][2]=2;
			BitIll[4][3]=1;
			BitIll[4][4]=0;
			for(int i=0;i<5;i++)
				for(int j=0;j<5;j++)
				BitIll[i][j]=BitIll[i][j]/80;		
		}
		private complexd[][] GetBits(Bitmap myBitmap)
		{
			int height=myBitmap.Height;
			int width=myBitmap.Width;
			int nHeight=(int) Math.Pow(2,Math.Ceiling(Math.Log(height,2)));
			int nWidth=(int) Math.Pow(2,Math.Ceiling(Math.Log(width,2)));
			myHeight=height;
			myWidth=width;
			complexd[][] array=new complexd[nHeight][];
			int i,j;
			for(i=0;i<=nHeight-1;i++)
			{
				array[i]=new complexd[nWidth];
				for(j=0;j<=nWidth-1;j++)
				{
					if(i<height&&j<width)
						array[i][j]=new complexd(myBitmap.GetPixel(j,i).R,0);
					else array[i][j]=new complexd(0,0);
				}
			}
			return array;
		}
		private double[][] GetArray(Bitmap myBitmap)
		{
			int height=myBitmap.Height;
			int width=myBitmap.Width;

			double[][] array=new double[height][];
			int i,j;
			for(i=0;i<=height-1;i++)
			{
				array[i]=new double[width];
				for(j=0;j<=width-1;j++)
				{
					array[i][j]=myBitmap.GetPixel(j,i).R;
				}
			}
			return array;
		}
		private complexd Mux(complexd x1,complexd x2)
		{		
			double real=x1.real*x2.real-x1.im*x2.im;
			double im=x1.real*x2.im+x1.im*x2.real;
			complexd x=new complexd(real,im);
			return x;
		}
		private complexd Add(complexd x1,complexd x2)
		{
			complexd x=new complexd(0,0);
			x.real=x1.real+x2.real;
			x.im=x1.im+x2.im;
			return x;
		}
		private complexd Del(complexd x1,complexd x2)
		{
			complexd x=new complexd(0,0);
			x.real=x1.real-x2.real;
			x.im=x1.im-x2.im;
			return x;
		}
		private void BitReverse(int[] br, int m,int N)
		{
			for(int i=0;i<N;i++)
			{
				br[i]=i;
			}
			int lh=N/2;
			int j=lh;
			int n1=N-2;

			for(int i=1;i<=n1;i++)
			{
				if(i<j)
				{
					int t=br[i];
					br[i]=br[j];
					br[j]=t;
				}
				int k=lh;
				while(j>=k)
				{
					j=j-k;
					k/=2;
				}
				j=j+k;
			}
		}
		private complexd WNR(int N,int r)
		{
			double x=Math.Cos(((-2)*r*Math.PI)/N);
			double y=Math.Sin(((-2)*r*Math.PI)/N);
			complexd c=new complexd(x,y);
			return c;
		}
		private complexd IWNR(int N,int r)
		{
			double x=Math.Cos(((-2)*r*Math.PI)/N);
			double y=Math.Sin(((-2)*r*Math.PI)/N);
			complexd c=new complexd(x,y);
			return c;
		}
		private complexd[][] Rotate(complexd[][] array)
		{
			int n=array[0].Length;
			complexd[][] ar=new complexd[n][];
			for(int i=0;i<n;i++)
			{
				ar[i]=new complexd[array.Length];
				for(int j=0;j<array.Length;j++)
					ar[i][j]=array[j][i];
			}
			return ar;
		}
		private void Operate(complexd[] array,int i,int j,complexd W)
		{
			complexd ii=array[i];
			complexd jj=array[j];
			array[i]=Add(ii,Mux(W,jj));
			array[j]=Del(ii,Mux(W,jj));
		}
		private void FFT1(complexd[] array,int sig)
		{
			int Width=array.Length;
			int bit=(int)Math.Ceiling(Math.Log(Width,2))+1;
			int[] br=new int[Width];
			BitReverse(br,bit,Width);
			complexd[] ar=(complexd[])array.Clone();
			for(int i=0;i<Width;i++)
				array[i]=ar[br[i]];
			int m=(int) Math.Log(Width,2);
			
			for(int l=1;l<=m;l++)
			{
				int b=(int)Math.Pow(2,l-1);
				for(int j=0;j<=b-1;j++)
				{
					int r=(int)Math.Pow(2,m-l)*j;
					for (int k=j;k<=Width-1;k+=(int)Math.Pow(2,l))
					{
						complexd w;
						if(sig==0)
							w=WNR(Width,r);
						else w=IWNR(Width,r);
						Operate(array,k,k+b,w);
					}
				}
			}
			if(sig==1)
			{
				for(int i=0;i<Width;i++)
				{
					array[i].real=array[i].real/Width;
					array[i].im=array[i].im/Width;
				}
			}
		}
		private complexd[][] FFT2(complexd[][] PicData,int sig)
		{
			int height=PicData.Length;
			int width=PicData[0].Length;
			for(int i=0;i<height;i++)
				FFT1(PicData[i],sig);	
			PicData=Rotate(PicData);
			for(int i=0;i<width;i++)
				FFT1(PicData[i],sig);	
			PicData=Rotate(PicData);
			return PicData;
		}
		private complexd[][] FFT2(Bitmap myBitmap)
		{
			complexd[][] PicData=GetBits(myBitmap);
			PicData=FFT2(PicData,0);
			PicData=Array2Array(PicData);
			return PicData;
		}
		public Bitmap Butterworth(Bitmap myBitmap,double pass)
		{
			complexd[][] PicData=FFT2(myBitmap);
			Bitmap m=new Bitmap(PicData.Length,PicData[0].Length);
			//Bitmap m=new Bitmap(myHeight,myWidth);
			double tp=TotalPower(PicData);
			int D0=0;
			int M=m.Height;
			int N=m.Width;
			while(true)
			{
				if(PartPower(PicData,D0)/tp>=pass)
					break;
				else D0++;
			}
			complexd[][] f=new complexd[M][];

			for(int i=0;i<M;i++)
			{
				f[i]=new complexd[N];
				for(int j=0;j<N;j++)
				{
					double bt=Math.Sqrt(Math.Pow(Math.Abs(i-M/2),2)+Math.Pow(Math.Abs(j-N/2),2))/D0;
					bt=1/(1+Math.Pow(bt,2));
					f[i][j]=new complexd(PicData[i][j].real*bt,PicData[i][j].im*bt);
				}
			}
			f=Array2Array(f);
			f=FFT2(f,1);
			for(int i=0;i<M;i++)
				for(int j=0;j<N;j++)
				{
					int c=(int)r2(f[i][j]);
					if(c>255) c=255;
					if(c<0) c=0;
					m.SetPixel(j,i,Color.FromArgb(c,c,c));
				}
			m.RotateFlip(RotateFlipType.Rotate180FlipNone);
			Rectangle rect=new Rectangle(0,0,myWidth,myHeight);
			m=m.Clone(rect,m.PixelFormat);
			return m;
		}

		public Bitmap IdealLowPass(Bitmap myBitmap,double pass)
		{
			complexd[][] PicData=FFT2(myBitmap);
			Bitmap m=new Bitmap(PicData.Length,PicData[0].Length);
			double tp=TotalPower(PicData);
			int D0=0;
			int M=PicData.Length;
			int N=PicData[0].Length;
			while(true)
			{
				if(PartPower(PicData,D0)/tp>=pass)
					break;
				else D0++;
			}
			complexd[][] f=new complexd[M][];

			for(int i=0;i<M;i++)
			{
				f[i]=new complexd[N];
				for(int j=0;j<N;j++)
				{
					f[i][j]=new complexd(0,0);
					if((Math.Pow(Math.Abs(i-M/2),2)+Math.Pow(Math.Abs(j-N/2),2))<=D0*D0)
					{
						f[i][j]=PicData[i][j];
					}
				}
			}
			f=Array2Array(f);
			f=FFT2(f,1);
			for(int i=0;i<m.Height;i++)
				for(int j=0;j<m.Width;j++)
				{
					int c=(int)r2(f[i][j]);
					if(c>255) c=255;
					if(c<0) c=0;
					m.SetPixel(j,i,Color.FromArgb(c,c,c));
				}
			m.RotateFlip(RotateFlipType.Rotate180FlipNone);
			Rectangle rect=new Rectangle(0,0,myWidth,myHeight);
			m=m.Clone(rect,m.PixelFormat);
			return m;
		}
		private double TotalPower(complexd[][] array)
		{
			double re=0;
			for(int i=0;i<array.Length;i++)
				for(int j=0;j<array[0].Length;j++)
				{
					double f=r2(array[i][j]);
					re+=f*f;
				}
			return re;
		}
		private double PartPower(complexd[][] array,int D0)
		{
			double re=0;
			int M=array.Length;
			int N=array[0].Length;
			for(int i=0;i<array.Length;i++)
				for(int j=0;j<array[0].Length;j++)
				{
					if((Math.Pow(Math.Abs(i-M/2),2)+Math.Pow(Math.Abs(j-N/2),2))<=D0*D0)
					{
						double f=r2(array[i][j]);
						re+=f*f;
					}
				}
			return re;
		}
		public complexd[][] Array2Array(complexd[][] array)
		{
			
			int M=array[0].Length;
			int N=array.Length;
			complexd[][] re=new complexd[N][];
			for(int i=0;i<N/2;i++)
			{
				re[i]=new complexd[M];
				for(int j=0;j<M/2;j++)//1
				{
					re[i][j]=array[i+N/2][j+M/2];
				}
				for(int j=M/2;j<M;j++)//2
				{
					re[i][j]=array[i+N/2][j-M/2];
				}
			}
			for(int i=N/2;i<N;i++)//4
			{
				re[i]=new complexd[M];
				for(int j=0;j<M/2;j++)
				{
					re[i][j]=array[i-N/2][j+M/2];
				}
				for(int j=M/2;j<M;j++)
				{
					re[i][j]=array[i-N/2][j-M/2];
				}
			}
			return re;
		}
		
		private double r2(complexd c)
		{
			return Math.Sqrt(c.real*c.real+c.im*c.im);
		}
		public Bitmap GetFFTPic(Bitmap myBitmap)
		{
			complexd[][] PicData=GetBits(myBitmap);
			PicData=FFT2(PicData,0);
			complexd[][] PicData1=Array2Array(PicData);
			double[][] data=GetPowerData(PicData1);
			double[] maxmin=GetMaxMinData(data);
			maxmin[0]=(int)Math.Log(1+maxmin[0],Math.E);
			maxmin[1]=(int)Math.Log(1+maxmin[1],Math.E);
			Bitmap m=new Bitmap(PicData1.Length,PicData1[0].Length);
			for(int i=0;i<m.Height;i++)
				for(int j=0;j<m.Width;j++)
				{
					int c=(255/(int)(maxmin[0]-maxmin[1]))*((int)Math.Log(1+data[i][j],Math.E));
					if(c>255) c=255;
					if(c<0) c=0;
					m.SetPixel(j,i,Color.FromArgb(c,c,c));
				}
			return m;
		}
		private double[][] GetPowerData(complexd[][] array)
		{
			double[][] re=new double[array.Length][];
			for(int i=0;i<array.Length;i++)
			{
				re[i]=new double[array[0].Length];
				for(int j=0;j<array[0].Length;j++)
				{
					re[i][j]=r2(array[i][j]);
				}
			}
			return re;
		}
		private double[] GetMaxMinData(double[][] array)
		{
			double[] re=new double[2];
			re[0]=array[0][0];
			re[1]=array[0][0];
			for(int i=0;i<array.Length;i++)
				for(int j=0;j<array[0].Length;j++)
				{
					if(array[i][j]>re[0]) re[0]=array[i][j];
					else re[1]=array[i][j];
				}
			return re;		
		}
		public double GetError(Bitmap myBitmap1,Bitmap myBitmap2)
		{
			double[][] array1=GetArray(myBitmap1);
			double[][] array2=GetArray(myBitmap2);
			double re=0;
			for(int i=0;i<=array1.Length-1;i++)
				for(int j=0;j<=array1[0].Length-1;j++)
				{
					re+=Math.Pow((array1[i][j]-array2[i][j]),2);
				}
			re=re/(array1.Length*array1[0].Length);
			re=Math.Sqrt(re);
			return re;
		}
		
		private double GetError(double[][] array1,double[][] array2)
		{
			double re=0;
			for(int i=0;i<=array1.Length-1;i++)
				for(int j=0;j<=array1[0].Length-1;j++)
				{
					re+=Math.Pow((array1[i][j]-array2[i][j]),2);
				}
			re=re/(array1.Length*array1[0].Length);
			re=Math.Sqrt(re);
			return re;
		}
		


	}
	
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区免费| 欧美午夜片在线观看| 午夜精品久久久久久不卡8050| 国产精品午夜在线| 久久久久久久久97黄色工厂| 26uuu国产在线精品一区二区| 欧美高清视频不卡网| 欧美精品日韩一本| 欧美理论在线播放| 欧美成人a在线| www国产精品av| 中文字幕一区二区在线观看| 亚洲天堂精品视频| 一区二区三区**美女毛片| 一区二区三区四区蜜桃| 天天做天天摸天天爽国产一区 | 欧美日韩亚洲另类| 欧美老年两性高潮| 精品久久人人做人人爰| 国产精品丝袜黑色高跟| 亚洲人成影院在线观看| 亚洲成人手机在线| 国产麻豆日韩欧美久久| av一区二区三区四区| 欧美性xxxxx极品少妇| 在线观看91av| 中文无字幕一区二区三区| 亚洲精品视频在线看| 免费成人小视频| 成人美女视频在线观看| 欧美日韩综合色| 久久精品一区二区三区不卡| 亚洲精品国产成人久久av盗摄 | 国产精品一级二级三级| 99精品视频一区| 日韩视频免费观看高清完整版在线观看 | 欧美影院精品一区| 欧美精品一区二区三区一线天视频 | 蜜桃视频一区二区| 色先锋资源久久综合| 欧美成va人片在线观看| 一区二区三区国产精华| 国产精品一区久久久久| 欧美久久免费观看| 国产精品麻豆视频| 久久精品国产精品亚洲红杏 | 一区二区三区高清| 国产成人av在线影院| 欧美精品久久一区| 亚洲免费av观看| 粉嫩蜜臀av国产精品网站| 欧美精品xxxxbbbb| 亚洲美女偷拍久久| 成人小视频在线| 久久亚洲一区二区三区明星换脸| 亚洲一区在线观看视频| www.亚洲精品| 国产精品免费av| 国产麻豆视频一区| 26uuuu精品一区二区| 久久99国产精品久久99果冻传媒| 欧美在线免费播放| 依依成人精品视频| 91丝袜美女网| 最新欧美精品一区二区三区| 成人免费高清在线观看| 久久久国产精品不卡| 激情久久久久久久久久久久久久久久| 欧美视频在线一区| 亚洲午夜激情网页| 欧美精品电影在线播放| 肉丝袜脚交视频一区二区| 欧美亚洲国产bt| 亚洲午夜国产一区99re久久| 欧美日韩亚洲综合一区二区三区| 一区二区三区四区五区视频在线观看| 97se亚洲国产综合自在线观| 亚洲人精品一区| 色8久久人人97超碰香蕉987| 亚洲宅男天堂在线观看无病毒| 色婷婷亚洲综合| 午夜久久久影院| 91精品在线麻豆| 激情综合色播激情啊| 久久久无码精品亚洲日韩按摩| 国产精品一区二区在线观看不卡| 国产日产亚洲精品系列| av不卡免费电影| 亚洲午夜在线观看视频在线| 欧美喷水一区二区| 国内精品久久久久影院薰衣草| 精品国产乱码久久久久久久久| 国内精品伊人久久久久影院对白| 国产婷婷色一区二区三区| 不卡电影免费在线播放一区| 亚洲一区在线观看网站| 日韩免费电影一区| 成人午夜视频网站| 亚洲午夜精品网| 精品国产伦一区二区三区观看体验| 国产激情视频一区二区在线观看| 亚洲欧洲在线观看av| 欧美另类变人与禽xxxxx| 国产在线播放一区二区三区| 最新不卡av在线| 日韩欧美一级片| av激情综合网| 美女脱光内衣内裤视频久久网站 | 亚洲柠檬福利资源导航| 91精品国产入口| 成人丝袜18视频在线观看| 亚洲一区二区三区中文字幕在线| 日韩一区二区三区在线视频| 成人综合激情网| 日本亚洲免费观看| 亚洲视频网在线直播| 欧美一区二区三区视频在线观看| 国产美女精品人人做人人爽 | 日韩女优av电影| 99re热这里只有精品免费视频| 日本视频一区二区| 亚洲欧美精品午睡沙发| 久久久久久久久蜜桃| 欧美日韩中文一区| a4yy欧美一区二区三区| 久久精品国产亚洲aⅴ| 亚洲一区二区综合| 亚洲欧美日韩久久| 久久综合九色综合欧美98 | 成人高清视频免费观看| 蜜臀av亚洲一区中文字幕| 亚洲免费观看高清在线观看| 久久久久亚洲蜜桃| 欧美mv日韩mv国产网站| 51精品视频一区二区三区| 色综合一个色综合| 9久草视频在线视频精品| 韩国视频一区二区| 免费看欧美女人艹b| 五月天久久比比资源色| 亚洲精品欧美激情| 亚洲色欲色欲www在线观看| 中文字幕不卡的av| 久久精品一级爱片| 国产日韩欧美精品电影三级在线| 日韩视频免费观看高清完整版在线观看 | 色婷婷精品大视频在线蜜桃视频| 国产一区二区三区不卡在线观看 | 成人黄色av网站在线| 国产精品香蕉一区二区三区| 精品影视av免费| 国模无码大尺度一区二区三区| 美女在线视频一区| 精品一区二区三区日韩| 精品一区二区三区在线播放视频| 日本成人在线看| 久久精品国产精品亚洲精品| 久久激五月天综合精品| 久久99精品国产麻豆婷婷| 狠狠色丁香婷综合久久| 国产麻豆精品一区二区| 国产91精品久久久久久久网曝门| 国产成人av影院| 91色九色蝌蚪| 欧美色图激情小说| 欧美成人综合网站| 国产三级三级三级精品8ⅰ区| 国产人伦精品一区二区| 亚洲色欲色欲www在线观看| 亚洲黄色片在线观看| 五月天亚洲婷婷| 国产一区二区成人久久免费影院| 国产不卡在线一区| 日本高清不卡aⅴ免费网站| 欧美人伦禁忌dvd放荡欲情| 欧美成人女星排名| ...av二区三区久久精品| 丝袜美腿亚洲一区二区图片| 国产自产高清不卡| 色悠久久久久综合欧美99| 欧美一级片免费看| 中文字幕av资源一区| 亚洲一区在线视频| 国产成人高清视频| 欧美日韩国产欧美日美国产精品| 精品欧美一区二区在线观看| 国产精品短视频| 蜜桃久久av一区| 色噜噜狠狠成人网p站| 精品久久五月天| 一区二区三区四区不卡视频| 精品一区二区三区免费观看| 成人的网站免费观看| 欧美一区二区啪啪| 亚洲欧美偷拍卡通变态| 国产一区二区福利| 欧美疯狂做受xxxx富婆| 中文字幕一区av| 国产在线精品免费| 欧美日韩激情一区二区三区|