Changeset 2617


Ignore:
Timestamp:
08/01/12 17:40:15 (12 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-2825

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: not available

Put in Release Notes: No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Minor refactoring.


Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/EdgeMarker.cpp

    r2615 r2617  
    7272
    7373  // exclude WVR
    74   vector<uInt> wvr ;
     74  Block<uInt> wvr( st_->getIFNos().size() ) ;
     75  uInt n = 0 ;
    7576  {
    7677    ROArrayColumn<uChar> flagCol( st_->table(), "FLAGTRA" ) ;
     
    8283      uInt nchan = flagCol( firstRow ).nelements() ;
    8384      if ( nchan == 4 )
    84         wvr.push_back( current ) ;
     85        wvr[n++] = current ;
    8586      iter.next() ;
    8687    }
    8788  }
    88   wvr_ = Vector<uInt>( wvr ) ;
     89  wvr_.takeStorage( IPosition(1,n), wvr.storage(), COPY ) ;
    8990
    9091  if ( wvr_.nelements() > 0 ) {
  • trunk/src/GenericEdgeDetector.cpp

    r2615 r2617  
    215215  const uInt maxiter = 100 ;
    216216  while ( n > 0 && niter < maxiter ) {
    217     n = _labeling( apix_ ) ;
     217    n = _labeling() ;
    218218    os_ << LogIO::DEBUGGING
    219219        << "cycle " << niter << ": labeled " << n << " pixels" << LogIO::POST ;
     
    226226}
    227227
    228 uInt GenericEdgeDetector::_labeling( Matrix<uInt> &a )
     228uInt GenericEdgeDetector::_labeling()
    229229{
    230230  uInt n = 0 ;
    231231  for ( uInt ix = 0 ; ix < nx_ ; ix++ ) {
    232     Vector<uInt> v( a.row( ix ) ) ;
     232    Vector<uInt> v( apix_.row( ix ) ) ;
    233233    uInt nx = __labeling( v ) ;
    234234    n += nx ;
    235235  }
    236236  for ( uInt iy = 0 ; iy < ny_ ; iy++ ) {
    237     Vector<uInt> v( a.column( iy ) ) ;
     237    Vector<uInt> v( apix_.column( iy ) ) ;
    238238    uInt ny = __labeling( v ) ;
    239239    n += ny ;
     
    290290  if ( !elongated_ ) {
    291291    while ( n < nTrim && niter < maxiter ) {
    292       uInt m = _trimming( apix_ ) ;
     292      uInt m = _trimming() ;
    293293      os_ << LogIO::DEBUGGING
    294294          << "cycle " << niter << ": trimmed " << m << " pixels" << LogIO::POST ;
     
    300300    os_ << "1D triming along x-axis" << LogIO::POST ;
    301301    while ( n < nTrim && niter < maxiter ) {
    302       uInt m = _trimming1DX( apix_ ) ;
     302      uInt m = _trimming1DX() ;
    303303      os_ << LogIO::DEBUGGING
    304304          << "cycle " << niter << ": trimmed " << m << " pixels" << LogIO::POST ;
     
    310310    os_ << "1D triming along y-axis" << LogIO::POST ;
    311311    while ( n < nTrim && niter < maxiter ) {
    312       uInt m = _trimming1DY( apix_ ) ;
     312      uInt m = _trimming1DY() ;
    313313      os_ << LogIO::DEBUGGING
    314314          << "cycle " << niter << ": trimmed " << m << " pixels" << LogIO::POST ;
     
    326326}
    327327
    328 uInt GenericEdgeDetector::_trimming( Matrix<uInt> &a )
    329 {
    330   uInt n = 0 ;
    331   const uInt nx = a.nrow() ;
    332   const uInt ny = a.ncolumn() ;
    333   Block<uInt> flatIdxList( a.nelements() ) ;
     328uInt GenericEdgeDetector::_trimming()
     329{
     330  uInt n = 0 ;
     331  Block<uInt> flatIdxList( apix_.nelements() ) ;
    334332  uInt start ;
    335333  uInt end ;
    336334  uInt flatIdx ;
    337   for ( uInt ix = 0 ; ix < nx ; ix++ ) {
    338     Vector<uInt> v( a.row( ix ) ) ;
     335  for ( uInt ix = 0 ; ix < nx_ ; ix++ ) {
     336    Vector<uInt> v( apix_.row( ix ) ) ;
    339337    if ( allEQ( v, (uInt)0 ) ) {
    340338      continue ;
    341339    }
    342340    _search( start, end, v ) ;
    343     uInt offset = start * nx ;
     341    uInt offset = start * nx_ ;
    344342    flatIdx = offset + ix ;
    345343    flatIdxList[n++] = flatIdx ;
    346344    if ( start != end ) {
    347       offset = end * nx ;
     345      offset = end * nx_ ;
    348346      flatIdx = offset + ix ;
    349347      flatIdxList[n++] = flatIdx ;
    350348    }
    351349  }
    352   for ( uInt iy = 0 ; iy < ny ; iy++ ) {
    353     Vector<uInt> v( a.column( iy ) ) ;
     350  for ( uInt iy = 0 ; iy < ny_ ; iy++ ) {
     351    Vector<uInt> v( apix_.column( iy ) ) ;
    354352    if ( allEQ( v, (uInt)0 ) ) {
    355353      continue ;
    356354    }
    357     uInt offset = iy * nx ;
     355    uInt offset = iy * nx_ ;
    358356    _search( start, end, v ) ;
    359357    flatIdx = offset + start ;
     
    368366               Sort::Ascending,
    369367               Sort::QuickSort | Sort::NoDuplicates ) ;
    370   Vector<uInt> v( IPosition(1,nx*ny), a.data(), SHARE ) ;
     368  Vector<uInt> v( IPosition(1,apix_.nelements()), apix_.data(), SHARE ) ;
    371369  const uInt *idx_p = flatIdxList.storage() ;
    372370  for ( uInt i = 0 ; i < n ; i++ ) {
     
    378376}
    379377
    380 uInt GenericEdgeDetector::_trimming1DX( Matrix<uInt> &a )
    381 {
    382   uInt n = 0 ;
    383   const uInt nx = a.nrow() ;
     378uInt GenericEdgeDetector::_trimming1DX()
     379{
     380  uInt n = 0 ;
     381  const uInt nx = apix_.nrow() ;
    384382  Vector<uInt> v1, v2 ;
    385383  uInt ix, jx ;
    386   for ( ix = 0 ; ix < nx ; ix++ ) {
    387     v1.reference( a.row( ix ) ) ;
     384  for ( ix = 0 ; ix < nx_ ; ix++ ) {
     385    v1.reference( apix_.row( ix ) ) ;
    388386    if ( anyNE( v1, n ) ) break ;
    389387  }
    390388  for ( jx = nx-1 ; jx > ix ; jx-- ) {
    391     v2.reference( a.row( jx ) ) ;
     389    v2.reference( apix_.row( jx ) ) ;
    392390    if ( anyNE( v2, n ) ) break ;
    393391  }
     
    399397}
    400398
    401 uInt GenericEdgeDetector::_trimming1DY( Matrix<uInt> &a )
    402 {
    403   uInt n = 0 ;
    404   const uInt ny = a.ncolumn() ;
     399uInt GenericEdgeDetector::_trimming1DY()
     400{
     401  uInt n = 0 ;
     402  const uInt ny = apix_.ncolumn() ;
    405403  Vector<uInt> v1, v2 ;
    406404  uInt iy, jy ;
    407   for ( iy = 0 ; iy < ny ; iy++ ) {
    408     v1.reference( a.column( iy ) ) ;
     405  for ( iy = 0 ; iy < ny_ ; iy++ ) {
     406    v1.reference( apix_.column( iy ) ) ;
    409407    if ( anyNE( v1, n ) ) break ;
    410408  }
    411409  for ( jy = ny-1 ; jy > iy ; jy-- ) {
    412     v2.reference( a.column( jy ) ) ;
     410    v2.reference( apix_.column( jy ) ) ;
    413411    if ( anyNE( v2, n ) ) break ;
    414412  }
     
    462460    return ;
    463461
    464   Vector<uInt> diff( len-1 ) ;
     462  Block<uInt> diff( len-1 ) ;
    465463  for ( uInt i = 0 ; i < len-1 ; i++ ) {
    466464    diff[i] = off_[i+1] - off_[i] ;
  • trunk/src/GenericEdgeDetector.h

    r2613 r2617  
    4343  // internal methods
    4444  void setup() ;
    45   casa::uInt _labeling( casa::Matrix<casa::uInt> &a ) ;
     45  casa::uInt _labeling() ;
    4646  casa::uInt __labeling( casa::Vector<casa::uInt> &a ) ;
    47   casa::uInt _trimming( casa::Matrix<casa::uInt> &a ) ;
    48   casa::uInt _trimming1DX( casa::Matrix<casa::uInt> &a ) ;
    49   casa::uInt _trimming1DY( casa::Matrix<casa::uInt> &a ) ;
     47  casa::uInt _trimming() ;
     48  casa::uInt _trimming1DX() ;
     49  casa::uInt _trimming1DY() ;
    5050  casa::uInt _trimming1D( casa::Vector<casa::uInt> &a ) ;
    5151  void _search( casa::uInt &start,
Note: See TracChangeset for help on using the changeset viewer.