1,105,332 Community Members

Gabor filter

Member Avatar
dalaharp
Light Poster
31 posts since Oct 2004
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi,

i am trying to implement gabor filter for image enhancement.
if someone has any code snippet or pseudocode or any idea of implementing it in C, please help me out with it.

thanks.

Member Avatar
1o0oBhP
Posting Pro in Training
445 posts since Dec 2004
Reputation Points: 4 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

Talk us through the gabor filter.... im sure if you explain it anyone can do a pseudocode for you and maybe a bit more.... :)

Member Avatar
Chainsaw
Posting Pro in Training
434 posts since Jun 2004
Reputation Points: 12 [?]
Q&As Helped to Solve: 13 [?]
Skill Endorsements: 1 [?]
 
0
 

Since Google is a programmer's best friend, a search there yielded a bunch-o-sites (of course), and this one claims to have some source code:

http://www.icsi.berkeley.edu/ftp/global/pub/speech/papers/icslp02-gabor/

Member Avatar
dalaharp
Light Poster
31 posts since Oct 2004
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-1
 

thanks for the help,
google yields hits, ok. but the problem is that all the codes are in high level C, unfortunately i am not that good in C. so i want the coding in simple C.

ok i can outline the operation required and the equations, maybe we can put together a code of sorts. :-|

i have attached a file, where the first step of gabor filter is detailed (a point to note: i am implementing gabor for fingerprint image processing)
and this is how i coded it..
just see if there are no technical errors in it..
R and C are image height and width.
and
#define P1 image[r-1][c-1] //3x3 IMAGE MASK ELEMENTS
#define P2 image[r-1][c]
#define P3 image[r-1][c+1]
#define P4 image[r][c+1]
#define P5 image[r+1][c+1]
#define P6 image[r+1][c]
#define P7 image[r+1][c-1]
#define P8 image[r][c-1]

/* LOCAL ORIENTATION ESTIMATION */
		for(r=0;r<R;r++)
		{
			for(c=0;c<C;c++)
			{
				// calculate the gradients gx and gy
				gx[r][c]=((P1*1)+(P2*0)+(P3*-1)+(P8*2)+(image[r][c]*0)+(P4*-2)+(P7*1)+(P6*0)+(P5*-1));
				gy[r][c]=((P1*1)+(P2*2)+(P3*1)+(P8*0)+(image[r][c]*0)+(P4*0)+(P7*-1)+(P6*-2)+(P5*-1));
				Vx[r][c]=0;
				Vy[r][c]=0;
				for(u=r-5;u<=r+5;r++)
				{
					for(v=c-5;v<=c+5;v++)
					{
						Vx[r][c]=Vx[r][c]+(2*(gx[u][v])*(gy[u][v]));
						Vy[r][c]=Vy[r][c]+(pow((gx[u][v]),2)*pow((gy[u][v]),2));
					}
				}  //inner loop
				if(Vx[r][c]==0)
				{
					thetaQ[r][c]=90;
				}
				else
				{
					//T=(Vy[r][c])/(Vx[r][c]);
					thetaQ[r][c]=(1/2)*(atan((Vy[r][c])/(Vx[r][c])));  //orientation angle of the query image
				}
				//vecx[r][c]=sin(2*theta[r][c]);
				//vecy[r][c]=cos(2*theta[r][c]);
			}  //outer loop
		}  //the loop

thanks..

Attachments orient.jpg 50.85KB
Member Avatar
jwenting
duckman
8,359 posts since Nov 2004
Reputation Points: 1,399 [?]
Q&As Helped to Solve: 447 [?]
Skill Endorsements: 35 [?]
Infraction Points: 5
Team Colleague
 
0
 

Maybe you should get better in C then before attempting to solve complex problems.
Studying that more complex code is one way which will help you get better yourself.

Member Avatar
dalaharp
Light Poster
31 posts since Oct 2004
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

if i am any better in C, why should i ask for help. :-)
with what little time i have, i have to finish the job at hand, and with what little C expertise i have. so...

Member Avatar
alc6379
Cookie... That's it
2,752 posts since Dec 2003
Reputation Points: 105 [?]
Q&As Helped to Solve: 154 [?]
Skill Endorsements: 4 [?]
Team Colleague
 
0
 

if i am any better in C, why should i ask for help. :-)
with what little time i have, i have to finish the job at hand, and with what little C expertise i have. so...

I think what they're trying to say is there might not be a simple way of doing it. I don't think you'll find some do_what_i_want_it_to_do(); function out there to plug into your program. This may be the opportunity to bone up on the topic.

Member Avatar
Dave Sinkula
long time no c
4,852 posts since Apr 2004
Reputation Points: 2,398 [?]
Q&As Helped to Solve: 340 [?]
Skill Endorsements: 69 [?]
Team Colleague
 
0
 

i have attached a file, where the first step of gabor filter is detailed (a point to note: i am implementing gabor for fingerprint image processing)
and this is how i coded it..
just see if there are no technical errors in it..

We can't really do that because you are not including enough code.

My living room is rectangular; there are some couches and a chair and some other stuff: tell me if it is baby-safe.

Member Avatar
1o0oBhP
Posting Pro in Training
445 posts since Dec 2004
Reputation Points: 4 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

do you have any matrix manipulation functions in your code??? you need to check them if you havent already (use ID matrix to check). Most people get the indicies of their matrices mixed up and therefore the maths breaks down!

If you have seperate functions for matrix algebra it would clean up the code. It doesnt look too hard at first glance, and should be able to be written in 'simple' (bit of a loose definition) c. Do you understand the maths? if you you should see that a matrix multiply in the block followed by a summation can be VERY easily done in c.....

What have you tried / got working so far? any code would help with errors ect..

Member Avatar
dalaharp
Light Poster
31 posts since Oct 2004
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

i really liked that do_what_i_want_it_to_do(); function and the baby-safe example..
but the problem is, the whole porgram is some 500 codes, so i submitted only the pertinent code.

i just want to know if i have commited a domain error, or the like(some technical flaw), which will go undetected by the compiler, but will ultimately produce erraneous results.
please tell me if i have put the equations in correct C.
i really cant understand why this code is insufficient for that( i maybe asking this because i know little about C), is it so?

i missed to define the data types,

unsigned char gx[R][C],gy[R][C],Vx[R][C],Vy[R][C],thetaQ[R][C];

thanks..
and i dont think i have any matrix multiplication in my code.

Member Avatar
hayat alazzeh
Newbie Poster
1 post since May 2010
Reputation Points: -1 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-1
 

Hi,

i am trying to implement code of filter for image
if someone has any code snippet or pseudocode or any idea of implementing it in C++, please help me out with it.

thanks

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article