int open_analyze(char* hdr_filename, char* img_filename, short* voxelMatrix, struct dsr *hdr) {
		
	int returnCode;
	//struct dsr hdr;
	
	printf("	[OPEN_ANALYZE:] Going to open Header...\n");
	returnCode = read_hdr(hdr_filename, hdr);
	printf("	[OPEN_ANALYZE:] ...done. <%d>\n", returnCode);
	
	//showHdr(hdr);
	//returnCode = getImgFilename(img_filename);

	printf("	[OPEN_ANALYZE:] Going to open Data...\n");
	returnCode = read_img(hdr, img_filename, &loadMatrix);
	printf("	[OPEN_ANALYZE:] ...done. <%d>\n", returnCode);
	
	int xSize = hdr->dime.dim[1];		
	int ySize = hdr->dime.dim[2];
	int zSize = hdr->dime.dim[3];
	int tSize = hdr->dime.dim[4];
	
	long voxelAmount = xSize*ySize*zSize;
	int x, t;

	//Voxel stehen so in der Matrix, dass die Zeitreihe eines Voxels an einem Stueck hintereinander steht
	for(x=0; x<voxelAmount; x++) {
		for (t=0; t<tSize; t++) {
			voxelMatrix[t+x*tSize] = loadMatrix[x+t*voxelAmount];
		}
	}
	return EXIT_SUCCESS;
}
Beispiel #2
0
/*** query user for file name and read image file ***/
img *read_user_specified_img_file (char *prog_name) {
  char file_name[IMG_FILE_NAME_LENGTH];
	
  printf ("Enter input file: ");
  scanf ("%s", file_name);
  return read_img (prog_name, file_name);
} /* end read_user_specified_img_file */
Beispiel #3
0
static void read_scale_img(image * a)
{
    image_dict *ad;
    if (a == NULL) {
        luaL_error(Luas, "the image scaler needs a valid image");
    } else {
        ad = img_dict(a);
        if (a == NULL) {
            luaL_error(Luas, "the image scaler needs a valid dictionary");
        } else {
            if (img_state(ad) == DICT_NEW) {
                if (img_type(ad) == IMG_TYPE_PDFSTREAM)
                    check_pdfstream_dict(ad);
                else {
                    read_img(ad);
                }
            }
            if ((img_type(ad) == IMG_TYPE_NONE) || (img_state(ad) == DICT_NEW)) {
                normal_warning("image","don't rely on the image data to be okay");
                img_width(a) = 0;
                img_height(a) = 0;
                img_depth(a) = 0;
            } else if (is_wd_running(a) || is_ht_running(a) || is_dp_running(a)) {
                img_dimen(a) = scale_img(ad, img_dimen(a), img_transform(a));
            }
        }
    }
}
static void water_image_from(void * conf)
{
	int size = 0;
	void * buffer;
	char * water_file;
	ngx_image_conf_t *info = conf;
	info->water_im = NULL;
	water_file = (char *)info->water_image.data;
	info->water_im_type = get_ext_header(water_file);
	if((read_img(&water_file,&size,&buffer)) == 0)
	{
		switch(info->water_im_type)
		{
		case NGX_IMAGE_GIF:
			info->water_im = gdImageCreateFromGifPtr(size,buffer);
			break;
		case NGX_IMAGE_JPEG:
			info->water_im = gdImageCreateFromJpegPtr(size,buffer);
			break;
		case NGX_IMAGE_PNG:
			info->water_im = gdImageCreateFromPngPtr(size,buffer);
			break;
		}
		free(buffer);
		return;
	}
}
Beispiel #5
0
// argv[1] = source name; argv[2] = destination name; argv[3] = reality check name
int main( int argc, char *argv[] ) {

  // Input valdiation
  if( argc != 4 ) {
    printf( "\nError: expecting three file name arguments ( src_name, dst_name, rl_name )\n\n" ) ;
	return 0 ;
  }
  
  // Read src_name and compute dft. Store result in dst_name
  dft( read_img( argv[0], argv[1] ), argv[2] ) ;
  
  // Read dst_name (dft of src_name) and compute idft. Store result in rl_name
  idft( read_img( argv[0], argv[2] ), argv[3] ) ;
  
  return 0 ;
}
Beispiel #6
0
int read_block(DCELL *** img, int wd, int ht, int nbands,
	       struct Region *region, char *infn)
{
    static first = 1;
    static unsigned char ***img_buf;

    int b, i, j;
    int xstop, ystop;
    char *infn_num;

    /* allocate image buffer first time called */
    if (first) {
	img_buf =
	    (unsigned char ***)multialloc(sizeof(unsigned char), 3, nbands,
					  ht, wd);

	/* allocate memory for name extension */
	infn_num = (char *)G_malloc((strlen(optarg) + 10) * sizeof(char));

	/* read data */
	if (nbands == 1) {
	    read_img(img_buf[0], wd, ht, infn);
	}
	else {
	    for (b = 1; b <= nbands; b++) {
		sprintf(infn_num, "%s.%d", infn, b);
		read_img(img_buf[b - 1], wd, ht, infn_num);
	    }
	}
	first = 0;
    }

    /* copy data from buffer */
    xstop = region->xmax;
    if (xstop > wd)
	xstop = wd;
    ystop = region->ymax;
    if (ystop > ht)
	ystop = ht;
    for (b = 0; b < nbands; b++)
	for (i = region->ymin; i < ystop; i++)
	    for (j = region->xmin; j < xstop; j++)
		img[b][i][j] = img_buf[b][i][j];

    return 0;
}
Beispiel #7
0
// argv[1] = src_path; argv[2] = dst_path
int main( int argc, char *argv[] ) {

  img *src_img = read_img( "hw9", argv[1] ) ;
	
	webify( src_img, argv[2] ) ;
	
	return 0 ;
}
Beispiel #8
0
// argv[1] = img_src_path; argv[2] = img_dst_path; argv[3] = transformation
int main( int argc, char *argv[] ) {

	// Input
	img *src_img = read_img( "hw8", argv[1] ) ;

	write_img( "yo", bilinear( "yo", src_img, 3 ), "test.img" );
	 
  return 0 ;
}
Beispiel #9
0
int main(int argc, char** argv) {

	saveBuffer.data = read_img("img.tif", &saveBuffer.w, &saveBuffer.h);

	if (saveBuffer.data == NULL) {
		printf("Error loading image file img.tif\n");
		return 1;
	}

	printf("Basic Functions: \n");
	printf("R: Reset \nS: Save \nQ: Quit  \n\n");

	printf("Display Functions: \n");
	printf("A: Only Red Channel   \nB: Only Blue Channel \n");
	printf("C: Channel Swap \nD: only Green Channel   \n");
	printf("G: Greyfilter \nM: Monochrome  \nN: Grey NTSC Filter  \n\n");

	printf("Basic Filter Functions:  \n");
	printf("E: Maximum Filter \nH: Minimum Filter  \nI: Intensify Red \n");
	printf("J: Intensify Blue \nK: Intensify Green \n\n");

	printf("Funny Filter Functions:   \n");
	printf("L: CrazyFilter \nO: Blur Filter \nP: Sobel Edge Detection \n");
	printf("U: MyFilter1  \nV: MyFilter2 \n");
	printf("W: Quantize Random   \nX: Qantize predefined Colors \n\n");

	printf("Other Stuff: \n");
	printf("F: Filter    \nT: Triangle  \n");
	printf("Y: Maikes Filter 1 \nZ: Maikes Filter 2\n\n");

	displayBuffer.h = saveBuffer.h;
	displayBuffer.w = saveBuffer.w;
	displayBuffer.data = (pixel *)malloc((saveBuffer.h)*(saveBuffer.w)*sizeof(pixel *));

	workBuffer.h = saveBuffer.h;
	workBuffer.w = saveBuffer.w;
	workBuffer.data = (pixel *)malloc((saveBuffer.h)*(saveBuffer.w)*sizeof(pixel *));

	resetBuffers();

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);

	glutInitWindowSize(displayBuffer.w, displayBuffer.h);
	glutCreateWindow("Funny Stuff Happens Here"); // Window-Title
	glShadeModel(GL_SMOOTH);
	glutDisplayFunc(display_image); 
	glutKeyboardFunc(keyboard);
	glMatrixMode(GL_PROJECTION);
	glOrtho(0, displayBuffer.w, 0, displayBuffer.h, 0, 1);
	createMenu();

	glutMainLoop();

	return 0;
} //main
Beispiel #10
0
// argv[1] = img_src_path; argv[2] = img_dst_path; argv[3] = transformation
int main( int argc, char *argv[] ) {

	// Input
	img *src_img = read_img( "hw8", argv[1] ) ;

	// Resize input image by argv[3] and store in argv[2]
	resize( src_img, argv[2], strtof( argv[3], NULL )) ;
	 
  return 0 ;
}
Beispiel #11
0
int main(int argc, char *argv[])
{
    int err = 0;
    char *img_name;
    char bin[32][128];
    int bin_nr = 0;
    int offset = 0;
    int total_w = 0;
    char *buffer;

    if(argc == 1)
        exit(0);

    img_name = DEFAULT_FILENAME;
    for(int i = 1; i < argc; i++) {
        if(strcmp(argv[i], "-o") == 0) {
            if(!argv[i + 1]) {
                err = -ERR_ARGW;
                break;
            }
            img_name = argv[i + 1];
            i++;
        } else if(strcmp(argv[i], "-f") == 0) {
            if(!argv[i + 1]) {
                err = -ERR_ARGW;
                break;
            }
            offset = atoi(argv[i + 1]);
            i++;
        } else {
            strcpy(bin[bin_nr], argv[i]);
            bin_nr++;
        }
    }
    if(err)
        err_exit(err);
    buffer = (char*)calloc(IMG_SIZE, 1);
    if((err = read_img(img_name, buffer)) < 0)
        err_exit(err);

    for(int i = 0; i < bin_nr; i++) {
        int res;
        res = write_buffer(bin[i], buffer, offset);
        if(res < 0)
            err_exit(res);
        offset += res;
        total_w += res;
    }
    if(err = write_img(img_name, buffer))
        err_exit(err);
    free(buffer);
    printf("%d bytes written.\n", total_w);
}
int main ( int argc, char **argv )
{
    int i;                      /* loop iterator            */
    int height, width;          /* image dimensions         */
    string param;               /* passed parameter         */
    void *raw_data;             /* raw image data           */
    Magick::Blob blob;          /* image in blob format     */
    vector <string> qr_data;    /* decoded qr codes         */

    /* Check that a file was passed - provide usage statement if not */
    if( argc != 2 )
    {
        error( TRUE, "Usage: read_img (imagefile | 'webcam')" );
    }

    /* get command line arg as c++ style string */
    param = argv[ 1 ];

    /* process the image into the raw data */
    if( param == "webcam" )
    {
        /* obtain the image from the webcam */
        dbg_msg( "Attempting to get data from webcam using OpenCV" );
        get_cam_img( raw_data, width, height );
    }
    else
    {
        /* initalize image magick c++ library and use it to get image data */
        dbg_msg( "Using ImageMagick to read QR codes from image file %s", param.c_str() );
        Magick::InitializeMagick( NULL );
        read_img( param, blob, width, height );
        raw_data = (void *) blob.data();
    }

    /* process the qr codes */
    if( raw_data == NULL )
    {
        error( TRUE, "Could not read image data" );
    }
    get_codes( qr_data, raw_data, width, height );

    /* output all of the recognized codes */
    for( i = 0; i < qr_data.size(); i++ )
    {
        printf( "symbol %d - data: %s\n", i, qr_data[ i ].c_str() );
    }

    /* be tidy -- don't leak memory */
    if( raw_data != NULL && param == "webcam" ) free( raw_data );

    return 0;
}
Beispiel #13
0
static int img_check_magic(struct cr_img *img, int oflags, int type, char *path)
{
	u32 magic;

	if (read_img(img, &magic) < 0)
		return -1;

	if (img_common_magic && (type != CR_FD_INVENTORY)) {
		if (magic != head_magic(oflags)) {
			pr_err("Head magic doesn't match for %s\n", path);
			return -1;
		}

		if (read_img(img, &magic) < 0)
			return -1;
	}

	if (magic != imgset_template[type].magic) {
		pr_err("Magic doesn't match for %s\n", path);
		return -1;
	}

	return 0;
}
Beispiel #14
0
int open_image_at(int dfd, int type, unsigned long flags, ...)
{
	char path[PATH_MAX];
	va_list args;
	int ret;

	va_start(args, flags);
	vsnprintf(path, PATH_MAX, fdset_template[type].fmt, args);
	va_end(args);

	if (flags & O_EXCL) {
		ret = unlinkat(dfd, path, 0);
		if (ret && errno != ENOENT) {
			pr_perror("Unable to unlink %s", path);
			goto err;
		}
	}

	ret = openat(dfd, path, flags, CR_FD_PERM);
	if (ret < 0) {
		pr_perror("Unable to open %s", path);
		goto err;
	}

	if (fdset_template[type].magic == RAW_IMAGE_MAGIC)
		goto skip_magic;

	if (flags == O_RDONLY) {
		u32 magic;

		if (read_img(ret, &magic) < 0)
			goto err;
		if (magic != fdset_template[type].magic) {
			pr_err("Magic doesn't match for %s\n", path);
			goto err;
		}
	} else {
		if (write_img(ret, &fdset_template[type].magic))
			goto err;
	}

skip_magic:
	return ret;
err:
	return -1;
}
Beispiel #15
0
static void read_scale_img(image * a)
{
    image_dict *ad;
    assert(a != NULL);
    ad = img_dict(a);
    assert(ad != NULL);
    if (img_state(ad) == DICT_NEW) {
        if (img_type(ad) == IMG_TYPE_PDFSTREAM)
            check_pdfstream_dict(ad);
        else {
            fix_pdf_minorversion(static_pdf);
            read_img(static_pdf,
                     ad, pdf_minor_version, pdf_inclusion_errorlevel);
        }
    }
    if (is_wd_running(a) || is_ht_running(a) || is_dp_running(a))
        img_dimen(a) = scale_img(ad, img_dimen(a), img_transform(a));
}
Beispiel #16
0
/* read_img read an image of format P5 */
pImage Image_Read(char *filename)
{
	unsigned char **read_img(char*,int*,int*,int*);
	tImage *image;
	int row, col;
	int imgtype;

	image = (tImage *) malloc(sizeof(tImage));
	assert(image != NULL);

	image->imageIdx = 0;
	image->content = read_img(filename,&row,&col,&imgtype);
	image->tag = NULL;
	image->row = row;
	image->col = col;

	/* to be perfected later Jul 26, Yan */
	image->type = eGrayScale8;
	image->status = 0;

	return image;
}
static void image_from(void * conf)
{
	int size = 0;
	void * buffer;
	ngx_image_conf_t *info = conf;
	info->src_im = NULL;
	if((read_img(&info->source_file,&size,&buffer)) == 0)
	{
		switch(info->src_type)
		{
			case NGX_IMAGE_GIF:
				info->src_im = gdImageCreateFromGifPtr(size,buffer);
				break;
			case NGX_IMAGE_JPEG:
				info->src_im = gdImageCreateFromJpegPtr(size,buffer);
				break;
			case NGX_IMAGE_PNG:
				info->src_im = gdImageCreateFromPngPtr(size,buffer);
				break;
		}
		free(buffer);
		return;
	}
}
Beispiel #18
0
static image_dict *read_image(char *file_name, int page_num, char *page_name, int colorspace, int page_box, char *user_password, char *owner_password, char *visible_filename)
{
    image *a = new_image();
    image_dict *idict = img_dict(a) = new_image_dict();
    static_pdf->ximage_count++;
    img_objnum(idict) = pdf_create_obj(static_pdf, obj_type_ximage, static_pdf->ximage_count);
    img_index(idict) = static_pdf->ximage_count;
    set_obj_data_ptr(static_pdf, img_objnum(idict), img_index(idict));
    idict_to_array(idict);
    img_colorspace(idict) = colorspace;
    img_pagenum(idict) = page_num;
    img_pagename(idict) = page_name;
    img_userpassword(idict) = user_password;
    img_ownerpassword(idict) = owner_password;
    img_visiblefilename(idict) = visible_filename;
    if (file_name == NULL) {
        normal_error("pdf backend","no image filename given");
    }
    cur_file_name = file_name;
    img_filename(idict) = file_name;
    img_pagebox(idict) = page_box;
    read_img(idict);
    return idict;
}
Beispiel #19
0
// simple comparison main
int main(int argc,char **argv) {
  if(argc<3) { printf("Enter at least two .bmp files (all functions and then the program image)."); exit(0); }
  else { FILE **f = malloc(argc*sizeof(FILE *));
    for(int i=1;i<argc;i++) { f[i] = fopen(argv[i],"rb");
      pr_img(read_img(f[i])); fclose(f[i]); } } return 0; }
Beispiel #20
0
/**
 Realiza la deteccion de todas las celulas de la imagen de forma automatica.
 */
bool DeteccionAut::deteccionBordesNoSupervisado()
{
    // Maximun number of objects in the image
    int NUM_CELLS (10000 );
    // Maximun roundness of interested objects in the image for unsupervised algorithm
    double  MAX_ROUND 	( 1.4 );
    int i, l;
    int nout;
    PointList **out;

    if(diamMax != 0)
    {
        MAX_DIAMETER = diamMax / calibracion;
    }
    else
    {
        MAX_DIAMETER = MAX_DIAMETER / calibracion;
    }

    if(diamMin != 0)
    {
        MIN_DIAMETER = diamMin / calibracion;
    }
    else
    {
        MIN_DIAMETER = MIN_DIAMETER / calibracion;
    }

    // Read the input image
    img = read_img ( ruta.c_str() );
    if ( !is_rgb_img ( img ) || (img == NULL))
    {
        fprintf ( stderr, "Input image ( %s ) must be color image !", ruta.c_str() );
        return false;
    }

    /********************************Reloj**************************************/
    // comienzo = clock();
    /***************************************************************************/

    /***************************************************************************/
    string mensaje, titulo;

    //mensaje = "Se va a proceder al cálculo de los bordes de los ovocitos, el proceso durara aproximadamente 1 minuto durante el cual la aplicación quedara bloqueada, ¿Esta seguro de continuar?";
    mensaje = "The automatic oocyte edge detection is going to be performed. The application will be unaccesible during this process. Are you sure that you want to continue?";

    //titulo = "Cálculo automatico de bordes de los ovocitos";
    titulo = "Oocyte edge detection";

    if(Dialogos::dialogoConfirmacion(mensaje, titulo))
    {
        //DialogoBarraProgres dProgres("Detectando Bordes");
        DialogoBarraProgres dProgres("Oocyte edge detection");
        dProgres.ejectuaDialogoProgreso();
        dProgres.setEstadoBarraProgreso(0.1);
        dProgres.setPercentText(0.1);
        Utiles::actualizarInterfaz();
        /***************************************************************************/
        // Detect the edges in the input image
        num_rows=get_num_rows(img);
        num_cols=get_num_cols(img);

        /*Este dobre bucle que ven a continuacion e a aplicacion do filtro de Canny para distintos umbrais
        e suavizados (distintas escalas). O que obtemos e en contour (unha estrutura da libreria fourier.0.8
        que almacena os bordes que teñen mais de MIN_LENGTH pixels) e en n_all o numero de borde. */
        // Este paso e independente de que o algoritmo se aplique de forma supervisada ou non supervisada.
        //num_edges = 0;

        if(num_rows > MAX_ROWS_IMAGE || num_cols > MAX_COLS_IMAGE) {
            fprintf(stderr, "Error: image of size %i x %i too large (max. size= %i x %i): border detection aborted\n", num_rows, num_cols, MAX_ROWS_IMAGE, MAX_COLS_IMAGE);
            Dialogos::dialogoError("Image too large for border detection", "Error");
            return false;
        }

        img_grey=rgb_to_gray(img);
        // Aplicando o filtro de canny multiescalar
        contour=detect_edge_multiscalar_canny ( img_grey,  &num_edges, MIN_DIAMETER, NUM_CELLS);
        if ( IS_NULL( contour)) {
            printf ( "Invalid point list objects !");
        }
        //	printf("Tempo transcurrido: %f bordes= %d \n", stop_timer ( start_time), num_edges) ;

        /**********************************fase 1****************************/
        /* final = clock();
        cout<<"Tiempo fase 1 "<<(final - comienzo)/(double) CLOCKS_PER_SEC<<endl;
        comienzo = clock();*/

        dProgres.setEstadoBarraProgreso(0.5);
        dProgres.setPercentText(0.5);
        Utiles::actualizarInterfaz();
        /**************************************************************************/
        // A partir de aqui fanse calculos para analizar os bordes que hai en contour e asi mostrar so os que cremos que son bordes de govocitos maduros.

        //utilizando funcion aplico a deteccion non supervisada
        out=nonSuperviseDetection(contour, num_edges, num_cols, num_rows, MIN_DIAMETER, MAX_DIAMETER, MAX_ROUND, &nout);

        /**********************************Reloj fase 2****************************/
        /* final = clock();
        cout<<"Tiempo fase 2 "<<(final - comienzo)/(double) CLOCKS_PER_SEC<<endl;
        comienzo = clock();*/

        dProgres.setEstadoBarraProgreso(0.9);
        dProgres.setPercentText(0.9);
        Utiles::actualizarInterfaz();
        /**************************************************************************/

        for ( l = 0; l <nout; l++)
        {
            /************************Pintado govocitos*************************/
            PointList *p = out[l];

            /*Guardamos los puntos en un objeto celula y lo añadimos al objeto de
            listado de celulas*/
            pasoCoordSistemaGovocitos(p);
            /*******************************************************************/
        }

        for(i=0; i<nout; i++)
        {
            free_point_list(out[i]);
            free(out[i]->point);
            free(out[i]);
        }
        free(out);
        free_img(img);
        free_img(img_grey);
        free(img);
        free(img_grey);

        /**********************************Reloj fase 3****************************/
        /* final = clock();
        cout<<"Tiempo fase 3 "<<(final - comienzo)/(double) CLOCKS_PER_SEC<<endl;*/

        dProgres.setEstadoBarraProgreso(1);
        dProgres.setPercentText(1);
        Utiles::actualizarInterfaz();
        dProgres.cierraVentanaProgreso();
        /**************************************************************************/
    }
    else
    {
        return false;
    }

    return true;
}
Beispiel #21
0
/**
 Carga los ficheros de clasificacion automatica de estados y clases y clasifica las
 celulas de la imagen cuya ruta corresponde con la pasada por parametro.
 @param ruta, string de la ruta de la imagen a analizar.
 @param listCell, objeto ListadoCeulas que contiene todas las celulas de la imagen
 a analizar.
 */
void Clasificador::clasificarCelulas(string ruta, ListadoCelulas &listCell)
{	
	struct svm_model  *svmEst, *svmCl;
	
	float  media_est[N_ENTRADAS], desv_est[N_ENTRADAS];
	float  media_cl[N_ENTRADAS], desv_cl[N_ENTRADAS];
	int  y1, y2;
	int numCelulas, numPuntos;
	vector <int> *cx, *cy;
	Image *img, *img_grey, *img_bin;
	
	img = read_img ( ruta.c_str() );
	img_grey = rgb_to_gray (img);
	
	numCelulas = listCell.getNumCelulas();

	//Obtenemos path de los ficheros de clasificacion
	const char  *f_svm_Est = fichClasificEst.c_str();
	const char  *f_med_desv_Est = fichMediaDesviaEst.c_str();
	const char  *f_svm_Cl = fichClasificCl.c_str();
	const char  *f_med_desv_Cl = fichMediaDesviaCl.c_str();

	//Creamos los svm
	svmEst = crea_svm(f_svm_Est, f_med_desv_Est, media_est, desv_est);
	svmCl = crea_svm(f_svm_Cl, f_med_desv_Cl, media_cl, desv_cl);
	
	for(int i = 0; i < numCelulas; i++) 
	{
		PointList *puntos;

		if(listCell.getCelula(i)->getEstadoCelula() != "outimage" && 
		   listCell.getCelula(i)->getClaseCelula() != "outimage")
		{
			cx = listCell.getCelula(i)->getBordeCellX();
			cy = listCell.getCelula(i)->getBordeCellY();

			numPuntos = cx->size();
			puntos = alloc_point_list(numPuntos);
		
			//Convertimos puntos
			for(int j = 0; j < numPuntos; j++)
			{
				puntos->point[j] = alloc_point((*cy)[j], (*cx)[j]);
			}
			puntos->type = GEN_VALID;
		
			img_bin=computeBinImage ( puntos, get_num_rows ( img_grey ) , get_num_cols (img_grey));
		
			//  double* resul = texture_features_haralick(img, puntos, 1, 1);
			double * resul = texture_features_glrls_grey ( img_grey, img_bin, puntos, 1000, 0);
			float resul2[N_ENTRADAS], resul3[N_ENTRADAS];
		
			for(unsigned int z = 0; z < N_ENTRADAS; z++)
			{
				resul2[z] = (float)resul[z];
				resul3[z] = (float)resul[z];
			}

			//Salida clasificador clases
			y1 = saida_svm(svmCl, resul2, media_cl, desv_cl);

			switch(y1)
			{
				case 0:
					listCell.getCelula(i)->setClaseCelula("cn");
					break;
				case 1:
					listCell.getCelula(i)->setClaseCelula("sn");
					break;
			}
		
			//Salida clasificador estados
			y2 = saida_svm(svmEst, resul3, media_est, desv_est);

			switch (y2)
			{
				case 0:
					listCell.getCelula(i)->setEstadoCelula("ac");
					break;
				case 1:
					listCell.getCelula(i)->setEstadoCelula("hid");
					break;
				case 2:
					listCell.getCelula(i)->setEstadoCelula("vit");// vitelinas o atresicas
					break;
			}
		    free_point_list ( puntos );
		    free ( puntos->point );
		    free ( puntos );
		//	delete puntos;    
	
			free ( resul );
		}
	}
	destrue_svm(svmCl);
	destrue_svm(svmEst);
	
	free_img ( img );
	free ( img );
	free_img ( img_grey );
	free ( img_grey );
}
Beispiel #22
0
struct cr_img *open_image_at(int dfd, int type, unsigned long flags, ...)
{
	struct cr_img *img;
	unsigned long oflags = flags;
	char path[PATH_MAX];
	va_list args;
	int ret;

	img = xmalloc(sizeof(*img));
	if (!img)
		goto errn;

	oflags |= imgset_template[type].oflags;
	flags &= ~(O_OPT | O_NOBUF);

	va_start(args, flags);
	vsnprintf(path, PATH_MAX, imgset_template[type].fmt, args);
	va_end(args);

	ret = openat(dfd, path, flags, CR_FD_PERM);
	if (ret < 0) {
		if ((oflags & O_OPT) && errno == ENOENT) {
			xfree(img);
			return NULL;
		}

		pr_perror("Unable to open %s", path);
		goto err;
	}

	img->_x.fd = ret;
	if (oflags & O_NOBUF)
		bfd_setraw(&img->_x);
	else if (bfdopen(&img->_x, flags))
		goto err;

	if (imgset_template[type].magic == RAW_IMAGE_MAGIC)
		goto skip_magic;

	if (flags == O_RDONLY) {
		u32 magic;

		if (read_img(img, &magic) < 0)
			goto err;
		if (magic != imgset_template[type].magic) {
			pr_err("Magic doesn't match for %s\n", path);
			goto err;
		}
	} else {
		if (write_img(img, &imgset_template[type].magic))
			goto err;
	}

skip_magic:
	return img;

err:
	xfree(img);
errn:
	return NULL;
}
void read_img_function(char *argv)
{
    read_img(argv);
}