Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
3Activity
0 of .
Results for:
No results containing your search query
P. 1
Code xu ly anh

Code xu ly anh

Ratings: (0)|Views: 39 |Likes:
Published by maivcong

More info:

Published by: maivcong on Sep 10, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

11/28/2012

pdf

text

original

 
Câu 1. Xây dựng và cài đặt thuật toán làm âm ảnh.
 
void Negatives(IplImage *imgin, IplImage *imgout){cvNot(imgin, imgout);}voidHistogramEqualization(IplImage *imgin, IplImage *imgout){cvEqualizeHist(imgin,imgout);}
 
voidHistogramOpenCV(IplImage *imgin,doublep[L]) {inthistSize[] = {L};floathranges[] = {0,L-1};float* ranges[] = {hranges};CvHistogram* hist;hist = cvCreateHist(1,histSize,CV_HIST_ARRAY,ranges);cvCalcHist(&imgin,hist);cvNormalizeHist(hist,1.0);intr;for(r=0; r<L; r++)p[r] = cvQueryHistValue_1D(hist,r);cvReleaseHist(&hist);return;}voidLocalHistogramCV(IplImage *imgin, IplImage *imgout){intm = 3, n = 3;CvMat *w1 = cvCreateMat(m,n,CV_8UC1);CvMat *w2 = cvCreateMat(m,n,CV_8UC1);intM = cvGetSize(imgin).height;intN = cvGetSize(imgin).width;intx, y, a, b, s, t;a = m/2; b = n/2;CvScalar value;for(x=a; x<M-a; x++)for(y=b; y<N-b; y++) {for(s=-a; s<=a; s++)for(t=-b; t<=b; t++) {value = cvGet2D(imgin,x+s,y+t);cvSet2D(w1,s+a,t+b,value);}cvEqualizeHist(w1,w2);value = cvGet2D(w2,a,b);cvSet2D(imgout,x,y,value);
 
}cvReleaseMat(&w1);cvReleaseMat(&w2);return;}voidHistogramStatistics(IplImage *imgin, IplImage *imgout){intm = 3, n = 3;CvMat *w = cvCreateMat(m,n,CV_8UC1);inta = m/2, b = n/2;intN = cvGetSize(imgin).width;intM = cvGetSize(imgin).height;CvScalar mG,sigmaG;CvScalar msxy, sigmasxy;cvAvgSdv(imgin,&mG,&sigmaG);intx,y,s,t;doubleE = 4.0, k0 = 0.4, k1 = 0.02, k2 = 0.4;CvScalar value;for(x=a; x<M-a; x++)for(y=b; y<N-b; y++) {for(s=-a; s<=a; s++)for(t=-b; t<=b; t++) {value = cvGet2D(imgin,x+s,y+t);cvSet2D(w,s+a,t+b,value);}cvAvgSdv(w,&msxy,&sigmasxy);value = cvGet2D(imgin,x,y);if((msxy.val[0] < k0*mG.val[0]) && (k1*sigmaG.val[0] <=sigmasxy.val[0] && sigmasxy.val[0] <= k2*sigmaG.val[0]))value.val[0] *= E;cvSet2D(imgout,x,y,value);}cvReleaseMat(&w);return;}
Câu 9:
 voidSmoothLinearFilterOld(IplImage *imgin, IplImage *imgout){intm = 35, n = 35;CvMat *w = cvCreateMat(m,n,CV_32FC1);intx, y;CvScalar value;for(x=0; x<m; x++)for(y=0; y<n; y++) {value.val[0] = 1.0/(m*n);cvSet2D(w,x,y,value);}cvFilter2D(imgin,imgout,w);cvReleaseMat(&w);return;
 
}Ho
c:cvSmooth(imgin,imgout,CV_BLUR,15,15);
Câu 10:
 cvSmooth(imgin,imgout,CV_MEDIAN,3);voidGradient(IplImage *imgin, IplImage *imgout){IplImage *gx = cvCreateImage(cvGetSize(imgin),IPL_DEPTH_32F,1);IplImage *gy = cvCreateImage(cvGetSize(imgin),IPL_DEPTH_32F,1);IplImage *Mag = cvCreateImage(cvGetSize(imgin),IPL_DEPTH_32F,1);intM = cvGetSize(imgin).height;intN = cvGetSize(imgin).width;intx, y;for(x=0; x<M; x++)for(y=0; y<N; y++){cvSet2D(gx,x,y,cvGet2D(imgin,x,y));cvSet2D(gy,x,y,cvGet2D(imgin,x,y));}intm = 3, n = 3;CvMat *Sobelx = cvCreateMat(m,n,CV_32FC1);CvMat *Sobely = cvCreateMat(m,n,CV_32FC1);CvScalar value;CvScalar *valueArr =newCvScalar[9];intarr1[3][3] = {{-1,-2,-1},{0,0,0},{1,2,1}};intarr2[3][3] = {{-1,0,1}, {-2,0,2},{-1,0,1}};value.val[0] = 1;value.val[0] = 1;cvSet2D(Sobelx,0,0,value);for(x=0; x<m; x++)for(y=0; y<n; y++){value.val[0] = arr1[x][y];cvSet2D(Sobelx,x,y,value);value.val[0] = arr2[x][y];cvSet2D(Sobely,x,y,value);}cvFilter2D(gx,gx,Sobelx);cvFilter2D(gy,gy,Sobely);

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->