Copy Link
Add to Bookmark
Report

VISION-LIST Digest 1989 12 08

eZine's profile picture
Published in 
VISION LIST Digest
 · 6 Jan 2024

Vision-List Digest	Fri Dec 08 10:00:41 PDT 89 

- Send submissions to Vision-List@ADS.COM
- Send requests for list membership to Vision-List-Request@ADS.COM

Today's Topics:

Re:MATLAB
Images Wanted
Submission to vision list
Re: MATLAB

----------------------------------------------------------------------

Date: Thu, 7 Dec 89 12:25:16 EST
Subject: Re:MATLAB
From: Sridhar Ramachandran <Sridhar@UC.EDU>

Hi,

Regarding Pranata's article on Matlab.

I am not sure about the Matlab Matrix file format, but if it is
an ASCII file, then you can write a small C program that converts
your Image file (binary, usually) to an ASCII text file that MATLAB
can use.

As mentioned, there is a large body of software, going under
the name of "Video Utilities", that do the reverse ie., convert
any format to raster format.

Sridhar Ramachandran.
Knowledge-Based Computer Vision Lab,
University of Cincinnati.

Replies to: Sridhar@UC.EDU || sramacha@uceng.uc.edu

------------------------------

Date: 7 Dec 89 10:02 -0800
From: <tate@cs.sfu.ca>
Subject: Images Wanted


We are doing research on the combination of laser and intensity imagery and
are looking for registered images of all levels of quality. Can anyone help
us out? Thanks in advance.

Kevin Tate
Dept. of Computing Sciences
Simon Fraser University
Burnaby, B.C.
V5A-1S6

e-mail: tate@cs.sfu.ca

[ As usual, please post answers to the List. These types of questions are of
particular interest to the readership.
phil... ]

------------------------------

Date: Thu, 07 Dec 89 12:28:19 PST
From: rossbach%engrhub@hub.ucsb.edu
Subject: Books from Springer-Verlag

Springer Series in Perception Engineering
A Book Series from Springer-Verlag Publishers edited by Ramesh C. Jain

For Information on any of the books in this series, please send email to
rossbach@hub.ucsb or call 1-800-SPRINGER.

Perception is the process of interpreting information gathered from a
variety of sensors. As a complex set of physiological functions it plays a
vital role in our life.
In recent years, the RbiologicalS concept of perception has beem extended
to artificial perception systems. In manufacturing, productivity and quality
are being significantly improved using machine perception. Perception systems
in medicine are improving diagnostic procedures and the ability to monitor
patients. The role of robots in hazardous environments and in space is
expanding. The success of automated machinery depends critically on systems
with the ability to both sense and understand the environment and determine
appropriate action.
In the last decade, research on perception systems has received
significant attention but, unfortunately, the progress in applications has been
slow. A lack of communication between researchers and practitioners, and, more
fundamentally, the lack of a well defined discipline of RPerception
EngineeringS has created a gap between the theoretical work on perception
systems and application oriented work.
In order to realize the factories, homes, hospitals, and offices of the
future, this gap needs to be bridged. Books in the Springer Series in
Perception Engineering will emphasize not only the rigorous theoretical and
experimental characterization of perception but also the engineering, design,
and application aspects of perception systems.

Published in the series:
Paul J. Besl: Surfaces in Range Image Understanding
ISBN 96773-7 $58.00
Jorge L. C. Sanz (ed.): Advances in Machine Vision
ISBN 96822-9 $79.00
R. C. Vogt: Automatic Generation of Morphological Set Recognition
Algorithms
ISBN 97049-5 $79.00
E. P. Krotkov: Active Computer Vision by Cooperative Focus and Stereo
ISBN 97103-3 $49.00
T. -J. Fan: Describing and Recognizing 3-D Objects Using Surface
Properties
ISBN 97179-3 $39.50
R. C. Jain and A.K. Jain: Analysis and Interpretation of Range Images
ISBN 97200-5 $59.00

Coming in the series:
R. Rao: A Taxonomy for Texture Description and Identification
T. Weymouth (ed.): Exploratory Vision: The Active Eye

Related Books in production:
P. Farelle: Data Compression and Recursive Block Coding ISBN 97235-8


------------------------------

Date: Fri, 8 Dec 89 08:14:54 GMT
From: tobbe@isy.liu.se (Torbjorn Kronander)
Subject: Re: MATLAB

Adi Pranata <pranata@udel.edu> writes:

>Hi,

> I'm not sure where to posted this question, anyway Does any one
>have any info, on convert raster images/picture to matlab matrix
>format, since i am interested on use the matlab software to manipulate
>it . Since it will be no problem to display the matlab file format
>using the imagetool software. Any info including what other newsgroup
>more appropriate to posted will be welcome. Thanks in advance.

>You could reply to pranata@udel.edu

> Sincerely,

> Desiderius Adi Pranata
>PS: Electromagnetig way
> 146.955 Mhz -600 KHz
> Oldfashioned way
> (302)- 733 - 0990
> (302)- 451 - 6992

>[ This is definitely appropriate for the Vision List. Answers to the
> List please.
> phil...]


I have done lots of work using images in MATLAB. It is fairly simple
to convert any structure to a matrix (.mat file).

It is also fairly simplr to use m-files to create image display oin
a color monitor such as a color sun.

I would however be nice to use mex-files instead of m-files as I did (no
mex facility available by then).

The following is example code. I do not even assume it will work
right on, but it may suit as a basis for further work. (it works for mew)
My image reading tool is kind of special so begin with adding you r
own reading routine.

/**********************************************************************

matc.h

Routines for input/Output of MATLAB matrices.

Peter Nagy 8712xx

rewritten by Torbjorn Kronander 8712xx+eps

-changed to std unix stream routines (fopen ...)

-added return values for routines. <=0 is failure, 1 is success.


-Only ONE variable read at the time in readmat, next call
will return next variable (if any).

-Similar in writemat, subsequent calls will add new elements to already open
file.

-New parameter added to call. "ctl", ctl is one of INIT,GO,FINIT as defined

INIT is file opening
GO is read/write one variable
FINIT is close.

-transpose added to get crrespondences in arhguments in matlab and C.


KNOWN PROBLEMS
-

**********************************************************************/




/**********************************************************************

int readmat(procctltyp ctl,char* fname,int* rows,int* cols,char* varname,boolean* iflag,double* rpart,double* ipart)
procctltyp ctl;
int *rows, *col, *iflag;
char *fname, *varname;
double *rpart, *ipart;

INPUT:
ctl, one of INIT,GO,FINIT (0,1,2) as described above
fname, filename if ctl=INIT, else not used

OUTPUT:
function return negative if read failure (normally premature eof)
0 if open failure
1 if success.
*rows,*cols Number of rows and columns. (first, second C-index!)
*iflag 0 if only real part
1 if complex
*rpart Pointer to eal part matrix.
*ipart Pointer to imaginary part matrix.


SIDE EFFECTS:
Be careful if the declared number of columns does not agree with the
return from the routine (cols). Indexing will collapse

PN mod TK

**********************************************************************/


typedef int procctltyp;

#define INIT 0
#define GO 1
#define FINIT 2


extern int readmat(procctltyp ctl,char* fname,int* rows,int* cols,char* varname,boolean* iflag,double* rpart,double* ipart);



/**********************************************************************

int writemat(procctltyp ctl,char* fname,int rows,int cols,char* varname,boolean iflag,double* rpart,double* ipart)
procctltyp ctl;
int rows, cols, iflag;
char fname[], varname[];
double *rpart, *ipart;

INPUT:
ctl, One of INIT,GO,FINIT (0,1,2) as described above
fname, Filename if ctl=INIT, else not used
rows,cols Number of rows and columns. (first, second C-index!)
varname variables name (matrix name)
iflag 0 if only real part
1 if complex
*rpart Pointer to real part matrix.
*ipart Pointer to imaginary part matrix.

OUTPUT:
function return negative if write failure (normally write access trouble)
0 if open failure
1 if success.


SIDE EFFECTS:
--

PN mod TK

**********************************************************************/


extern int writemat(procctltyp ctl,char* fname,int rows,int cols,char* varname,boolean iflag,double* rpart,double* ipart);


/**********************************************************************

matc.c


Routines for input/Output of MATLAB matrices.

Peter Nagy 8712xx

rewritten by Torbjorn Kronander 8712xx+eps

-changed to std unix stream routines (fopen ...)

-added return values for routines. <=0 is failure, 1 is success.


-Only ONE variable read at the time in readmat, next call
will return next variable (if any).

-Similar in writemat, subsequent calls will add new elements to already open
file.

-New parameter added to call. "ctl", ctl is one of INIT,GO,FINIT as defined
in tkctools.h
INIT is file opening
GO is read/write one variable
FINIT is close.

-transpose added to get crrespondences in arhguments in matlab and C.


KNOWN PROBLEMS
-

**********************************************************************/



#include <stdio.h>

#define MACHINECODE 1000 /* 1000 for SUN */


/**********************************************************************

double *getadress(row,col,mat,rows,cols)
int row,col;
double *mat;

returns pointer to mat(row,col)

INPUT:
row row of index
col column of index (here row is FIRST coordinate in C!!)
mat pointer to matrix of DOUBLE!!
rows dimensionality of first index of mat.
cols dimensionality of second index of mat.

OUTPUT:
function return: pointer to double mat[row][col]

Sides:
no known (be carefuul not to index out of mat !!)

**********************************************************************/


static double *getadress(row,col,mat,rows,cols)
int row,col;
double *mat;
{
register int ipnt,icols;
register double *pnt;

icols=(int) cols;
ipnt= row * icols + col;

pnt=mat + ipnt;
return( pnt);
}

/**********************************************************************

static void transpose(rows,cols,mat)
int rows,cols;
double *mat;

Transposes a matrix

INPUT:
rows dimensionality of first index in mat
cosl same for second index
mat pointer to matrix of double

OUTPUT:
-

Sides:
The matrix mat is transposed!



**********************************************************************/



static void transpose(rows,cols,mat)
int rows,cols;
double *mat;
{
double tmp, *adr1, *adr2;
int ix,iy;

for (ix=0; ix < rows; ix++)
for (iy=ix+1; iy < cols; iy++)
{
adr1=getadress(ix,iy,mat,rows,cols);
adr2=getadress(iy,ix,mat,rows,cols);
tmp = *adr1;
*adr1 = *adr2;
*adr2 = tmp;
}
}


/**********************************************************************

int readmat(ctl,fname,rows,col,varname,iflag,rpart,ipart)
procctltyp ctl;
int *rows, *col, *iflag;
char *fname, *varname;
double *rpart, *ipart;

INPUT:
ctl, one of INIT,GO,FINIT (0,1,2) as described above
fname, filename if ctl=INIT, else not used

OUTPUT:
function return negative if read failure (normally premature eof)
0 if open failure
1 if success.
*rows,*cols Number of rows and columns. (first, second C-index!)
*iflag 0 if only real part
1 if complex
*rpart Pointer to eal part matrix.
*ipart Pointer to imaginary part matrix.


SIDE EFFECTS:
Be careful if the declared number of columns does not agree with the
return from the routine (cols). Indexing will go balooney!!

PN mod TK

**********************************************************************/



int readmat(ctl,fname,rows,cols,varname,iflag,rpart,ipart)
procctltyp ctl;
int *rows, *cols, *iflag;
char *fname, *varname;
double *rpart, *ipart;
{
int sizint,retn, inum[5], i;

static FILE *infp;

switch(ctl)
{
case INIT:
infp = fopen(strcat(fname,".mat"), "r");
if (NULL != infp)
return(1);
else
return(0);
break;
case GO:
if (5 != fread(inum,sizeof(sizint),5,infp)) return(-1);
if (MACHINECODE != inum[0]) return(-2); /* wrong machine type ! */
*rows = inum[1];
*cols = inum[2];
*iflag= inum[3];

/* Real part */
retn=fread(varname,1, inum[4], infp);
if (inum[4] != retn) return(-3);
retn=fread(rpart,8,(*rows)*(*cols),infp);
if ((*rows)*(*cols) != retn) return(-4);

if ( (*rows >1) && (*cols>1)){
transpose(*rows,*cols,rpart);
}

/* Complex part */
if (*iflag) {
if (ipart == NULL) return(-5);
retn=fread(ipart,8,(*rows)*(*cols),infp);
if ((*rows)*(*cols) != retn) return(-6);
if ( (*rows >1) && (*cols>1)){
transpose(*rows,*cols,ipart);
}
}
return(1);
break;

case FINIT:
fclose(infp);
return(1);
}
}


/**********************************************************************

int writemat(ctl,fname,rows,cols,varname,iflag,rpart,ipart)
procctltyp ctl;
int rows, cols, iflag;
char fname[], varname[];
double *rpart, *ipart;

INPUT:
ctl, One of INIT,GO,FINIT (0,1,2) as described above
fname, Filename if ctl=INIT, else not used
rows,cols Number of rows and columns. (first, second C-index!)
varname variables name (matrix name)
iflag 0 if only real part
1 if complex
*rpart Pointer to real part matrix.
*ipart Pointer to imaginary part matrix.

OUTPUT:
function return negative if write failure (normally write access trouble)
0 if open failure
1 if success.


SIDE EFFECTS:
--

PN mod TK

**********************************************************************/


int writemat(ctl,fname,rows,cols,varname,iflag,rpart,ipart)
procctltyp ctl;
int rows, cols, iflag;
char fname[], varname[];
double *rpart, *ipart;

{
int sizint,retn, inum[5], i;
static FILE *outfp;
char filename[100];

switch(ctl)
{
case INIT:
strcpy(filename,fname);
outfp = fopen(strcat(filename,".mat"), "w");
if (outfp != NULL)
return(1);
else
return(0);
break;
case GO:
if ( (rows >1) && (cols>1)){
transpose(rows,cols,rpart);
if (iflag) transpose(rows,cols,ipart);
}

inum[0]=MACHINECODE;
inum[1]=rows;
inum[2]=cols;
inum[3]=iflag;
inum[4]=strlen(varname)+1;

retn=fwrite(inum,4,5,outfp);
if (5 != retn) return(-1);
#ifdef PRINTDEB
printf("inum %d %d %d %d %d\n",inum[0],inum[1],inum[2],inum[3],inum[4]);
printf("retn (inum) %d \n",retn);
#endif

retn=fwrite(varname,1, inum[4], outfp);
if (inum[4] != retn) return(-2);
#ifdef PRINTDEB
printf("varname %d\n",retn);
#endif

/* Real part */
retn=fwrite(rpart,8,rows*cols,outfp);
if (rows*cols != retn) return(-3);
#ifdef PRINTDEB
printf("real part %d\n",retn);
#endif

/* Complex part */
if (iflag) {
if (ipart == NULL) return(-4);
retn=fwrite(ipart,8,(rows)*(cols),outfp);
if (rows*cols != retn) return(-5);
}

if ( (rows >1) && (cols>1)){
transpose(rows,cols,rpart); /* redo rpart and ipart to original */
if (iflag) transpose(rows,cols,ipart);
}

return(1);
break;

case FINIT:
fclose(outfp);
return(1);
}
} /* writemat */


/* imtomat.c */
/**********************************************************************

Converts an image file (256 x 256) to a matlab .mat file.

Tobbe K 880123

**********************************************************************/


#include <stdio.h>
#include <string.h>



im256typ ima;
double fima[256][256];

main(argc,argv)
int argc;
char *argv[];

{
int ix,iy;
char fname[100];


/* THIS IS WHERE YOUR WORK GOES...
readopenim256("");
*/


printf("Matlab filename without extension (.mat assumed)>");
scanf("%s",fname);



/* THIS IS WHERE YOUR WORK GOES...
readim256(ima);
*/


for (ix=0; ix <= 255; ix++)
for (iy=0; iy <=255; iy++)
fima[ix][iy]=ima[ix][iy];

if (1 != writemat(INIT,fname,256,256,fname,FALSE,fima,NULL)) {
printf("Error in open of tstmat!!");
exit(1);
}

if (1 != writemat(GO,fname,256,256,fname,FALSE,fima,NULL)) {
printf("Error in write of tstmat!!");
exit(2);
}
}




/**********************************************************************

mat2im.c

Converts a matlab matrix .mat file to a info standard .256 file

Note must be 256 x 256 image presently !!

Tobbe 880122

**********************************************************************/


#include <stdio.h>
#include <math.h>
#include <string.h>


im256typ ima;
double fima[256][256];

main(argc,argv)
int argc;
char *argv[];

{
int ret,xrows,yrows,iflag;
register int ix,iy,tmpi;
float ifima;
char varname[30],fname[30];
double fa[3][3];

if (argc > 0) {
strcpy(fname,argv[1]);
}
else {
printf("Filename without extension (.256 and .mat assumed)>");
scanf("%s",fname);
}

xrows=256;
yrows=256;

/* THIS IS WHERE YOUR WORK GOES...

if (!writeopenim256(fname)) {
printf("Sorry there was some error in open of image file/n");
exit(1);
}

if (1 != readmat(INIT,fname,&xrows,&yrows,varname,&iflag,fima,&ifima)) {
printf("Error in open of %s.mat",fname);
exit(2);
}
*/


do
{
if (1 != readmat(GO,fname,&xrows,&yrows,varname,&iflag,fima,&ifima)) {
break;
}

printf("varname is: %s, iflag is; %d, xdim,ydim are (%d,%d)\n"
,varname,iflag,xrows,yrows);

for (ix=0; ix < 256; ix++)
for (iy=0; iy < 256; iy++) {
tmpi=rint(fima[ix][iy]);
ima[ix][iy]=MAX(0,MIN(255,tmpi));
}

/* THIS IS WHERE YOUR WORK GOES...
writeim256(ima);
*/


}
while (ret =1);

}



Torbjorn Kronander tobbe@isy.liu.se
Dept. of EE Linkoping University Sweden
ph +46 13 28 22 07


------------------------------

End of VISION-LIST
********************

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT