Bsoft  1.9
Bernard's software package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
img_rescale.h File Reference

Header file for image utilities. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <math.h>
#include <time.h>
#include "rwimg.h"

Go to the source code of this file.

Functions

int img_rescale (Bimage *p, double scale, double shift)
 Rescales the image data to a given minimum and maximum. More...
 
int img_rescale_to_min_max (Bimage *p, double min, double max)
 Rescales the image data to a given minimum and maximum. More...
 
int img_rescale_to_avg_std (Bimage *p, double avg, double std)
 Rescales the image data to a given average and standard deviation. More...
 
int img_truncate (Bimage *p, double min, double max, double setmin, double setmax)
 Truncates image data to a given minimum and maximum. More...
 
int img_truncate_to_min_max (Bimage *p, double min, double max)
 Truncates image data to a given minimum and maximum. More...
 
int img_truncate_to_avg (Bimage *p, double min, double max)
 Sets voxels in image data exceeding a given minimum and maximum to the average. More...
 
int img_truncate_to_background (Bimage *p, double min, double max)
 Sets voxels in image data exceeding a given minimum and maximum to the image background. More...
 
int img_limit_levels (Bimage *p, int nlevels)
 Converts a full gray scale image to a limited level image. More...
 

Detailed Description

Header file for image utilities.

Author
Bernard Heymann
Date
Created: 20000430
Modified: 20070927

Definition in file img_rescale.h.

Function Documentation

int img_limit_levels ( Bimage *  p,
int  nlevels 
)

Converts a full gray scale image to a limited level image.

The dynamic range of the image is decreased to a given number of gray scale levels. The new data replaces the old data. Image statistics are recalculated.

Parameters
*pimage.
nlevelsnumber of levels.
Returns
int 0.

Definition at line 314 of file img_rescale.cpp.

int img_rescale ( Bimage *  p,
double  scale,
double  shift 
)

Rescales the image data to a given minimum and maximum.

Parameters
*pimage.
scalemultiplier.
shiftaddition.
Returns
int 0, <0 on error.
The new data is calculated as:
    new_datum = datum*scale + shift
The new data replaces the old data.
Image statistics are recalculated.

Definition at line 31 of file img_rescale.cpp.

int img_rescale_to_avg_std ( Bimage *  p,
double  avg,
double  std 
)

Rescales the image data to a given average and standard deviation.

Parameters
*pimage.
avgnew average.
stdnew standard deviation.
Returns
int 0, <0 on error.
The new data is calculated as:
                                new_std_dev
    new_datum = (datum - avg) * ----------- + new_avg
                                  std_dev
The new data replaces the old data.
Image statistics are recalculated.

Definition at line 113 of file img_rescale.cpp.

int img_rescale_to_min_max ( Bimage *  p,
double  min,
double  max 
)

Rescales the image data to a given minimum and maximum.

Parameters
*pimage.
minnew minimum.
maxnew maximum.
Returns
int 0, <0 on error.
The new data is calculated as:
                                new_max - new_min
    new_datum = (datum - min) * ----------------- + new_min
                                    max - min
The new data replaces the old data.
Image statistics are recalculated.

Definition at line 79 of file img_rescale.cpp.

int img_truncate ( Bimage *  p,
double  min,
double  max,
double  setmin,
double  setmax 
)

Truncates image data to a given minimum and maximum.

All values smaller than the new minimum are set to the new minimum and all values larger than the new maximum are set to the new maximum. In cases where the given minimum and maximum are outside the data type ranges, they are reset to the data type range limits. The new data replaces the old data. Image statistics are recalculated.

Parameters
*pimage.
minminimum.
maxmaximum.
setminvalue to set voxels smaller than minimum.
setmaxvalue to set voxels larger than maximum.
Returns
int 0.

Definition at line 165 of file img_rescale.cpp.

int img_truncate_to_avg ( Bimage *  p,
double  min,
double  max 
)

Sets voxels in image data exceeding a given minimum and maximum to the average.

All values smaller than the new minimum or larger than the new maximum are set to the image average. The new data replaces the old data. Image statistics are recalculated.

Parameters
*pimage.
minminimum.
maxmaximum.
Returns
int 0.

Definition at line 239 of file img_rescale.cpp.

int img_truncate_to_background ( Bimage *  p,
double  min,
double  max 
)

Sets voxels in image data exceeding a given minimum and maximum to the image background.

All values smaller than the new minimum or larger than the new maximum are set to the background value. The new data replaces the old data. Image statistics are recalculated.

Parameters
*pimage.
minminimum.
maxmaximum.
Returns
int 0.

Definition at line 258 of file img_rescale.cpp.

int img_truncate_to_min_max ( Bimage *  p,
double  min,
double  max 
)

Truncates image data to a given minimum and maximum.

All values smaller than the new minimum are set to the new minimum and all values larger than the new maximum are set to the new maximum. In cases where the given minimum and maximum are outside the data type ranges, they are reset to the data type range limits. The new data replaces the old data. Image statistics are recalculated.

Parameters
*pimage.
minminimum.
maxmaximum.
Returns
int 0.

Definition at line 220 of file img_rescale.cpp.