02 2012 档案

摘要:cl;m=31;n=31;img=zeros(m+1,n+1);img=double(img);pi=3.1415926;sigma=10;for i=-(m/2):m/2 for j=-(n/2):n/2 img(i+m/2+1,j+n/2+1)=(1/(2*pi*sigma*sigma))*exp(-(i*i+j*j)/(2*sigma*sigma)); endendimg=mat2gray(img);imshow(img);imwrite(img,'pic.bmp');%一个更好的实现,2012.12.18修改h=5;w=2;[x y]=meshgrid(-w... 阅读全文
posted @ 2012-02-26 12:53 Dsp Tian 阅读(8861) 评论(3) 推荐(1) 编辑
摘要:cl;raw=zeros(200,256,30);for i=1:30 filename=strcat('F:\算法实验\data\seq3\',int2str(i),'.bmp'); raw(:,:,i)=imread(filename);end方法二:cl;img=cell(1,30);for i=1:30 filename=strcat('F:\算法实验\data\seq3\',int2str(i),'.bmp'); img{i}=imread(filename);end 阅读全文
posted @ 2012-02-23 15:57 Dsp Tian 阅读(6175) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <time.h>#include <stdlib.h>using namespace std;int random(int a,int b){ srand(NULL); return rand()%(b-a)+a;}void exchange(int &a,int &b){ int temp; temp=a; a=b; b=temp;}int partition(int *a,int p,int r){ int x=a[r]; int i=p-1; for (int j=p;j<r 阅读全文
posted @ 2012-02-20 14:07 Dsp Tian 阅读(644) 评论(0) 推荐(0) 编辑
摘要://元素只能为正整数#include <iostream>using namespace std;int Max(int *a,int length){ int temp=-1000; for (int i=0;i<length;i++) if (temp<a[i]) temp=a[i]; return temp;}void counting_sort(int *a,int *b,int k,int length){ int *c; c=(int*)malloc(sizeof(int)*(k+1)); for (int i... 阅读全文
posted @ 2012-02-19 14:03 Dsp Tian 阅读(452) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <time.h>#include <stdlib.h>using namespace std;int random(int a,int b){ srand(NULL); return rand()%(b-a)+a;}void exchange(int &a,int &b){ int temp; temp=a; a=b; b=temp;}int partition(int *a,int p,int r){ int x=a[r]; int i=p-1; for (int j=p;j<r 阅读全文
posted @ 2012-02-18 21:31 Dsp Tian 阅读(579) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>using namespace std;void exchange(int &a,int &b){ int temp; temp=a; a=b; b=temp;}int partition(int *a,int p,int r){ int x=a[r]; int i=p-1; for (int j=p;j<r;j++) { if (a[j]<=x) { i=i+1; exchange(a[i],a[j]); } } ... 阅读全文
posted @ 2012-02-18 21:14 Dsp Tian 阅读(599) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>using namespace std;int parent(int i){ return i/2;}int left(int i){ return 2*i;}int right(int i){ return 2*i+1;}void exchange(int &a,int &b){ int temp; temp=a; a=b; b=temp;}//但就算法来看,heap_size(堆的大小)设为全局变量也许会好一些void max_heapify(int *a,int i,int heap_size){ in... 阅读全文
posted @ 2012-02-17 21:46 Dsp Tian 阅读(446) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>using namespace std;int main(){ int b[]={1,2,3}; int *a; a=(int*)malloc(sizeof(int)*3); memcpy(a,b,sizeof(int)*3); for (int i=0;i<3;i++) cout<<a[i]<<""; cout<<endl; system("pause"); free(a); return 0;} 阅读全文
posted @ 2012-02-17 21:36 Dsp Tian 阅读(494) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>using namespace std;void process(int *a){ a=(int*)realloc(a,sizeof(int)*4); a[3]=3;}int main(){ int *a; a=(int*)malloc(sizeof(int)*3); a[0]=0; a[1]=1; a[2]=2; process(a); for (int i=0;i<4;i++) cout<<a[i]<<""; cout<<endl; system("pause" 阅读全文
posted @ 2012-02-17 21:17 Dsp Tian 阅读(488) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <time.h>#include <stdlib.h>using namespace std;int random(int a,int b){ srand(NULL); return rand()%(b-a)+a;}void exchange(int &a,int &b){ int temp; temp=a; a=b; b=temp;}int main(){ int a[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14}; int length=sizeof(a)/ 阅读全文
posted @ 2012-02-17 19:00 Dsp Tian 阅读(551) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>using namespace std;int parent(int i){ return i/2;}int left(int i){ return 2*i;}int right(int i){ return 2*i+1;}void exchange(int &a,int &b){ int temp; temp=a; a=b; b=temp;}void max_heapify(int *a,int i,int heap_size){ int l=left(i); int r=right(i); i... 阅读全文
posted @ 2012-02-17 18:59 Dsp Tian 阅读(455) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <cmath>#include <vector>using namespace std;void main(){ double area=50; double R=0; int line; cin>>line; int i; double x,y; vector<double> dist; vector<double>::iterator dit; vector<int> res; vector<int>::iterator rit; for 阅读全文
posted @ 2012-02-09 17:23 Dsp Tian 阅读(438) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <vector>using namespace std;void main(){ int i; int month=12; double mean=0; double num; vector<double> vect; vector<double>::iterator vit; for (i=0;i<month;i++) { cin>>num; vect.push_back(num); } for (vit=vect.begin();vit!=vect... 阅读全文
posted @ 2012-02-09 15:25 Dsp Tian 阅读(484) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <string>using namespace std;void main(){ string card="card(s)"; double num=2; double res=0; double end; cin>>end; int what=0; while (res<=end) { res+=1/(num++); what++; } if (end>0) cout<<what<<" "<<card<< 阅读全文
posted @ 2012-02-09 15:10 Dsp Tian 阅读(398) 评论(0) 推荐(0) 编辑
摘要:#pragma warning (disable:4786)#include <iostream>#include <map>#include <algorithm>#include <string>#include <vector>using namespace std;typedef struct { string first; int second;}res;bool less_first(res tmp1,res tmp2){ return tmp1.first<tmp2.first;}bool my_equal(res 阅读全文
posted @ 2012-02-09 13:12 Dsp Tian 阅读(482) 评论(0) 推荐(0) 编辑
摘要:#include <string.h>#include <vector>#include <algorithm>#include <string>#include <iostream>using namespace std;void main(){ string m("----------asdfas--------------dfgdf---------"); string::iterator it; vector<char> csr; vector<char>::iterator cit 阅读全文
posted @ 2012-02-09 01:03 Dsp Tian 阅读(690) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <vector>#include <string>#include <algorithm>using namespace std;void main(){ string num; string strset1="."; string strset2="0"; int n; int wei; int sum_wei; cin>>num>>n; int first=num.find_first_of(strset1); if (fi 阅读全文
posted @ 2012-02-08 20:56 Dsp Tian 阅读(448) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>using namespace std; void main(){ int a,b; cin>>a>>b; cout<<a+b<<endl;} 阅读全文
posted @ 2012-02-08 15:25 Dsp Tian 阅读(393) 评论(0) 推荐(0) 编辑
摘要:#include <string>#include <iostream>#include <algorithm>#include <vector>#include <fstream>using namespace std;int main(){ ifstream in("data.txt"); string strtmp; vector<string> vect; while (getline(in,strtmp,'\n')) vect.push_back(strtmp); copy(v 阅读全文
posted @ 2012-02-08 13:18 Dsp Tian 阅读(629) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <vector>#include <algorithm>using namespace std;int testscore[] = {67, 56, 24, 78, 99, 87, 56}; void main(){ vector<int> score(testscore,testscore+sizeof(testscore)/sizeof(int)); vector<int>::iterator it; copy(score.begin(),score.end(),ostrea 阅读全文
posted @ 2012-02-08 00:00 Dsp Tian 阅读(649) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <vector>#include <algorithm>#include <numeric>#include <string>using namespace std;int testscore[] = {67, 56, 24, 78, 99, 87, 56}; bool pass(int n){ if (n>=60) return true; else return false;}void main(){ vector<int> score(testscore, 阅读全文
posted @ 2012-02-07 21:27 Dsp Tian 阅读(792) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <vector>#include <string>#include <boost/shared_ptr.hpp>class A{public: A(std::string s){a=s;} std::string a; void print(){std::cout<<a<<'\n';} };void main(){ boost::shared_ptr<A> p1(new A("2345")); boost::shared 阅读全文
posted @ 2012-02-07 17:52 Dsp Tian 阅读(562) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <string>#include <boost/lexical_cast.hpp>using namespace std;using namespace boost;int main(){ string i; try { i=lexical_cast<string>(123.134); } catch(bad_lexical_cast&e) { cout<<e.what()<<endl; return 1; } cout<<i<<end 阅读全文
posted @ 2012-02-06 22:01 Dsp Tian 阅读(742) 评论(0) 推荐(0) 编辑
摘要:cl;img=imread('1.bmp');[m n]=size(img);imshow(img)imgn=img;temp=[];%开操作for i=2:m-1 %腐蚀 for j=2:n-1 temp=img(i-1:i+1,j-1:j+1); imgn(i,j)=min(temp(:)); endendfor i=2:m-1 %膨胀 for j=2:n-1 temp=img(i-1:i+1,j-1:j+1); imgn(i,j)=max(... 阅读全文
posted @ 2012-02-05 19:45 Dsp Tian 阅读(2272) 评论(0) 推荐(0) 编辑
摘要:cl;img_gray=imread('fupeng.jpg');img_erzhi=imread('erzhi_fupeng.jpg');imshow(img_gray)figure,imshow(img_erzhi)[m n]=size(img_gray);img_gray_fu=zeros(m,n);img_gray_peng=zeros(m,n);img_erzhi_fu=zeros(m,n);img_erzhi_peng=zeros(m,n);for i=2:m-1 for j=2:n-1 img_gray_fu(i,j)=min(min(img_gr 阅读全文
posted @ 2012-02-05 16:02 Dsp Tian 阅读(11978) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <stdlib.h>#include <time.h>using namespace std;#define NUM 30 //区间个数typedef struct { int min; //区间中最小值 int max; //区间中最大值 int diff; //区间的大小}extent;int Max(int a,int b){ if (a>=b) { return a... 阅读全文
posted @ 2012-02-03 15:17 Dsp Tian 阅读(1237) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>using namespace std;int main(){ int a[9]={2,8,1,7,5,6,9,3,0}; int b[10]; int i; for (i=0;i<10;i++) { b[i]=-1; } for (i=0;i<9;i++) { b[a[i]]=a[i]; } for (i=0;i<10;i++) { if (b[i]==-1) { cout<<i<<endl; ... 阅读全文
posted @ 2012-02-03 13:33 Dsp Tian 阅读(514) 评论(0) 推荐(0) 编辑
摘要:cl;img=imread('1.bmp');img=double(img);imshow(mat2gray(img));[m n]=size(img);imgn=zeros(m-3,n-3);temp=[];for i=1:m-3 for j=1:n-3 temp=img(i:i+3,j:j+3); imgn(i,j)=median(temp(:)); endendfigure,imshow(mat2gray(imgn))imgn=img(1:m-3,1:n-3)-imgn;figure,imshow(mat2gray(imgn))imgn=i... 阅读全文
posted @ 2012-02-02 13:09 Dsp Tian 阅读(2091) 评论(2) 推荐(0) 编辑
摘要:#include <iostream>#include <string>#include <fstream>#include <iomanip>using namespace std;int main(){ ofstream fs("123.txt",ios::app); fs<<setw(7)<<"234234"<<setw(3)<<"12"<<endl; system("pause"); return 0 阅读全文
posted @ 2012-02-01 17:24 Dsp Tian 阅读(539) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示