00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
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
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
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 }