Capsim Block Documentation
Read a ASCII image. Read the image and output a single image sample.
Num | Description | Type | Name | Default Value | |
---|---|---|---|---|---|
0 | File that contains image. Note width and height must be first line. | file | fileName | stdin |
Num | Type | Name | Initial Value | Description |
---|---|---|---|---|
0 | int | obufs | ||
1 | int | numberRowsRead | 0 | |
2 | float** | mat_PP | ||
3 | int | pwidth | ||
4 | int | pheight | ||
5 | int | done | 0 | |
6 | FILE* | fp |
int i,j,k; float x; int n; image_t img; |
---|
done=0; if(strcmp(fileName,"stdin") == 0) fp = stdin; else if((fp = fopen(fileName,"r")) == NULL) { fprintf(stderr,"imgrdasc: cannot open file\n"); return(1); /* file cannot be opened */ } fscanf(fp,"%d %d",&pwidth,&pheight); numberRowsRead =0; if( (obufs = NO_OUTPUT_BUFFERS()) < 1 ) { fprintf(stderr,"imgrdasc: no output buffers\n"); return(2); } mat_PP = (float**)calloc(pheight+1,sizeof(float*)); if(mat_PP == NULL) { fprintf(stderr,"imgrdasc could not allocate space \n"); return(5); } for(i=0; i |
---|
while(!done) { if(numberRowsRead >= pheight) { return(0); } /* * read a row */ for(i=0; i < pwidth; ++i) { /* Read input lines until EOF */ if(fscanf(fp,"%f",&x) == EOF){ CsInfo("imgrdasc: EOF"); done=1; } else mat_PP[numberRowsRead][i]=x; } /* * Check if all of matrix has been input. * increment time on output buffer(s) * and output a sample image */ if(numberRowsRead == pheight-1) { for(j=0; j |
---|
if (fp != stdout) fclose(fp); |
---|
/* Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks) Copyright (C) 1989-2017 Silicon DSP Corporation This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA http://www.silicondsp.com Silicon DSP Corporation Las Vegas, Nevada */ |
---|
/************************************************************* imgrdasc() *************************************************************** Description: Read a ASCII image. Read the image and output a single image sample. Auto fan-out. |
---|