⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blobdemo_ppm.c

📁 it runs for blob detection with opencv
💻 C
字号:
/***  Source file for blobdetect. (c) 2004 Per-Erik Forssen****  This program is free software; you can redistribute it and/or modify**  it under the terms of the GNU General Public License as published by**  the Free Software Foundation; either version 2 of the License, or**  (at your option) any later version.**  **  See the file COPYING for details.***/#include <stdio.h>#include <stdlib.h>#include "image_buffer.h"#include "file_and_time.h"#include "extract_blobs.h"#include "visualise.h"/***  File: blobdemo_ppm.c **  Usage: blobdemo_ppm <infile.ppm> <outfile.ppm> [<dmax>]**  (c) April 2004 Per-Erik Forssen*/int main(int argc,char *argv[]) {fpnum bkgr_green[] = {0.0,1.0,0.0}; /* Background colour */buffer *bf_image,*bf_mvec,*bf_pvec,*bf_blobimage,*bf_rimage;buffer **bl_lout,*bf_bkgr;ibuffer *bf_cert,*bf_csc,*bf_labelim;int regionfl=0;fpnum testnum;/* Parameters for the algorithm */ fpnum dmax=0.16;    /* Maximum colour distance */fpnum cmin=0.5;     /* Area threshold for pyramid generation */fpnum minc=0.5;     /* Merger threshold */int roi=0;          /* Side of spatial window (or 0 for 12 pixel roi) */int miter=5;        /* Number of m-estimation steps */int lowsc=2;        /* Finest scale to detect blobs in */int amin=20;        /* Min required area */int ssfl=0;         /* Subsample image if set */ if((argc<3)||(argc>5)) {   fprintf(stderr,"ERROR: At least two filenames should be supplied.\n");   fprintf(stderr,"Usage: %s <infile.ppm> <outfile.ppm> [<outfile2.ppm>] [<dmax>]\n",argv[0]);   exit(1); } if(argc==4) {   testnum=strtod(argv[3],(char **)NULL);   if(testnum>0) {     dmax=testnum;  /* Third arg was dmax */   } else {     regionfl=1;    /* Third arg was fname */   } } if(argc==5) {   regionfl=1;   /* Third arg was fname */   dmax=strtod(argv[4],(char **)NULL); } read_pnm_file(argv[1],argv[0],&bf_image,ssfl); /* Create certainty mask */ bf_cert=ibuffer_new(bf_image->rows,bf_image->cols,bf_image->ndim); set_to_ones(bf_cert); /* Allocate array of result pointers */ bl_lout=(buffer **)calloc(4,sizeof(buffer *)); /* Call the blob extraction function */   extract_blobs(bf_image,bf_cert,bl_lout,dmax,cmin,roi,miter,lowsc,minc,amin);   /* Extract results */ bf_mvec    = bl_lout[0]; bf_pvec    = bl_lout[1]; bf_csc     = (ibuffer *)bl_lout[2];  bf_labelim = (ibuffer *)bl_lout[3]; /* Create an empty green image */ bf_bkgr=buffer_new0(bkgr_green,3,1,1);  /* Define background */ bf_blobimage = buffer_new(bf_image->rows,bf_image->cols,bf_image->ndim);  buffer_paint(bf_blobimage,bf_bkgr);  /* Visualise blobs in the green image */ draw_ellipses(bf_blobimage,bf_mvec,bf_pvec); /* Store result as a file */ write_pnm_file(argv[2],argv[0],bf_blobimage); if(regionfl) {   /* Create an empty green image */   bf_rimage = buffer_new(bf_image->rows,bf_image->cols,bf_image->ndim);    buffer_paint(bf_rimage,bf_bkgr);    /* Visualise regions in the green image */     draw_regions(bf_rimage,bf_labelim,bf_pvec);   /* Store result as a file */   write_pnm_file(argv[3],argv[0],bf_rimage);   buffer_free(bf_rimage); } /* Free memory */ free(bl_lout); free(bf_bkgr); /* Only release struct */ buffer_free(bf_image); ibuffer_free(bf_cert); buffer_free(bf_blobimage); buffer_free(bf_mvec); buffer_free(bf_pvec); ibuffer_free(bf_csc); ibuffer_free(bf_labelim); return(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -