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

📄 owtrans2_alloc.c

📁 LastWave
💻 C
📖 第 1 页 / 共 2 页
字号:
  trans->wavelet = NULL;    trans->workimage = (IMAGE *) Malloc(sizeof(IMAGE)*9);  for (i=0;i<9;i++) trans->workimage[i] = NewImage();    trans->hsize = trans->vsize = trans->noct = 0;      trans->original = NewImage();    trans->subimage = NULL;  trans->coeff = NULL;   return(trans);}/* * Desallocation of the subimages */static void  DeleteSubImagesOWtrans2 (OWTRANS2 owtrans2){   int nSubbands = 3 * owtrans2->noct + 1;  int i;    if (owtrans2->subimage) {    for (i=0;i<nSubbands;i++) DeleteImage(owtrans2->subimage[i]);    Free(owtrans2->subimage);     owtrans2->subimage=NULL;  }    owtrans2->noct = 0;}/* * Sets the number of octaves and allocates in subimages 3*noct+1 images. * If ncol != 0 these images are resized to the right size for decomposition of an * original image of size ncol*nrow */void SetNOctOWtrans2(OWTRANS2 wtrans,int noct,int ncol,int nrow){  int i;  int n;    if (noct < 0) Errorf("SetNOctOWtrans2() : Bad 'noct' value '%d'",noct);    DeleteSubImagesOWtrans2(wtrans);  DeleteCoeffOWtrans2(wtrans);  wtrans->vsize = nrow;  wtrans->hsize = ncol;  wtrans->noct = noct;      if (wtrans->noct == 0) return;  n = 3 * wtrans->noct + 1;    wtrans->subimage  = (IMAGE *) Malloc(sizeof(IMAGE)*n);   for (i = wtrans->noct-1; i >=0; i--) {    wtrans->subimage[3*i+1] = NewImage();    wtrans->subimage[3*i+2] = NewImage();    wtrans->subimage[3*i+3] = NewImage();    if (ncol != 0) {      nrow = nrow/2;      ncol = ncol/2;       SizeImage(wtrans->subimage[3*i+1],ncol, nrow);      SizeImage(wtrans->subimage[3*i+2],ncol, nrow);      SizeImage(wtrans->subimage[3*i+3],ncol, nrow);    }  }    wtrans->subimage[0] = NewImage();    if (ncol != 0) SizeImage(wtrans->subimage[0],ncol, nrow);     }  /* * Desallocation of the coeffs */void  DeleteCoeffOWtrans2 (OWTRANS2 owtrans2){   int nSubbands = 3 * owtrans2->noct + 1;  int i;    if (owtrans2->coeff) {    for (i=0;i<nSubbands;i++) DeleteCoeffSet(owtrans2->coeff[i]);     Free(owtrans2->coeff);    owtrans2->coeff=NULL;  }}/* * Desallocation of a OWtrans2 */void DeleteOWtrans2(OWTRANS2 wtrans2){  int i;   RemoveRefValue(wtrans2);  if (wtrans2->nRef > 0) return;  DeleteSubImagesOWtrans2(wtrans2);  DeleteCoeffOWtrans2(wtrans2);  DeleteImage(wtrans2->original);     wtrans2->hsize = wtrans2->vsize =0;    if (wtrans2->wavelet) DeleteOWavelet2(wtrans2->wavelet);  wtrans2->wavelet = NULL;   if (wtrans2->name != defaultName)  Free(wtrans2->name);   wtrans2->name=NULL;  for (i=0;i<9;i++) DeleteImage(wtrans2->workimage[i]);  Free(wtrans2->workimage);#ifdef DEBUGALLOCDebugType = "OWtrans2";#endif    Free(wtrans2);}/* * Clear a owtrans2 */ void ClearOWtrans2(OWTRANS2 owtrans2){   int i;  DeleteSubImagesOWtrans2(owtrans2);  DeleteCoeffOWtrans2(owtrans2);  ClearImage(owtrans2->original);     owtrans2->hsize =owtrans2->vsize =0;     for (i=0;i<9;i++) ClearImage(owtrans2->workimage[i]);}  /* * Copy a WTRANS2 into another  */OWTRANS2 CopyOWtrans2(OWTRANS2 in,OWTRANS2 out){  int i;  int n;  /* Tests*/  if (in == NULL) return(NULL);  if (out == NULL) out = NewOWtrans2();  if (in == out) return(in);  ClearOWtrans2(out);    SetNOctOWtrans2(out,in->noct,in->hsize,in->vsize);  SetWaveletOWtrans2(out,in->wavelet->name);    if (in->noct != 0) {    n = 3*in->noct+1;    for (i=0;i<n;i++) CopyImage(in->subimage[i],out->subimage[i]);  }    CopyImage(in->original,out->original);     for (i=0;i<9;i++) CopyImage(in->workimage[i],out->workimage[i]);      return(out);}/* * Set the wavelet of a OWtrans2 */void SetWaveletOWtrans2 (OWTRANS2 wtrans,char * nameWavelet){  OWAVELET2 wave;      if(!nameWavelet) wave = NewOWavelet2(defaultO2WaveletName);  else wave = NewOWavelet2(nameWavelet);  if (wtrans->wavelet != NULL) DeleteOWavelet2(wtrans->wavelet);  wtrans->wavelet = wave;}/* * Check the fact that a owtrans2 is not empty */void CheckOWtrans2(OWTRANS2 wtrans){   int nrow,ncol,i,j,n;  IMAGE image1;    /*   * We check the size of each image   */  if (wtrans->subimage==NULL) Errorf("CheckOWtrans2() : The owtrans2 is empty !");    nrow = wtrans->vsize;  ncol = wtrans->hsize;  n = 3 * wtrans->noct + 1;    for (i = wtrans->noct-1; i >=0; i--) {    nrow = nrow/2;    ncol = ncol/2;     for (j=1;j<=3;j++) {      image1 = wtrans->subimage[3*i+j];      if (image1->ncol != ncol || image1->nrow != nrow) Errorf("CheckOWtrans2() : Bad size of owtrans2 subimage");    }  }   image1 = wtrans->subimage[0];  if (image1->ncol != ncol || image1->nrow != nrow) Errorf("CheckOWtrans2() : Bad size of owtrans2 subimage");}  /* * 'name' field */static char *nameDoc = "{[= <name>]} {Sets/Gets the name of a owtrans2}";static void * GetNameOWtrans2V(OWTRANS2 wtrans, void **arg){  /* Documentation */  if (wtrans == NULL) return(nameDoc);    return(GetStrField(wtrans->name,arg));}static void * SetNameOWtrans2V(OWTRANS2 wtrans, void **arg){       /* doc */  if (wtrans == NULL) return(nameDoc);  if (wtrans->name==defaultName) {    wtrans->name=CharAlloc(1);    wtrans->name[0] = '\0';  }  return(SetStrField(&(wtrans->name),arg));}/* * 'noct' field */static char *noctDoc = "{[= <noct>]} {Gets the number of octave of a 2d orthogonal wavelet transform.}";static void * GetNOctOWtrans2V(OWTRANS2 wtrans, void **arg){  /* Documentation */  if (wtrans == NULL) return(noctDoc);    return(GetIntField(wtrans->noct,arg));}/* * 'wavelet' field */static char *waveletDoc = "{[= <name>]} {Gets/Sets the analyzing wavelet used for the wavelet transform.}";static void * GetWaveletOWtrans2V(OWTRANS2 wtrans, void **arg){  /* Documentation */  if (wtrans == NULL) return(waveletDoc);    if (wtrans->wavelet == NULL) return(GetStrField("",arg));    return(GetStrField(wtrans->wavelet->name,arg));}/* * The field list */struct field fieldsOWtrans2[] = {  "", GetExtractOWtrans2V, SetExtractOWtrans2V, GetExtractOptionsOWtrans2V, GetExtractInfoOWtrans2V,  "name", GetNameOWtrans2V, SetNameOWtrans2V, NULL, NULL,  "noct", GetNOctOWtrans2V, NULL, NULL, NULL,  "wavelet", GetWaveletOWtrans2V, NULL, NULL, NULL,  NULL, NULL, NULL, NULL, NULL};/* * The type structure for OWTRANS2 */TypeStruct tsOWtrans2 = {  "{{{&owtrans2} {This type is the basic type for 2d orthogonal wavelet transforms.}}}",  /* Documentation */  &owtrans2Type,       /* The basic (unique) type name */  NULL,     /* The GetType function */                           DeleteOWtrans2,     /* The Delete function */  NewOWtrans2,     /* The Delete function */    CopyOWtrans2,       /* The copy function */  ClearOWtrans2,       /* The clear function */    ToStrOWtrans2,       /* String conversion */  PrintOWtrans2,   /* The Print function : print the object when 'print' is called */  PrintInfoOWtrans2,   /* The PrintInfo function : called by 'info' */  NumExtractOWtrans2,              /* The NumExtract function : used to deal with syntax like 10a */     fieldsOWtrans2,      /* The list of fields */}; 

⌨️ 快捷键说明

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