image moment normalization

asked 2014-05-07 00:01:58 -0600

Yasmin93 gravatar image

I am doing a sign language to voice recognition ,i am using normalized moments to compare databse images and captured frame , moments are used to calculate the orientation of the image and rotate it so that between orientation and reference angle there's a 5 degree difference ,i am following the method in this thesis link text more explaination of normalizarion is from page 28 to 30 .

The problem is when i am trying to implement the code the results are as follows inputapplying contrast and thresholding first rotation and flipping !second rotation3rd rotation

when trying to compare the final result with an image captured by subtracting pixels and defining a threshold value of 80 percent , only input images which are the same give the correct answer , so the problem is in the normalization part but i can't identify how to improve it

this is the normalization method ::


   int normalize2 (const char * imageDB) 
{ 
FILE *fp; 
IplImage* pic1=0 , *pic2=0 , *tempT=0, *tempDB=0 , *temp3=0 , *temp4=0; 
double u11 , u20 , u02 , theta1=0 , compare=0, theta2=0 , theta3=0 , theta=0, ratio=0; 
//int h= 100 , w= 100 ;          // Parameters needed for rotation 
int a=0 , bright=0 , pixel1 =0 , pixel2 =0; 
int threshold = 80 , id=0 , i=0; 
CvMoments moments; 


cvNamedWindow("Tobe_Modified",1); 
cvMoveWindow( "Tobe_Modified", 0, 50); 
cvNamedWindow("final",1); 
cvMoveWindow( "final", 500, 50); 
cvNamedWindow("compare",1);
cvMoveWindow( "compare", 250, 400);


 imageDB="hand.jpg";   

const char * name=0; 

pic2 = cvLoadImage(imageDB,0); 
tempDB = cvCreateImage( cvGetSize(pic2), IPL_DEPTH_8U, 1 ); 
tempDB = cvLoadImage(imageDB,0); 
//cvResize(tempT,tempDB, CV_INTER_AREA);  // Normalize SIZE to standard size of Temp2
int w= cvGetSize(pic2).width/2;    //Set rotation axes from size of image 
int h=cvGetSize(pic2).height/2;


cout<<"widthis"<<w<<"heght is "<<h<<endl;

cvSmooth(tempDB,tempDB,CV_GAUSSIAN,1,1);
ContrastBrightness(tempDB,40,10);
cvThreshold(tempDB,tempDB,100,255,CV_THRESH_BINARY);
cvSaveImage("afternorm.jpg",tempDB);
int f= cvCountNonZero(tempDB);
cout<<f<<"Non Zero Pixels in TEST"<<endl;
GetRotatedImage(tempDB,0,h,w);

cout<<"done first rotation\n"<<endl;

cvSaveImage("FirstRotation.jpg",tempDB);

cvFlip(tempDB,tempDB);
theta1=0;
cout<<"Angle of first image "<<theta1<<endl;

cvShowImage("Tobe_Modified",tempDB);
cvMoments( tempDB, &moments, 1 );   

u11=cvGetCentralMoment( &moments, 1,1 ); 
u20=cvGetCentralMoment( &moments, 2,0 ); 
u02=cvGetCentralMoment( &moments, 0,2 ); 
/////////////////////////////////////// EQ 1 //////////////////////////////////////////////////
theta=2*u11/(u20-u02); 

cout <<" The ANGLE theta in radians  = " <<theta <<endl; 
theta = 180*theta/pi;
cout <<" The ANGLE theta in degree  = " <<theta <<endl; 

if ((theta >=0) & (theta <=pi)) {
//Page 65of 83 
theta2 = 0.5*atan(2*u11/(u20-u02));
cout<<"1"<<endl;
cout<<theta2<<"theta2 in radians in 1st cond"<<endl;
}
else {
if ((theta > pi) & (theta < 1.5*pi)) {
    cout<<"2"<<endl;
    theta2 = 0.5*(atan(2*u11/(u20-u02)) + pi);
cout<<theta2<<"theta2 in radians in 2nd cond"<<endl;
}
else{ 
    cout<<"3"<<endl;
theta2 = 0.5*(atan(2*u11/(u20-u02))+2*pi) ; 
cout<<theta2<<"theta2 in radians in 3rd cond"<<endl;
 }

}
theta2 = 180*theta2/pi;
cout <<"angle theta2 of secnod image in degrees = " <<theta2 <<endl; 


while ( (theta2-theta1 > 3 || theta2-theta1 <- 3) & (a < 360) || (theta1>0) & 
(theta2<0) || (theta1<0) & (theta2>0)) 
{ 
    printf("error b4 2nd rota \n");
tempDB ...
(more)
edit retag flag offensive close merge delete

Comments

Basically you want us to fix your master thesis for you which you created copying a master thesis of someone else? Guess that a no go and exactly why someone already downvoted this. Don't expect us to go read other peoples thesis to understand the problem...

StevenPuttemans gravatar imageStevenPuttemans ( 2014-05-07 04:32:44 -0600 )edit

well actually i am not copying anything , i am trying to understand a method in the thesis , and i put the link only if more info is needed ! and i provided the number f pages and another equations that if found from a book .

Yasmin93 gravatar imageYasmin93 ( 2014-05-07 17:10:26 -0600 )edit