Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

edt_buildmask.c File Reference

#include "mrilib.h"

Go to the source code of this file.


Functions

MCW_clusterMCW_build_mask (int nx, int ny, int nz, float dx, float dy, float dz, float max_dist)

Function Documentation

MCW_cluster* MCW_build_mask int    nx,
int    ny,
int    nz,
float    dx,
float    dy,
float    dz,
float    max_dist
 

Definition at line 25 of file edt_buildmask.c.

References ADDTO_CLUSTER, ENTRY, idx, INIT_CLUSTER, KILL_CLUSTER, MCW_cluster::num_pt, nz, and RETURN.

Referenced by EDIT_aver_fvol(), EDIT_filter_volume(), HISTO_main(), MCW_erode_clusters(), MCW_find_clusters(), mri_medianfilter(), NIH_find_clusters(), RCREND_cutout_blobs(), REND_cutout_blobs(), TT_whereami(), and WINsorize().

00028 {
00029    int ii, jj, kk, idx, jdy, kdz, nxy, nxyz, ijkma, mnum;
00030    float xq, yq, zq, dist_q;
00031    MCW_cluster * mask;
00032 
00033 ENTRY("MCW_build_mask") ;
00034 
00035    if( max_dist <= 0.0 ){                   /* 30 Apr 2002 */
00036      dx = dy = dz = 1.0 ; max_dist = 1.01 ;
00037    }
00038 
00039    idx = max_dist / dx ; jdy = max_dist / dy ; kdz = max_dist / dz ;
00040 
00041 #ifdef CLUST_DEBUG
00042 printf("MCW_find_clusters: idx=%d jdy=%d kdz=%d\n",idx,jdy,kdz) ;
00043 #endif
00044 
00045    if( (idx < 1 && jdy < 1 && kdz < 1) || (idx < 0 || jdy < 0 || kdz < 0 ) ){
00046       fprintf(stderr,"*** Illegal dimensions input to MCW_build_mask:\n"
00047                      "*** dx=%g dy=%g dz=%g max_dist=%g\n",
00048                      dx,dy,dz,max_dist ) ;
00049       RETURN( NULL );
00050    }
00051 
00052    INIT_CLUSTER(mask) ;
00053 
00054    dist_q = max_dist * max_dist ;
00055    nxy = nx*ny ; nxyz = nxy * nz ;
00056 
00057    for( kk=-kdz ; kk <= kdz ; kk++ ){
00058       zq = (kk*dz) * (kk*dz) ;
00059       for( jj=-jdy ; jj <= jdy ; jj++ ){
00060          yq = zq + (jj*dy) * (jj*dy) ;
00061          for( ii=-idx ; ii <= idx ; ii++ ){
00062             xq = yq + (ii*dx)*(ii*dx) ;
00063             if( xq <= dist_q && xq > 0.0 ){
00064               ADDTO_CLUSTER( mask , ii, jj, kk, 0 ) ;
00065             }
00066          }
00067       }
00068    }
00069 
00070 #ifdef CLUST_DEBUG
00071 printf("  mask size = %d\n",mask->num_pt ) ;
00072 #endif
00073 
00074    mnum = mask->num_pt ;
00075    if( mnum < 2 ){
00076       KILL_CLUSTER(mask) ;
00077       fprintf(stderr,
00078               "*** MCW_build_mask error: mask has only %d elements!\n",mnum);
00079       RETURN( NULL );
00080    }
00081 
00082    RETURN (mask);
00083 }
 

Powered by Plone

This site conforms to the following standards: