Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

change_labels.c

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------- 00002 @COPYRIGHT : 00003 Copyright 1993,1994,1995 David MacDonald, 00004 McConnell Brain Imaging Centre, 00005 Montreal Neurological Institute, McGill University. 00006 Permission to use, copy, modify, and distribute this 00007 software and its documentation for any purpose and without 00008 fee is hereby granted, provided that the above copyright 00009 notice appear in all copies. The author and McGill University 00010 make no representations about the suitability of this 00011 software for any purpose. It is provided "as is" without 00012 express or implied warranty. 00013 ---------------------------------------------------------------------------- */ 00014 00015 #include <volume_io/internal_volume_io.h> 00016 #include <bicpl/vols.h> 00017 00018 #ifndef lint 00019 static char rcsid[] = "$Header: /software/source//libraries/bicpl/Volumes/change_labels.c,v 1.9 2000/02/06 15:30:53 stever Exp $"; 00020 #endif 00021 00022 /* ----------------------------- MNI Header ----------------------------------- 00023 @NAME : modify_labels_in_range 00024 @INPUT : volume 00025 src_min 00026 src_max 00027 dest_label 00028 min_threshold 00029 max_threshold 00030 @OUTPUT : label_volume 00031 @RETURNS : 00032 @DESCRIPTION: Changes all labels which have the value within src_min and 00033 src_max and a 00034 volume value within the threshold, to the dest_label. 00035 @METHOD : 00036 @GLOBALS : 00037 @CALLS : 00038 @CREATED : 1993 David MacDonald 00039 @MODIFIED : 00040 ---------------------------------------------------------------------------- */ 00041 00042 public void modify_labels_in_range( 00043 Volume volume, 00044 Volume label_volume, 00045 int src_min, 00046 int src_max, 00047 int dest_label, 00048 Real min_threshold, 00049 Real max_threshold, 00050 int range_changed[2][N_DIMENSIONS] ) 00051 { 00052 int voxel[MAX_DIMENSIONS], sizes[MAX_DIMENSIONS], dim; 00053 int label; 00054 BOOLEAN must_change, first; 00055 Real value; 00056 progress_struct progress; 00057 00058 get_volume_sizes( label_volume, sizes ); 00059 00060 initialize_progress_report( &progress, FALSE, sizes[X] * sizes[Y], 00061 "Modifying Labels" ); 00062 00063 first = TRUE; 00064 00065 for_less( voxel[X], 0, sizes[X] ) 00066 { 00067 for_less( voxel[Y], 0, sizes[Y] ) 00068 { 00069 for_less( voxel[Z], 0, sizes[Z] ) 00070 { 00071 if( src_min <= src_max ) 00072 { 00073 label = get_volume_label_data( label_volume, voxel ); 00074 must_change = (src_min <= label && label <= src_max); 00075 } 00076 else 00077 must_change = TRUE; 00078 00079 if( must_change && min_threshold < max_threshold ) 00080 { 00081 value = get_volume_real_value( volume, voxel[X], voxel[Y], 00082 voxel[Z], 0, 0 ); 00083 if( value < min_threshold || value > max_threshold ) 00084 must_change = FALSE; 00085 } 00086 00087 if( must_change ) 00088 { 00089 set_volume_label_data( label_volume, voxel, dest_label ); 00090 for_less( dim, 0, N_DIMENSIONS ) 00091 { 00092 if( first || voxel[dim] < range_changed[0][dim] ) 00093 range_changed[0][dim] = voxel[dim]; 00094 if( first || voxel[dim] > range_changed[1][dim] ) 00095 range_changed[1][dim] = voxel[dim]; 00096 } 00097 first = FALSE; 00098 } 00099 } 00100 00101 update_progress_report( &progress, voxel[X] * sizes[Y] + 00102 voxel[Y] + 1 ); 00103 } 00104 } 00105 00106 terminate_progress_report( &progress ); 00107 }

Generated on Wed Jul 28 09:10:56 2004 for BICPL by doxygen 1.3.7