本文整理汇总了C++中VError函数的典型用法代码示例。如果您正苦于以下问题:C++ VError函数的具体用法?C++ VError怎么用?C++ VError使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadSlicetimes
/*
** read slice onset times from ASCII file, if not in header
*/
float *
ReadSlicetimes(VString filename) {
FILE *fp;
int i, j, id, n = 256;
float onset;
float *onset_array = NULL;
char buf[LEN];
onset_array = (float *) VCalloc(n, sizeof(float));
fp = fopen(filename, "r");
if(!fp)
VError(" error opening file %s", filename);
/* fprintf(stderr," reading file: %s\n",filename); */
i = 0;
while(!feof(fp)) {
if(i >= n)
VError(" too many lines in file %s, max is %d", filename, n);
for(j = 0; j < LEN; j++)
buf[j] = '\0';
fgets(buf, LEN, fp);
if(buf[0] == '%' || buf[0] == '#')
continue;
if(strlen(buf) < 2)
continue;
if(sscanf(buf, "%f", &onset) != 1)
VError(" line %d: illegal input format", i + 1);
onset_array[i] = onset;
i++;
}
fclose(fp);
return onset_array;
}
示例2: VDTDilate
/*!
\fn VImage VDTDilate(VImage src,VImage dest,VDouble radius)
\brief 3D morphological dilation
\param src input image (bit repn)
\param dest output image (bit repn)
\param radius radius of the spherical structural element
*/
VImage
VDTDilate(VImage src,VImage dest,VDouble radius)
{
VImage float_image;
VBit *bin_pp;
VFloat *float_pp;
int i,nbands,nrows,ncols,npixels;
if (VPixelRepn(src) != VBitRepn)
VError("Input image must be of type VBit");
nbands = VImageNBands(src);
nrows = VImageNRows(src);
ncols = VImageNColumns(src);
npixels = nbands * nrows * ncols;
float_image = VChamferDist3d(src,NULL,VFloatRepn);
if (! float_image)
VError("VDTDilate failed.\n");
dest = VSelectDestImage("VDTDilate",dest,nbands,nrows,ncols,VBitRepn);
if (! dest) return NULL;
float_pp = (VFloat *) VPixelPtr(float_image,0,0,0);
bin_pp = (VBit *) VPixelPtr(dest,0,0,0);
for (i=0; i<npixels; i++)
*bin_pp++ = ((*float_pp++ > radius) ? 0 : 1);
VDestroyImage(float_image);
VCopyImageAttrs (src,dest);
return dest;
}
示例3: main
int main(int argc, char **argv) {
static VString filename = "";
static VLong neighb = 2;
static VLong iter = 1;
static VOptionDescRec options[] = {
{
"n", VLongRepn, 1, &neighb, VOptionalOpt, TYPDict,
"type of neighbourhood used for smoothing"
},
{
"iter", VLongRepn, 1, &iter, VOptionalOpt, NULL,
"number of iterations"
},
{
"image", VStringRepn, 1, &filename, VOptionalOpt, NULL,
"grey value image"
},
};
FILE *in_file, *out_file, *fp;
VAttrList list, list1;
VImage src = NULL, dest, image = NULL;
VAttrListPosn posn;
/* Parse command line arguments: */
VParseFilterCmd(VNumber(options), options, argc, argv, &in_file, &out_file);
/* Read transformation image: */
fp = VOpenInputFile(filename, TRUE);
list1 = VReadFile(fp, NULL);
if(! list1)
VError("Error reading image");
fclose(fp);
for(VFirstAttr(list1, & posn); VAttrExists(& posn); VNextAttr(& posn)) {
if(VGetAttrRepn(& posn) != VImageRepn)
continue;
VGetAttrValue(& posn, NULL, VImageRepn, & image);
if(VPixelRepn(image) != VUByteRepn)
continue;
VGetAttrValue(& posn, NULL, VImageRepn, & image);
break;
}
if(image == NULL)
VError(" image not found");
/* Read source image(s): */
if(!(list = VReadFile(in_file, NULL)))
exit(1);
for(VFirstAttr(list, & posn); VAttrExists(& posn); VNextAttr(& posn)) {
if(VGetAttrRepn(& posn) != VImageRepn)
continue;
VGetAttrValue(& posn, NULL, VImageRepn, & src);
dest = VTopSmoothImage3d(src, image, NULL, neighb, iter);
if(dest == NULL)
exit(1);
VSetAttrValue(& posn, NULL, VImageRepn, dest);
VDestroyImage(src);
}
/* Write the results to the output file: */
if(VWriteFile(out_file, list))
fprintf(stderr, "%s: done.\n", argv[0]);
return 0;
}
示例4: VRead2ndLevel
/*
** read a 2nd level design file
*/
VImage
VRead2ndLevel(FILE *fp) {
VImage dest = NULL;
int i, j, nrows, ncols;
float val;
char buf[LEN], token[32];
nrows = ncols = 0;
while(!feof(fp)) {
memset(buf, 0, LEN);
if(!fgets(buf, LEN, fp))
break;
if(strlen(buf) < 1)
continue;
if(buf[0] == '%')
continue;
j = 0;
while(VStringToken(buf, token, j, 30)) {
if(!sscanf(token, "%f", &val))
VError("illegal input string: %s", token);
j++;
}
if(ncols == 0)
ncols = j;
if(j < 1)
continue;
else if(ncols != j)
VError(" inconsistent number of columns in row %d", nrows + 1);
nrows++;
}
rewind(fp);
dest = VCreateImage(1, nrows, ncols, VFloatRepn);
VFillImage(dest, VAllBands, 0);
VSetAttr(VImageAttrList(dest), "modality", NULL, VStringRepn, "X");
VSetAttr(VImageAttrList(dest), "name", NULL, VStringRepn, "X");
VSetAttr(VImageAttrList(dest), "ntimesteps", NULL, VLongRepn, (VLong)VImageNRows(dest));
VSetAttr(VImageAttrList(dest), "nsessions", NULL, VShortRepn, (VShort)1);
VSetAttr(VImageAttrList(dest), "designtype", NULL, VShortRepn, (VShort)2);
i = 0;
while(!feof(fp)) {
memset(buf, 0, LEN);
if(!fgets(buf, LEN, fp))
break;
if(strlen(buf) < 1)
continue;
if(buf[0] == '%')
continue;
j = 0;
while(VStringToken(buf, token, j, 30)) {
sscanf(token, "%f", &val);
VPixel(dest, 0, i, j, VFloat) = val;
j++;
}
if(j < 1)
continue;
i++;
}
return dest;
}
示例5: main
int
main(int argc, char *argv[]) {
static VString filename = "";
static VBoolean fisher = FALSE;
static VShort minval = 0;
static VOptionDescRec options[] = {
{"mask", VStringRepn, 1, (VPointer) &filename, VRequiredOpt, NULL, "mask"},
{"fisher", VBooleanRepn, 1, (VPointer) &fisher, VOptionalOpt, NULL, "Whether to do fisher transform"},
{"minval", VShortRepn, 1, (VPointer) &minval, VOptionalOpt, NULL, "signal threshold"}
};
FILE *in_file, *out_file, *fp;
VAttrList list = NULL, list1 = NULL, list2 = NULL;
VAttrListPosn posn;
VImage dest = NULL, mask = NULL;
char prg_name[100];
char ver[100];
getLipsiaVersion(ver, sizeof(ver));
sprintf(prg_name, "vsimmat V%s", ver);
fprintf(stderr, "%s\n", prg_name);
VParseFilterCmd(VNumber(options), options, argc, argv, &in_file, &out_file);
/*
** read mask
*/
fp = VOpenInputFile(filename, TRUE);
list1 = VReadFile(fp, NULL);
if(! list1)
VError("Error reading mask file");
fclose(fp);
for(VFirstAttr(list1, & posn); VAttrExists(& posn); VNextAttr(& posn)) {
if(VGetAttrRepn(& posn) != VImageRepn)
continue;
VGetAttrValue(& posn, NULL, VImageRepn, & mask);
if(VPixelRepn(mask) != VBitRepn) {
mask = NULL;
continue;
}
}
if(mask == NULL)
VError(" no mask found");
/*
** read functional data
*/
if(!(list = VReadFile(in_file, NULL)))
exit(1);
fclose(in_file);
/*
** process
*/
dest = SimilarityMatrix(list, mask, minval, fisher);
list2 = VCreateAttrList();
VAppendAttr(list2, "matrix", NULL, VImageRepn, dest);
VHistory(VNumber(options), options, prg_name, &list, &list2);
if(! VWriteFile(out_file, list2))
exit(1);
fprintf(stderr, "%s: done.\n", argv[0]);
return 0;
}
示例6: VSelSlices
VImage
VSelSlices (VImage src,VImage dest,VShort first,VShort last)
{
int nbands,nrows,ncols,nbands_neu,npixels;
int i,b,bn;
VRepnKind repn;
nbands = VImageNBands(src);
nrows = VImageNRows(src);
ncols = VImageNColumns(src);
repn = VPixelRepn(src);
if (first < 0) VError("VSelSlices: parameter <first> must be positive");
if (last < 0) last = nbands-1;
if (last >= nbands) last = nbands-1;
if (first > last)
VError("VSelSlices: <first> must be less than <last>.");
nbands_neu = last - first + 1;
if (dest == NULL)
dest = VCreateImage(nbands_neu,nrows,ncols,repn);
npixels = nrows * ncols;
#define SelSlices(type) \
{ \
type *src_pp, *dest_pp; \
bn = 0; \
for (b=first; b<=last; b++) { \
src_pp = VPixelPtr(src,b,0,0); \
dest_pp = VPixelPtr(dest,bn,0,0); \
for (i=0; i<npixels; i++) *dest_pp++ = *src_pp++; \
bn++; \
} \
}
/* Instantiate the macro once for each source pixel type: */
switch (repn) {
case VBitRepn: SelSlices (VBit); break;
case VUByteRepn: SelSlices (VUByte); break;
case VSByteRepn: SelSlices (VSByte); break;
case VShortRepn: SelSlices (VShort); break;
case VLongRepn: SelSlices (VLong); break;
case VFloatRepn: SelSlices (VFloat); break;
case VDoubleRepn: SelSlices (VDouble); break;
default: ;
}
/* Let the destination inherit any attributes of the source image: */
VCopyImageAttrs (src, dest);
return dest;
}
示例7: ReadField
void ReadField (VString Name, VImage& X, VImage& Y, VImage& Z, VAttrList& history_list)
{
FILE* file; /* input file */
VAttrList list; /* attribute list */
VAttrListPosn pos; /* position in list */
/* initialize results */
X = Y = Z = NULL;
/* open file */
file = fopen (Name, "r");
if (!file)
{
VError ("Failed to open input file '%s'", Name);
return;
}
/* read file */
list = VReadFile (file, NULL);
if (!list)
{
VError ("Failed to read input file '%s'", Name);
fclose (file);
return;
}
/* Read History */
history_list = VCopyAttrList(VReadHistory(&list));
/* extract field images */
if (VLookupAttr (list, "X", &pos))
{
VGetAttrValue (&pos, NULL, VImageRepn, &X);
VSetAttrValue (&pos, NULL, VImageRepn, NULL);
}
else VError ("Input file '%s' does not contain an image 'X'", Name);
if (VLookupAttr (list, "Y", &pos))
{
VGetAttrValue (&pos, NULL, VImageRepn, &Y);
VSetAttrValue (&pos, NULL, VImageRepn, NULL);
}
else VError ("Input file '%s' does not contain an image 'Y'", Name);
if (VLookupAttr (list, "Z", &pos))
{
VGetAttrValue (&pos, NULL, VImageRepn, &Z);
VSetAttrValue (&pos, NULL, VImageRepn, NULL);
}
else VError ("Input file '%s' does not contain an image 'Z'", Name);
/* clean-up*/
VDestroyAttrList (list);
fclose (file);
} /* ReadField */
示例8: throw
void
VImage::call_option_string( const char *operation_name,
const char *option_string, VOption *options )
throw( VError )
{
VipsOperation *operation;
VIPS_DEBUG_MSG( "vips_call_by_name: starting for %s ...\n",
operation_name );
if( !(operation = vips_operation_new( operation_name )) ) {
if( options )
delete options;
throw( VError() );
}
/* Set str options before vargs options, so the user can't
* override things we set deliberately.
*/
if( option_string &&
vips_object_set_from_string( VIPS_OBJECT( operation ),
option_string ) ) {
vips_object_unref_outputs( VIPS_OBJECT( operation ) );
g_object_unref( operation );
delete options;
throw( VError() );
}
if( options )
options->set_operation( operation );
/* Build from cache.
*/
if( vips_cache_operation_buildp( &operation ) ) {
vips_object_unref_outputs( VIPS_OBJECT( operation ) );
delete options;
throw( VError() );
}
/* Walk args again, writing output.
*/
if( options )
options->get_operation( operation );
/* We're done with options!
*/
delete options;
/* The operation we have built should now have been reffed by
* one of its arguments or have finished its work. Either
* way, we can unref.
*/
g_object_unref( operation );
}
示例9: VReadObjectData
/*
** read several rows of data from a file
*/
void
VReadObjectData (FILE *fp,int object_id,VImage *image)
{
static VImageInfo imageInfo;
static VAttrList list=NULL;
fseek(fp,0L,SEEK_SET);
if (! ReadHeader (fp)) VError("error reading header");
if (! (list = ReadAttrList (fp)))
VError("error reading attr list");
if (! VGetImageInfo(fp,list,object_id,&imageInfo))
VError(" error reading image info");
if (imageInfo.nbands != VImageNBands((*image)))
VError("incorrect number of bands");
if (imageInfo.nrows != VImageNRows((*image)))
VError("incorrect number of rows");
if (imageInfo.ncolumns != VImageNColumns((*image)))
VError("incorrect number of columns");
if (imageInfo.repn != VPixelRepn((*image)))
VError("incorrect pixel representation");
if (! VReadBlockData (fp,&imageInfo,0,imageInfo.nrows,image))
VError(" error reading data");
}
示例10: ReadImages
void ReadImages (VString Name, VAttrList& Images, VAttrList& history_list)
{
FILE* file; /* input file */
VAttrList list, list1; /* attribute list */
VAttrListPosn pos; /* position in list */
VImage image; /* image in list */
/* initialize results */
Images = NULL;
/* open file */
file = fopen (Name, "r");
if (!file)
{
VError ("Failed to open input file '%s'", Name);
return;
}
/* read file */
list = VReadFile (file, NULL);
if (!list)
{
VError ("Failed to read input file '%s'", Name);
fclose (file);
return;
}
/* Read History */
list1 = VReadHistory(&list);
if (list1==NULL) list1=VCreateAttrList();
history_list = VCopyAttrList(list1);
/* extract images */
for (VFirstAttr (list, &pos); VAttrExists (&pos); VNextAttr (&pos))
{
if (VGetAttrRepn (&pos) != VImageRepn) continue;
if (!Images) Images = VCreateAttrList ();
VGetAttrValue (&pos, NULL, VImageRepn, &image);
VSetAttrValue (&pos, NULL, VImageRepn, NULL);
VAppendAttr (Images, "image", NULL, VImageRepn, image);
}
if (!Images) VError ("Input file '%s' does not contain an image", Name);
/* clean-up*/
VDestroyAttrList (list);
fclose (file);
} /* ReadImages */
示例11: VFillImage
VImage VImageManager::vtimestep( VAttrList list, VImage dest, int step )
{
VFillImage( dest, VAllBands, 0 );
VPointer src_pp = NULL;
VPointer dest_pp = NULL;
VAttrListPosn posn;
VShort *ptr1 = NULL;
VShort *ptr2 = NULL;
VString str;
VImage src;
int n = 0;
int npixels = 0;
bool revert = false;
for ( VFirstAttr ( list, & posn ); VAttrExists ( & posn ); VNextAttr ( & posn ) ) {
if ( VGetAttrRepn ( & posn ) != VImageRepn )
continue;
VGetAttrValue ( &posn, NULL, VImageRepn, &src );
if ( VPixelRepn( src ) != VShortRepn )
continue;
if ( ( VGetAttr ( VImageAttrList ( src ), "MPIL_vista_0", NULL,
VStringRepn, ( VPointer ) & str ) != VAttrFound ) &&
( VGetAttr ( VImageAttrList ( src ), "repetition_time", NULL,
VStringRepn, ( VPointer ) & str ) != VAttrFound ) )
continue;
/* doch nicht rumdrehen!
if (VGetAttr (VImageAttrList (src), "extent", NULL,
VStringRepn, (VPointer) & str) != VAttrFound)
revert = true;
*/
if ( n == 0 )
VCopyImageAttrs ( src, dest );
if ( VImageNRows( src ) > 1 ) {
if ( VSelectBand ( "vtimestep", src, step, &npixels, &src_pp ) == FALSE )
VError( "err reading data" );
int destBand = ( revert ) ? VImageNBands( dest ) - n - 1 : n;
dest_pp = VPixelPtr( dest, destBand, 0, 0 );
ptr1 = ( VShort * ) src_pp;
ptr2 = ( VShort * ) dest_pp;
memcpy ( ptr2, ptr1, npixels * sizeof( VShort ) );
}
n++;
}
return dest;
}
示例12: main
int
main (int argc,char *argv[])
{
static VFloat sigma = 1.5;
static VOptionDescRec options[] = {
{"sigma",VFloatRepn,1,(VPointer) &sigma,VOptionalOpt,NULL,"std dev"}
};
FILE *in_file,*out_file;
VAttrList list=NULL;
VAttrListPosn posn;
VImage src=NULL,dest=NULL;
char prg[50];
sprintf(prg,"vgauss2d V%s", getVersion());
fprintf (stderr, "%s\n", prg);
VParseFilterCmd (VNumber (options),options,argc,argv,&in_file,&out_file);
if (! (list = VReadFile (in_file, NULL))) exit (1);
fclose(in_file);
for (VFirstAttr (list, & posn); VAttrExists (& posn); VNextAttr (& posn)) {
if (VGetAttrRepn (& posn) != VImageRepn) continue;
VGetAttrValue (& posn, NULL,VImageRepn, & src);
dest = VFilterGauss2d (src,NULL,(double)sigma);
VSetAttrValue (& posn, NULL,VImageRepn,dest);
}
if (src == NULL) VError(" no input image found");
VHistory(VNumber(options),options,prg,&list,&list);
if (! VWriteFile (out_file, list)) exit (1);
fprintf (stderr, "%s: done.\n", argv[0]);
return 0;
}
示例13: FreeAttrValue
static void FreeAttrValue (VStringConst routine, VAttrRec *a)
{
VTypeMethods *methods;
switch (a->repn) {
case VAttrListRepn:
VDestroyAttrList (a->value);
break;
case VBundleRepn:
VDestroyBundle (a->value);
break;
case VPointerRepn:
case VStringRepn:
break;
default:
if (! (methods = VRepnMethods (a->repn)))
VError ("%s: %s attribute has invalid repn %d",
routine, a->name, a->repn);
(methods->destroy) (a->value);
}
}
示例14: main
int
main(int argc, char *argv[]) {
static VString cfile = "";
static VFloat tr = 2;
static VBoolean normalize = FALSE;
static VOptionDescRec options[] = {
{"in", VStringRepn, 1, (VPointer) &cfile, VRequiredOpt, NULL, "file"},
{"tr", VFloatRepn, 1, (VPointer) &tr, VRequiredOpt, NULL, "TR in seconds"},
{"normalize", VBooleanRepn, 1, (VPointer) &normalize, VOptionalOpt, NULL, "Whether to normalize"}
};
FILE *out_file = NULL;
VAttrList list = NULL;
VImage dest = NULL;
char prg_name[100];
char ver[100];
getLipsiaVersion(ver, sizeof(ver));
sprintf(prg_name, "vcovariates V%s", ver);
fprintf(stderr, "%s\n", prg_name);
VParseFilterCmd(VNumber(options), options, argc, argv, NULL, &out_file);
if(tr > 500)
VError(" tr must be given in seconds, not milliseconds");
dest = VCovariates(cfile, tr, normalize);
list = VCreateAttrList();
VAppendAttr(list, "image", NULL, VImageRepn, dest);
/* Output: */
if(! VWriteFile(out_file, list))
exit(1);
fprintf(stderr, " %s: done.\n", argv[0]);
return 0;
}
示例15: VCCM2
/*
** concordance mapping
*/
VImage VCCM2(float *A1,float *A2,VImage map,int type)
{
VImage dest=NULL;
size_t b,r,c,i,j,k,kk,nvoxels;
int nslices=0,nrows=0,ncols=0;
double *arr1=NULL,*arr2=NULL,u;
nslices = VPixel(map,0,3,0,VShort);
nrows = VPixel(map,0,3,1,VShort);
ncols = VPixel(map,0,3,2,VShort);
nvoxels = VImageNColumns(map);
dest = VCreateImage(nslices,nrows,ncols,VFloatRepn);
VFillImage(dest,VAllBands,0);
VCopyImageAttrs (map, dest);
VSetAttr(VImageAttrList(dest),"modality",NULL,VStringRepn,"conimg");
arr1 = (double *) VCalloc(nvoxels,sizeof(double));
arr2 = (double *) VCalloc(nvoxels,sizeof(double));
fprintf(stderr," concordance mapping...\n");
for (i=0; i<nvoxels; i++) {
if (i%50 == 0) fprintf(stderr," %6d of %d\r",i,nvoxels);
b = (int)VPixel(map,0,0,i,VShort);
r = (int)VPixel(map,0,1,i,VShort);
c = (int)VPixel(map,0,2,i,VShort);
for (j=0; j<nvoxels; j++) arr1[j] = arr2[j] = 0;
kk = 0;
for (j=0; j<i; j++) {
k=j+i*(i+1)/2;
arr1[kk] = (double)A1[k];
arr2[kk] = (double)A2[k];
kk++;
}
for (j=i+1; j<nvoxels; j++) {
k=i+j*(j+1)/2;
arr1[kk] = (double)A1[k];
arr2[kk] = (double)A2[k];
kk++;
}
u = 0;
switch (type) {
case 0:
u = kendall(arr1,arr2,nvoxels);
break;
case 1:
u = CCC(arr1,arr2,nvoxels);
break;
default:
VError("illegal type");
}
VPixel(dest,b,r,c,VFloat) = (VFloat)u;
}
fprintf(stderr,"\n");
return dest;
}