imgrdbin

Capsim Block Documentation

Short Description

ead a binary image. On each visit a row is read from file. An image sample is output.

Top
Parameters
Num Description Type Name Default Value
0 Image width int pwidth 128
1 Image height int pheight 128
2 File that contains binary image file file_name test.img
3 Number of bytes to skip int skip 0
Top
States
Num Type Name Initial Value Description
0 int obufs
1 int fd
2 int numberRowsRead 0
3 char* buff
4 float** mat_PP
Top

Declarations


 

	int i,j,k;
	float x;
	int  n;
	image_t	img;



Top

Initialization Code



 

	if((fd = open(file_name,0)) == -1) {
		fprintf(stderr,"rdbinimage: cannot open file\n");
		return(1); /* file cannot be opened */
	}
	if( (obufs = NO_OUTPUT_BUFFERS()) < 1 ) {
		fprintf(stderr,"rdbinimage: no output buffers\n");
		return(2);
	}
	fprintf(stderr,"Image width= %d, height = %d \n",pwidth,pheight);
	numberRowsRead =0;
	buff = (char *) calloc(pwidth,sizeof(char));
	if(buff == NULL) {
		fprintf(stderr,"rdbinimage: can't allocate space\n");
		return(3);
	}
	for(i=0; i
    
Top

Main Code



 


while(numberRowsRead < pheight) { 
	/* 
	 * output a row 
	 */
	        n= read(fd,buff,pwidth);
		/* 
		 *
		 * increment time on output buffer(s) 
		 * and output a sample 
		 */
		for (k = 0; k< n; k++) 
			mat_PP[numberRowsRead][k]=buff[k];
		if(numberRowsRead == pheight-1) {
		  
		  for(j=0; j
    
Top

Wrapup Code



 

        /* free up allocated space      */
        close(fd);
	free(buff);
        return(0);




Top

License



/*  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
*/


Top

Description



 

/*************************************************************
			imgrdbin()
***************************************************************
Description:  Read a binary image.
	On each visit a row is read from file.
	An image sample is output.
	Auto fan-out.

imgrdbin


Description:  Read a binary image.
	On each visit a row is read from file.
	An image sample is output.
	Auto fan-out.


Programmer: Sasan Ardalan
Date: November 4, 1990 

*/