#include #include #include #include #include #include #include #include "ami.h" #include "ami_calibracion.h" /* WE USE THE MORPHOLOGICAL CORNER DETECTOR TO RECOVER LOCALLY THE BEST CORNER IN A WINDOW CENTERED IN A NUMBER OF SELECTED PIXEL POINTS THE MAIN PARAMETER IS THE RADIUS OF THE WINDOW. WHEN YOU CHOOSE BY HAND THE SELECTED POINTS IT IS BETTER TO DO IT INSIDE THE CORNERS. THE ALGORITHM SAVE IN A FILE THE COORDINATES OF THE IMPROVED LOCATION OF THE CORNERS. TO PROVIDE THE INITIAL CORNERS, YOU HAVE TO ACTIVE THE OPTION CREATE POINT OF THE EDIT MENU OF THE MAIN WINDOW OF XMEGAWAVE, THEN YOU HAVE JUST TO CLICK ON THE IMAGE */ FUNCTION(LocalMorphologicalCornerDetector) { int width=MasterGW->width; int height=MasterGW->height; int i, j,k,i0,j0; GraphicWindow *input,*output; char filename[100]; char *name; FILE *f; double x,y; int Nc; int radius=GetInt(Params[0]); int *flat; double les,pes,curvs; float step=0.01; name=GetString(Params[1]); strcpy(filename,name); input=MasterGW; Nc=input->num_points; if(Nc<1){ printf("There is not any selected point\n"); return; } if(input->type!=TGA){ printf("Algorithm only implemented for tga format image\n"); return; } output=CreateMasterCopy("Local Morphological Corners"); /* WE CALL TO THE FUNCTION WHICH COMPUTE THE CORNERS */ /* AND WE SAVE THE CORNER IN THE FILE name */ if(f=fopen(name, "w"),!f){ printf("Corner File can not be created \n"); return; } fprintf(f,"%d\n",Nc); for(k=0;kTGAdata[0],width,height,radius, input->point_x[k],input->point_y[k],&x,&y); printf("x_ini=%d y_ini=%d x_corr=%lf, y_corr=%lf\n",input->point_x[k],input->point_y[k],x,y); fprintf(f,"%lf %lf \n",y,x); i0=input->point_x[k]; j0=input->point_y[k]; for(i=0;i<11;i++){ output->TGAdata[0][(j0+i-5)*width+i0]=255; output->TGAdata[1][(j0+i-5)*width+i0]=0; output->TGAdata[2][(j0+i-5)*width+i0]=0; output->TGAdata[0][(j0)*width+i0-5+i]=255; output->TGAdata[1][(j0)*width+i0-5+i]=0; output->TGAdata[2][(j0)*width+i0-5+i]=0; } i0=x+0.5; j0=y+0.5; for(i=0;i<11;i++){ output->TGAdata[0][(j0+i-5)*width+i0]=0; output->TGAdata[1][(j0+i-5)*width+i0]=0; output->TGAdata[2][(j0+i-5)*width+i0]=255; output->TGAdata[0][(j0)*width+i0-5+i]=0; output->TGAdata[1][(j0)*width+i0-5+i]=0; output->TGAdata[2][(j0)*width+i0-5+i]=255; } ShowImage(output); } fclose(f); } Panel_LocalMorphologicalCornerDetector(w) Widget w; { BeginCreatePanel("Local Morphological Corner Detector Parameters"); CreateIntSlider("Minimum distance bettween corners",0,20,5); CreateStringInput("File Name for recovered corners","local_corners.txt"); EndCreatePanel(LocalMorphologicalCornerDetector,STOP_OFF); } main (argc, argv) int argc; char **argv; { static OPTION option_Calibrado[] ={ {BUTTON, "Local Morhological Corner Detector",Panel_LocalMorphologicalCornerDetector}, {NULL, NULL, NULL} }; InitXMW (argc, argv); AddMenuOptions(3,option_Calibrado); EndXMW (argc, argv); }