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

📄 owtrans2_alloc.c

📁 LastWave
💻 C
📖 第 1 页 / 共 2 页
字号:
/*..........................................................................*//*                                                                          *//*      L a s t W a v e    P a c k a g e 'owtrans2d' 2.1                    *//*                                                                          *//*      Copyright (C) 1998-2002 Geoff Davis, Emmanuel Bacry, Jerome Fraleu. *//*                                                                          *//*      The original program was written in C++ by Geoff Davis.             *//*      Then it has been translated in C and adapted to LastWave by         *//*      J. Fraleu and E. Bacry.                                             *//*                                                                          *//*      If you are interested in the C++ code please go to                  *//*          http://www.cs.dartmouth.edu/~gdavis                             *//*                                                                          *//*      emails : geoffd@microsoft.com                                       *//*               fraleu@cmap.polytechnique.fr                               *//*               lastwave@cmap.polytechnique.fr                             *//*                                                                          *//*..........................................................................*//*                                                                          *//*      This program is a free software, you can redistribute it and/or     *//*      modify it under the terms of the GNU General Public License as      *//*      published by the Free Software Foundation; either version 2 of the  *//*      License, or (at your option) any later version                      *//*                                                                          *//*      This program 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 General Public License for more details.                        *//*                                                                          *//*      You should have received a copy of the GNU General Public License   *//*      along with this program (in a file named COPYRIGHT);                *//*      if not, write to the Free Software Foundation, Inc.,                *//*      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA             *//*                                                                          *//*..........................................................................*/#include "lastwave.h"#include "int_fsilist.h"#include "owtrans2d.h"#include "compress2d.h"extern OWAVELET2  NewOWavelet2(char * nameFilterset);extern void DeleteOWavelet2(OWAVELET2 w);static char defaultName[] = "";char *owtrans2Type = "&owtrans2";/* * Get the current wtransform  * (generate an error if there is none) */ OWTRANS2 GetOWtrans2Cur(void){  OWTRANS2 wtrans;  if (!ParseTypedValLevel_(levelCur, "objCur", NULL, (VALUE *) &wtrans, owtrans2Type)) Errorf1("");  AddRefValue( wtrans);  TempValue( wtrans);     return(wtrans);}/* * Answers to the different print messages */ void PrintOWtrans2(OWTRANS2 wtrans){  if (wtrans->name == NULL)    Printf("<&owtrans2[%d];%p>\n",wtrans->noct,wtrans);  else    Printf("<'%s';&wtrans[%d];%p>\n",wtrans->name,wtrans->noct,wtrans);}char *ToStrOWtrans2(OWTRANS2 wtrans, char flagShort){  static char str[30];    if (wtrans->name == defaultName) {    sprintf(str,"<&owtrans2;%p>",wtrans);  }  else {    sprintf(str,"<&owtrans2;%s>",wtrans->name);  }    return(str);}void PrintInfoOWtrans2(OWTRANS2 wtrans){  Printf("  number of octave  :  %2d\n",wtrans->noct);  if (wtrans->wavelet != NULL)     Printf("  wavelet    :  %s\n",wtrans->wavelet->name);  }/* * NumExtraction * * (10a, 20, 31,...) */static IMAGE Extract(OWTRANS2 wtrans,int o, int v){  int numSubband;  if (o < 0 || o > wtrans->noct) {    if (wtrans->noct != 0) SetErrorf("Octave index '%d' out of range : should be in [0,%d]",o,wtrans->noct);    else SetErrorf("Octave index '%d' out of range : should be 0",o);    return(NULL);  }  if (o> 0 && (v < 0 || v >= 4)) {    SetErrorf("Orientation number '%d' out of range : should be in [0,%d]",v,3);    return(NULL);  }  if (o == 0 && (v < 0 || v >= 10)) {    SetErrorf("Orientation number '%d' out of range : should be in [0,%d]",v,9);    return(NULL);  }   if (o == 0 && v == 0) return(wtrans->original);  else if (o == 0) return(wtrans->workimage[v-1]);  else {    numSubband = wtrans->noct*3 - 3*o+v;    return(wtrans->subimage[numSubband]);  }}static char *numdoc = "The syntax <i><j> refers to the image which corresponds to octave <i> and orientation <j>. The octave number <i> ranges between [1,noct]. \The orientation number <j> is 1,2 or 3 (0 corresponds to the projection on V_i). The image 0 corresponds to the analyzed image. \The images 1,2,...9 are working images that are not used by the wavelet transform algorithm.";static void *NumExtractOWtrans2(OWTRANS2 wtrans,void **arg){  int n;  char flagDot;  int v;  int o;  VALUE val;       /* doc */  if (wtrans == NULL) return(numdoc);  n = ARG_NE_GetN(arg);  flagDot = ARG_NE_GetFlagDot(arg);  v = n%10;  o = n/10;  if (flagDot == YES) {    SetErrorf("No '.' allowed in this syantax");    return(NULL);  }  val = (VALUE) Extract(wtrans,o,v);  if (val == NULL) return(NULL);    ARG_NE_SetResValue(arg,val);  return(imageiType);}/* * Basic function to call to get the image at octave 'oct' and orientation 'orient' */IMAGE GetOWtrans2Image(OWTRANS2 wtrans, int oct, int orient){  IMAGE i;    i = Extract(wtrans,oct,orient);    if (i == NULL) Errorf1("");    return(i);  }/* * Get the options for extraction : There is none !! */static void *GetExtractOptionsOWtrans2V(OWTRANS2 wtrans, void **arg){  static char *extractOptionsOWtrans2[] = {NULL};  return(extractOptionsOWtrans2);}/* * Function to get the ExtractInfo  */static void *GetExtractInfoOWtrans2V(OWTRANS2 wtrans, void **arg){  char *field =  ARG_EI_GetField(arg);  unsigned long *options = ARG_EI_GetPOptions(arg);  static ExtractInfo extractInfo;  static char flagInit = YES;    /* Init of the extraction info */  if (flagInit) {    extractInfo.nSignals = 1;    extractInfo.dx = 1;    extractInfo.xmin = 0;    extractInfo.flags = EIIntIndex | EIErrorBound;    flagInit = NO;  }  extractInfo.xmax = MAX(wtrans->noct,9);  return(&extractInfo);}/* * Extraction */static char *doc = "{[oct,orient]} {it returns the image which corresponds to octave <oct> and orientation <orient>. The octave number <oct> ranges between [1,noct]. \The orientation number <orient> is 1,2 or 3 (and 0 corresponds to the projection on V_oct). The image [0,0] corresponds to the analyzed image. \The images [0,1],[0,2],...,[0,9] are working images that are not used by the wavelet transform algorithm.}";  static void *GetExtractOWtrans2V(OWTRANS2 wtrans, void **arg){  char *field;  FSIList *fsiList;  IMAGE i;  int o,v;   /* doc */  if (wtrans == NULL) return(doc);    field = ARG_G_GetField(arg);  fsiList = ARG_G_GetFsiList(arg);             /* 2 integers in between the [] */        if (fsiList->nx != 2) {          SetErrorf("owtrans2[] expects 2 indices");          return(NULL);        }                /* Get the integers */        o = (int) FSI_FIRST(fsiList);        v = (int) FSI_SECOND(fsiList);           i = Extract(wtrans,o,v);  if (i == NULL) return(NULL);             ARG_G_SetResValue(arg,i);  AddRefValue(i);  TempValue(i);  return(GetTypeValue(i));}static void *SetExtractOWtrans2V(OWTRANS2 wtrans, void **arg){  char *field;  FSIList *fsiList;  IMAGE i;  int o,v;   /* doc */  if (wtrans == NULL) return(doc);    field = ARG_S_GetField(arg);  fsiList = ARG_S_GetFsiList(arg);             /* 2 integers in between the [] */        if (fsiList->nx != 2) {          SetErrorf("owtrans2[] expects 2 indices");          return(NULL);        }                /* Get the integers */        o = (int) FSI_FIRST(fsiList);        v = (int) FSI_SECOND(fsiList);           i = Extract(wtrans,o,v);  if (i == NULL) return(NULL);             return(SetImageField(i,arg));}/*****************************************************************************  Allocation and Desallocation*****************************************************************************//* * Allocation of a OWtrans2 */ OWTRANS2 NewOWtrans2(void){  OWTRANS2 trans;  int i;#ifdef DEBUGALLOCDebugType = "OWtrans2";#endif    trans = (OWTRANS2) Malloc(sizeof(struct owtrans2));  InitValue(trans,&tsOWtrans2);    trans->name=defaultName; 

⌨️ 快捷键说明

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