| Bsoft 1.9 Bernard's software package

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Functions
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

  *p | image.
  nlevels | number 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

  *p | image.
  scale | multiplier.
  shift | addition.

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

  *p | image.
  avg | new average.
  std | new 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

  *p | image.
  min | new minimum.
  max | new 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

  *p | image.
  min | minimum.
  max | maximum.
  setmin | value to set voxels smaller than minimum.
  setmax | value 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

  *p | image.
  min | minimum.
  max | maximum.

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

  *p | image.
  min | minimum.
  max | maximum.

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

  *p | image.
  min | minimum.
  max | maximum.

Returns
  int 0.

Definition at line 220 of file img_rescale.cpp.