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

Header file for image segmenting functions. 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"
#include "marker.h"

Go to the source code of this file.

Functions

int img_blobs (Bimage *p, float threshold, float min_size, float max_size, float setvalue, int sign)
 Identifies contiguous regions above a given threshold (blobs) and eliminate those less than a minimum size. More...
 
float img_find_threshold (Bimage *p, int img_num, double mol_weight, float rho)
 Finds the density threshold associated with a particular molecular weight. More...
 
float img_mass_at_threshold (Bimage *p, int img_num, float threshold, float rho)
 Calculates the mass from the density threshold. More...
 
int img_internal_volume (Bimage *p, float threshold, int mask_out_freq)
 Finds the density threshold associated with a particular molecular weight. More...
 
int img_segment_threshold_series (Bimage *p, float threshold_first, float threshold_last, float threshold_step)
 Segments a map through a series of thresholds and reports results. More...
 
Bimage * img_flood_fill (Bimage *p, Bimage *pfeature, float threshold_hi, float threshold_lo, float threshold_step, int fill_borders)
 Creates and expands a feature map from a starting to ending threshold value. More...
 
Bimage * img_flood_peaks (Bimage *p, int kernel_size, float threshold)
 Generates a segmented image from peaks above a threshold value. More...
 
int img_set_second_mask (Bimage *p, Bimage *pmask, float threshold)
 A second level mask is added to a primary mask based on a threshold. More...
 
int img_check_neighbors (Bimage *p, unsigned long index)
 Check neighbors in feature map and assign a value if a neighbor is assigned. More...
 
long img_find_highest_in_kernel (Bimage *p, unsigned long index, int size)
 Finds the highest value in a kernel excluding the central voxel. More...
 
Bimage * img_excise_feature (Bimage *p, Bimage *pfeature, Bmarker *markers)
 Finds the density around a voxel associated with a particular feature. More...
 
Bimage * img_excise_all_features (Bimage *p, Bimage *pfeature)
 Extracts all the features associated with a multi-level mask. More...
 

Detailed Description

Header file for image segmenting functions.

Author
Bernard Heymann
Date
Created: 19990321 Modified: 20130122

Definition in file img_segment.h.

Function Documentation

int img_blobs ( Bimage *  p,
float  threshold,
float  min_size,
float  max_size,
float  setvalue,
int  sign 
)

Identifies contiguous regions above a given threshold (blobs) and eliminate those less than a minimum size.

Parameters
*pimage.
thresholdthreshold to define contiguous regions.
min_sizeminimum number of voxels to keep a region.
max_sizemaximum number of voxels to keep a region.
setvaluevalue to assign to deleted regions (typically set to threshold).
signsign controlling direction of thresholding.
Returns
int number of voxels set to threshold.
All contiguous regions in an image are indexed and their sizes 
calculated. Whether a region is contiguous is defined by a
threshold. Regions smaller than a minimum number of voxels are
set to the threshold value. The input image is modified and
left as a floating point image.

Definition at line 37 of file img_segment.cpp.

int img_check_neighbors ( Bimage *  p,
unsigned long  index 
)

Check neighbors in feature map and assign a value if a neighbor is assigned.

Parameters
*pthe integer image mask.
indexindex in multi-image.
Returns
int new value assigned.
The mask must be of type integer.

Definition at line 731 of file img_segment.cpp.

Bimage* img_excise_all_features ( Bimage *  p,
Bimage *  pfeature 
)

Extracts all the features associated with a multi-level mask.

Parameters
*pdensity map.
*pfeaturemulti-level feature mask map.
Returns
Bimage* image with excised features.
The feature index is found in a feature map and the corresponding voxels
in the density maps are extracted.
An image is assumed to have density represented by higher (white) values.

Definition at line 944 of file img_segment.cpp.

Bimage* img_excise_feature ( Bimage *  p,
Bimage *  pfeature,
Bmarker *  markers 
)

Finds the density around a voxel associated with a particular feature.

Parameters
*pdensity map (modified, omission map).
*pfeaturefeature map.
*markersmarker coordinates within features to be extracted.
Returns
Bimage* image with excised feature.
The feature index is found in a feature map and the corresponding voxels
in the density maps are extracted.
An image is assumed to have density represented by higher (white) values.
Each voxel is specified as x, y, z and image number.

Definition at line 850 of file img_segment.cpp.

long img_find_highest_in_kernel ( Bimage *  p,
unsigned long  index,
int  size 
)

Finds the highest value in a kernel excluding the central voxel.

Parameters
*pimage.
indexindex in multi-image.
sizekernel edge half size
Returns
int index of highest value.
The image must be floating point.

Definition at line 796 of file img_segment.cpp.

float img_find_threshold ( Bimage *  p,
int  img_num,
double  mol_weight,
float  rho 
)

Finds the density threshold associated with a particular molecular weight.

Parameters
*pimage.
img_numsub-image number (first = 0, -1 means all).
mol_weightmolecular weight.
rhoprotein density in Da/A3.
Returns
float threshold.
A threshold value is determined which contour a density such that
it corresponds to 100% of the given molecular weight.
An image is assumed to have density represented by higher (white) values.

Definition at line 127 of file img_segment.cpp.

Bimage* img_flood_fill ( Bimage *  p,
Bimage *  pfeature,
float  threshold_hi,
float  threshold_lo,
float  threshold_step,
int  fill_borders 
)

Creates and expands a feature map from a starting to ending threshold value.

Parameters
*pthe image.
*pfeaturefeature map (if NULL, generate from high threshold).
threshold_hithe level to pick initial regions.
threshold_lothe lowest level to include voxels in regions.
threshold_stepthe incremental change in threshold.
fill_bordersflag to assign borders between regions (default not).
Returns
Bimage* integer image containing feature index numbers.
A feature map is calculated at the threshold furthest from the average.
The feature map is then expanded by lowering the threshold gradually 
and assigning newly included voxels to neighboring regions (i.e., flooding).
Voxels with neighbours assigned to two or more different regions are tagged
as indeterminate to indicate borders between regions. These border voxels
are counted and can be used to estimate the extent of interfaces.
The indices of all the final regions are packed into an integer data block
within a new image.

Definition at line 439 of file img_segment.cpp.

Bimage* img_flood_peaks ( Bimage *  p,
int  kernel_size,
float  threshold 
)

Generates a segmented image from peaks above a threshold value.

Parameters
*pthe image.
kernel_sizesize of kernel to determine peaks.
thresholdthe lowest level to include voxels in regions.
Returns
Bimage* integer image containing region index numbers.
Every voxel with a value above the threshold is tagged by a pointer 
pointing to the highest value within a kernel. 
A peak is defined as pointing to itself, while every other voxel
points towards a peak.
The voxels in the mask are then iteratively assigned to the peaks
they point to.
The indices of all the final regions are packed into an integer data block
within a new image.

Definition at line 612 of file img_segment.cpp.

int img_internal_volume ( Bimage *  p,
float  threshold,
int  mask_out_freq 
)

Finds the density threshold associated with a particular molecular weight.

Parameters
*pimage (modified to generate mask).
thresholdthreshold to define density.
mask_out_freqmask output frequency.
Returns
int 0.
A threshold value is determined which contour a density such that
it corresponds to 100% of the given molecular weight.
An image is assumed to have density represented by higher (white) values.

Definition at line 264 of file img_segment.cpp.

float img_mass_at_threshold ( Bimage *  p,
int  img_num,
float  threshold,
float  rho 
)

Calculates the mass from the density threshold.

Parameters
*pimage.
img_numsub-image number (first = 0).
thresholddensity threshold.
rhoprotein density in Da/A3.
Returns
float threshold.
An image is assumed to have density represented by higher (white) values.

Definition at line 222 of file img_segment.cpp.

int img_segment_threshold_series ( Bimage *  p,
float  threshold_first,
float  threshold_last,
float  threshold_step 
)

Segments a map through a series of thresholds and reports results.

Parameters
*pthe image.
threshold_firstthe level to pick initial regions.
threshold_lastthe lowest level to include voxels in regions.
threshold_stepthe incremental change in threshold.
Returns
int 0.

Definition at line 382 of file img_segment.cpp.

int img_set_second_mask ( Bimage *  p,
Bimage *  pmask,
float  threshold 
)

A second level mask is added to a primary mask based on a threshold.

Parameters
*pthe image.
*pmaskthe integer image mask.
thresholdthreshold for secondary mask.
Returns
int 0.
A new level is created in the mask image (i.e., max+1) for all voxels 
above the threshold and not included in the mask already.

Definition at line 701 of file img_segment.cpp.