source: tags/release-0.9/Cubes/removeMW.cc @ 813

Last change on this file since 813 was 3, checked in by Matthew Whiting, 18 years ago

This is the first full import of all working code to
the Duchamp repository.
Made three directories at top level:

branches/ tags/ trunk/

and trunk/ has the full set of code:
ATrous/ Cubes/ Detection/ InputComplete? InputExample? README Utils/ docs/ mainDuchamp.cc param.cc param.hh

File size: 1.4 KB
Line 
1#include <iostream>
2#include <Cubes/cubes.hh>
3
4Cube removeMW(Cube &cube, Param &par)
5{
6  int maxMW = par.getMaxMW();
7  int minMW = par.getMinMW();
8  bool flagBlank = par.getFlagBlankPix();
9  bool flagMW = par.getFlagMW();
10  float nPV = par.getBlankPixVal();
11  long xdim=cube.getDimX(),ydim=cube.getDimY(),zdim = cube.getDimZ();
12  long *dim = new long[3];
13  dim[0] = xdim; dim[1]=ydim; dim[2]=zdim;
14  Cube *newcube = new Cube(cube);
15//   Cube *newcube = new Cube(dim);
16//   *newcube = cube;
17//   newcube->setWCS(cube.getWCS());
18  int pos;
19  bool isMW;
20  float val;
21  for(int pix=0;pix<xdim*ydim;pix++){
22    for(int z=0;z<zdim;z++){
23      pos = z*xdim*ydim + pix;
24      val = cube.getPixValue(pos);
25      isMW = flagMW && (z>=minMW) && (z<=maxMW);
26      if(!par.isBlank(val) && isMW) newcube->setPixValue(pos,0.);
27      //if(!isBlank && isMW) newcube->setPixValue(pos,nPV);
28    }
29  }
30  return *newcube;
31}
32
33void Cube::removeMW()
34{
35  int maxMW = this->par.getMaxMW();
36  int minMW = this->par.getMinMW();
37  bool flagBlank = this->par.getFlagBlankPix();
38  bool flagMW = this->par.getFlagMW();
39  float nPV = this->par.getBlankPixVal();
40  long xdim=axisDim[0], ydim=axisDim[1], zdim=axisDim[2];
41  for(int pix=0;pix<xdim*ydim;pix++){
42    for(int z=0;z<zdim;z++){
43      int pos = z*xdim*ydim + pix;
44      bool isMW = flagMW && (z>=minMW) && (z<=maxMW);
45      if(!(this->par.isBlank(this->array[pos])) && isMW) this->array[pos]=0.;
46    }
47  }
48}
49
Note: See TracBrowser for help on using the repository browser.