/* EulerNumber The input image should be a binary image */ int EulerNumber(ImageMatrix *Im, int FeatureNumber) { int x,y,HolesNumber; ImageMatrix *cp; cp=Im->duplicate(); /* inverse the image */ for (y=0;y<cp->height;y++) for (x=0;x<cp->width;x++) if (cp->data[x][y].intensity>0) cp->data[x][y].intensity=0; else cp->data[x][y].intensity=1; HolesNumber=cp->BWlabel(8); delete cp; return(FeatureNumber-HolesNumber-1); }
/* EulerNumber The input image should be a binary image */ int EulerNumber(ImageMatrix *Im, int FeatureNumber) { long x,y,z,HolesNumber; ImageMatrix *cp; cp=Im->duplicate(); /* inverse the image */ for (z=0;z<cp->depth;z++) for (y=0;y<cp->height;y++) for (x=0;x<cp->width;x++) { pix_data val=cp->pixel(x,y,z); if (cp->pixel(x,y,z).intensity>0) val.intensity=0; else val.intensity=1; cp->set(x,y,z,val); } HolesNumber=cp->BWlabel(8); delete cp; return(FeatureNumber-HolesNumber-1); }