Archived

This topic is now archived and is closed to further replies.

Whitehair

How do one compare 2 bitmaps and recognise 2 similar bitmaps being compared?

Recommended Posts

Well there''s lots of ways... enter the wide world of Image Processing...

The simplest way would be to just XOR them together, count howmany 1 bits result, compare that to how many bits were in the original image(s).. and if the percentage of 1''s to total bits is below a certain threshold you can consider them similar... of course... this has (many) flaws, but it''s the easiest to conceptualize and implement...

Being able to recognize two images as "similar", by the way, is an ill-posed and difficult problem if you want it to be robust

Anyway, if the above isn''t good enough for you go Google it up for Image Processing stuff

Share this post


Link to post
Share on other sites
that''s good enough for what i want to do...
but i guess my problem lies with writing it in terms of code.
to load the bitmaps, compare them, then recognise which is "similar", and finally find the correct texture index and display it onto a second window. (that''s a whole loads of errors, when i write it down... probably becoz of my gay programming...)

anyway...

void Cload_texture ( char *file_name, int width, int height, int depth,
int colour_type, int filter_type )
{ GLubyte *keeper;
GLubyte *raw_bitmap ;
FILE *file;

if (( file = fopen(file_name, "rb"))==NULL )
{
printf ( "File Not Found : %s\n", file_name );
exit ( 1 );
}

raw_bitmap = (GLubyte *)malloc(width * height * depth * (sizeof(GLubyte)));

if ( raw_bitmap == NULL )
{
printf ( "Cannot allocate memory for texture\n" );
fclose ( file );
exit ( 1 );
}

fread ( raw_bitmap , height * width * 3, 1 , file );
fclose ( file);
// Comparing
int g =0;
if (g <0)
{ keeper == raw_bitmap;
}
int totaldiff;
int totaldif;
int diff = keeper - raw_bitmap;
totaldiff += diff*diff;
if ( totaldif == NULL)
{ totaldif == totaldiff;
}
if (totaldif > totaldiff){
totaldif == totaldiff;}
if (g == 35)
{totaldiff = sqrt (totaldif);
raw_bitmap = keeper - totaldiff;}
raw_bitmap = keeper - totaldiff;
// Set Filtering type
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );

// Set Texture Evironment
glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );

// Build Mipmaps
gluBuild2DMipmaps ( GL_TEXTURE_2D, colour_type, width , height, colour_type,
GL_UNSIGNED_BYTE, raw_bitmap );

free ( raw_bitmap );
g++;
}

Share this post


Link to post
Share on other sites