robwhess / opensift

Open-Source SIFT Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about the code

xyg-coder opened this issue · comments

Hello, your code is very elegant and I am now studying it.
I have one question:

	unsigned long* feature_mat;

	features = cvCreateSeq( 0, sizeof(CvSeq), sizeof(struct feature), storage );
	for( o = 0; o < octvs; o++ )
	{
		feature_mat = calloc( dog_pyr[o][0]->height * dog_pyr[o][0]->width, sizeof(unsigned long) );
		for( i = 1; i <= intvls; i++ )
			for(r = SIFT_IMG_BORDER; r < dog_pyr[o][0]->height-SIFT_IMG_BORDER; r++)
				for(c = SIFT_IMG_BORDER; c < dog_pyr[o][0]->width-SIFT_IMG_BORDER; c++)
					/* perform preliminary check on contrast */
					if( ABS( pixval32f( dog_pyr[o][i], r, c ) ) > prelim_contr_thr )
						if( is_extremum( dog_pyr, o, i, r, c ) ) 
							//is_extremum: Determines whether a pixel is a scale-space extremum by comparing it to it's
							//3x3x3 pixel neighborhood
						{
							feat = interp_extremum(dog_pyr, o, i, r, c, intvls, contr_thr);
							if( feat )
							{
								ddata = feat_detection_data( feat );
								// is_too_edge_like: is_too_edge_like: use the trace and det to determine
								if( ! is_too_edge_like( dog_pyr[ddata->octv][ddata->intvl],
														ddata->r, ddata->c, curv_thr ) )
								{
									if( ddata->intvl > sizeof(unsigned long) )
										cvSeqPush( features, feat );
									else if( (feature_mat[dog_pyr[o][0]->width * ddata->r + ddata->c] & (1 << ddata->intvl-1)) == 0 )
									{
										cvSeqPush( features, feat );
										feature_mat[dog_pyr[o][0]->width * ddata->r + ddata->c] += 1 << ddata->intvl-1;
									}
								}
								else
									free( ddata );
								free( feat );
							}
						}
		free( feature_mat );
	}

What's the purpose of feature_mat here?

feature_mat was added by @qq545305338 in #18 to ensure that no duplicate features were output.