示例#1
0
GraphDiscription extractModelJets(ImageList* modelImages, char* imageDir, char* graphDir, JetMasks masks){
    ImageList *subject, *replicate;
    GraphDiscription mj = NULL;
    int count = 0, i;

    for(subject = modelImages; subject != NULL; subject = subject->next_subject){
        for(replicate = subject; replicate != NULL; replicate = replicate->next_replicate){
            /* load the model graph */
            GraphDiscription gd = readGraphDiscription(makePath(graphDir,replicate->filename));

            /* Load the model image */
            Image model = readRawImage(makePath(imageDir,replicate->filename));

            /*MESSAGE2ARG("Extracting Jets From Image #%d.  <%s>", count, replicate->filename);*/
            if(count == 0){
                /* load up a default graph */
                mj = readGraphDiscription(makePath(graphDir,replicate->filename));
            }
            else{
                assert(mj->numVert == gd->numVert);
                for(i = 0; i < mj->numVert; i++){
                    /* Accumulate mean locations */
                    mj->verts[i].x += gd->verts[i].x;
                    mj->verts[i].y += gd->verts[i].y;
                }
            }

            /* extract jets */
                printf("Extracting jets from model image #%03d.  <%s>  |", count, replicate->filename); fflush(stdout);
            for(i = 0; i < gd->numVert; i++){
                printf("#"); fflush(stdout);
                addJetToBunch( mj->bunch[i],
                    extractJet(gd->verts[i].x, gd->verts[i].y, model, masks));
            }
            printf("|\n");

            freeImage(model);
            freeGraphDiscription(gd);
            count++;
        }
    }

    for(i = 0; i < mj->numVert; i++){
        /* Accumulate mean locations */
        mj->verts[i].x /= count;
        mj->verts[i].y /= count;
    }

    return mj;
}
示例#2
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;
}
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;
}