Exemple #1
0
int main(int argc, char** argv){
    GraphDiscription modelJets, bunchGraph, graphTemplate;
    ImageList *modelImages, *novelImages;
    JetMasks masks;
    Arguments args;

    srand(time(NULL));

    processCommand(argc, argv, &args);

    /* build masks */
    masks = readMasksFile(args.masksFile);
    modelImages = getImageNames(args.modelFile, NULL);
    novelImages = getImageNames(args.novelFile, NULL);
    graphTemplate = readGraphDiscription(makePath(args.graphDir,modelImages->filename));

    /* extract model jets */
    modelJets = extractModelJets(modelImages, args.imageDir, args.graphDir, masks);

    /* build jet bunch */
    /* bunchGraph = buildBunchGraph(modelJets, args.distance, args.bunchSize); */
    bunchGraph = modelJets;

    /* locate features in novel image */
    locateNovelFeatures(novelImages, graphTemplate, bunchGraph, masks, args.imageDir, args.outputDir, args.dispEst);

    return 0;
}
Exemple #2
0
void
makeDifferenceImages (char *imageDirectory, char *imageList, char *distanceMatrix, int maxRank, int reqNIntra, int reqNExtra, Matrix *intrapersonal, Matrix *extrapersonal)
{
    ImageList* imlist;
    void *nameList = NULL;
    char **nameArray;
    void *subjList = NULL;
    int *subjArray, *shuffledIndices, **sortedBySimilarityToProbe;
    int subjId, probeIdx, galleryIdx, idx, nIntrapersonal, nExtrapersonal, rank, i, numPixels;
    int nImages;
    /* size_t trash; */
    Matrix sourceImages, intraImages, extraImages;
    ImageList *replicate, *subject;
    char *subjName;

    /* Read in a list of all the images */

    imlist = getImageNames (imageList, &nImages);
    subjId = 0;
    for EACH_SUBJECT (imlist, subject) {
        for EACH_REPLICATE (subject, replicate) {
            subjName = strdup (replicate->filename);
            listAccumulate (&nameList, &subjName, sizeof (char *));
            listAccumulate (&subjList, &subjId,   sizeof (int));
            writeProgress ("Reading subjects list", subjId, 0);
        }
        subjId++;
    }
/*
This function reads images in to a vector.  That vector is then mean subtracted
and then projected onto an optimal basis (PCA, LDA or LPP). Returned is a matrix
that contains the images after they have been projected onto the subspace.
*/
Matrix
readAndProjectImages (Subspace *s, char *imageNamesFile, char *imageDirectory, int *numImages, ImageList **srt)
{
    int i, j;
    Matrix images, vector, smallVector;
    char name[FILE_LINE_LENGTH];
    ImageList *subject, *replicate;

    DEBUG(1, "Reading training file names from file");

    *srt = getImageNames(imageNamesFile, numImages);

    DEBUG_CHECK(*srt, "Error: header no imagenames found in file image list file");

    /* Automatically determine number of pixels in images    */
    sprintf(name, "%s/%s", imageDirectory, (*srt)->filename);
    DEBUG(1, "Autodetecting number of pixels, i.e. vector length based on the size of image 0.");
    DEBUG_CHECK (autoFileLength(name) == s->numPixels, "Images sizes do not match subspace basis vector size");
    DEBUG_INT(1, "Vector length", s->numPixels);
    DEBUG_CHECK(s->numPixels > 0, "Error positive value required for a Vector Length");

    /*Images stored in the columns of a matrix */
    DEBUG(1, "Allocating image matrix");

    images = makeMatrix(s->basis->col_dim, *numImages);
    vector = makeMatrix(s->numPixels, 1);

    i = 0;
    for (subject = *srt; subject; subject = subject->next_subject) {
        for (replicate = subject; replicate; replicate = replicate->next_replicate) {
            if (debuglevel > 0)
                printf("%s ", replicate->filename);
            sprintf(name, "%s/%s", imageDirectory, replicate->filename);
            replicate->imageIndex = i;
            readFile(name, 0, vector);

            writeProgress("Reading images", i,*numImages);

            smallVector = centerThenProjectImages(s, vector);

            /* Copy the smaller vector into the image matrix*/
            for (j = 0; j < smallVector->row_dim; j++) {
                ME(images, j, i) = ME(smallVector, j, 0);
            }
            freeMatrix(smallVector);
            i++;  /* increament the image index */
        }
        if (debuglevel > 0)
            printf("\n");
    }

    return images;
}
void Board::setFileNameItems() {
	if (m_fileNameComboBox == NULL) return;

	m_fileNameComboBox->addItems(getImageNames());
	m_fileNameComboBox->addItems(getNewImageNames());

	int ix = 0;
	foreach (QString name, getImageNames()) {
		if (prop("lastfilename").contains(name)) {
			m_fileNameComboBox->setCurrentIndex(ix);
			return;
		}
		ix++;
	}

	foreach (QString name, getNewImageNames()) {
		if (prop("lastfilename").contains(name)) {
			m_fileNameComboBox->setCurrentIndex(ix);
			return;
		}
		ix++;
	}
}
int main(int argc, char** argv){
    Arguments args;
    ImageList *imagenames, *subject, *replicate;
    JetMasks masks;
    GraphDiscription gd;
    Image face;
    FaceGraph graph;
    int i;
    int imagenum = 0, numImage;
    
    processCommand(argc,argv, &args);

    masks = readMasksFile(args.masksFile);
    imagenames = getImageNames(args.imageFile, &numImage);
    
    for(subject = imagenames; subject != NULL; subject = subject->next_subject){
        for(replicate = subject; replicate != NULL; replicate = replicate->next_replicate){
            imagenum++;
            printf("Processing: %s (%5d of %5d) %5.2f%%   \n" , replicate->filename, imagenum, numImage, imagenum*100.0/numImage); fflush(stdout);

            gd = readGraphDiscription(makePath(args.graphDir,replicate->filename));
            face = readRawImage(makePath(args.imageDir,replicate->filename));
            graph = makeFaceGraph(gd->numVert, gd->numVert+gd->numEdge);
            graph->params =masks->params;

            for( i = 0; i < gd->numVert; i++){
                graph->jets[i] = extractJet(gd->verts[i].x,gd->verts[i].y,face,masks);
            }

            for( i = 0; i < gd->numEdge; i++){

                double x = 0.5*(gd->verts[gd->edges[i].vert1].x + gd->verts[gd->edges[i].vert1].x);
                double y = 0.5*(gd->verts[gd->edges[i].vert1].y + gd->verts[gd->edges[i].vert1].y);

                graph->jets[ gd->numVert + i ] = extractJet(x,y,face,masks);
            }

            saveFaceGraph(makePath(args.outputDir,replicate->filename),graph);
            freeImage(face);
            freeGraphDiscription(gd);
            freeFaceGraph(graph);
        }
    }
    printf("\n");

    return 0;
}
Exemple #6
0
void setup()
{
    SDL_Init(SDL_INIT_EVERYTHING);
    IMG_Init(IMG_INIT_PNG);

    win = SDL_CreateWindow("P53 Prototype",
            SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
            SCREEN_WIDTH, SCREEN_HEIGHT,
            SDL_WINDOW_SHOWN);

    ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);

    SDL_ShowCursor(SDL_DISABLE);

    initNodes();

    initMenu();

    loadImages( getImageNames() );
}
Exemple #7
0
/**
* This function reads in the image list file.  It then
* takes the image filenames and reads in every file.
*
* @returns A Matrix containing all of the images
*/
Matrix readImages(char *imageNamesFile, char *imageDirectory, int *numPixels, int *numImages, int *numSubjects, ImageList **srt) {
    int i;
    Matrix images;
    ImageList *subject, *replicate;

    DEBUG(1, "Reading training file names from file");

    *srt = getImageNames(imageNamesFile, numImages);

    DEBUG_CHECK(*srt, "Error: header no imagenames found in file image list file");

    /* Automatically determine number of pixels in images    */

    DEBUG(1, "Autodetecting number of pixels, i.e. vector length based on the size of image 0.");
    *numPixels = autoFileLength(makePath(imageDirectory, (*srt)->filename));
    DEBUG_INT(1, "Vector length", * numPixels);
    DEBUG_CHECK(*numPixels > 0, "Error positive value required for a Vector Length");

    /* Images stored in the columns of a matrix */
    DEBUG(1, "Allocating image matrix");
    images = makeMatrix(*numPixels, *numImages);

    i = 0;
    (*numSubjects) = 0;
    for (subject = *srt; subject; subject = subject->next_subject) {
        for (replicate = subject; replicate; replicate = replicate->next_replicate) {
            if (debuglevel > 0)
                printf("%s ", replicate->filename);
            replicate->imageIndex = i;
            readFile(makePath(imageDirectory, replicate->filename), i++, images);
        }
        if (debuglevel > 0)
            printf("\n");
        (*numSubjects)++;
    }

    return images;

}
int main(int argc, char** argv) {
    ImageList *imagenames, *subject, *replicate;
    int imageCount;
    Matrix distance;
    FaceGraph* graphs;
    char** names;
    int i, j;
    Arguments args;
    DistDirNode* distrec;

    processCommand(argc, argv, &args);

    MESSAGE("Reading in image names");
    imagenames = getImageNames(args.imageNamesFile, &imageCount);

    MESSAGE1ARG("Reading in graph files %d",imageCount);

    /* Allocate space for imagenames, face graphs and distance matrix */
    names = ALLOCATE(char*,imageCount);
    graphs = ALLOCATE(FaceGraph, imageCount);
    distance = makeZeroMatrix(imageCount,imageCount);


    MESSAGE("Reading in graph files");
    i = 0;
    for(subject = imagenames; subject != NULL; subject = subject->next_subject) {
        for( replicate = subject; replicate != NULL; replicate = replicate->next_replicate) {
            printf("Reading in graph: %s\n", replicate->filename);
            fflush(stdout);
            names[i] = strdup(replicate->filename);
            graphs[i] = loadFaceGraph(makePath(args.faceGraphDir,replicate->filename));
            i++;
        }
    }

    for(distrec = args.distList; distrec != NULL; distrec = distrec->next) {
        /* Create distance matrix */
        completed = 0;
        total = imageCount*imageCount;

        MESSAGE("Computing Distance Matrix");
        start_time = time(NULL);

        computeDistanceMatrix(distance, graphs, 0, imageCount, 0, imageCount, distrec->distMeasure);

        /* Print out distance files to the distance directory */
        for(i = 0; i < imageCount; i++) {
            FILE* distfile = fopen(makePath(distrec->distDirectory,names[i]), "w");

            if(!distfile) {
                printf("Error opening distance file: %s\n",makePath(distrec->distDirectory,names[i]));
                exit(1);
            }

            printf("Saving distances for image: %s\n",names[i]);
            fflush(stdout);

            for(j = 0; j < imageCount; j++) {
                fprintf(distfile,"%s\t%16e\n",names[j], ME(distance,i,j));
            }
            fclose(distfile);
        }
    }

    return 0;
}