-
public class AdaptiveMapImage adaptive mapping methods.
-
-
Field Summary
Fields Modifier and Type Field Description public final static intDEFAULT_TILE_WIDTHpublic final static intDEFAULT_TILE_HEIGHTpublic final static intDEFAULT_MIN_COUNTpublic final static intDEFAULT_X_SMOOTH_SIZEpublic final static intDEFAULT_Y_SMOOTH_SIZE
-
Method Summary
Modifier and Type Method Description static PixbackgroundNormMorph(Pix pixs)Normalizes an image's background using default parameters. static PixbackgroundNormMorph(Pix pixs, int normReduction, int normSize, int normBgValue)Normalizes an image's background to a specified value. static PixpixContrastNorm(Pix pixs)Adaptively attempts to expand the contrast to the full dynamic range ineach tile using default parameters. static PixpixContrastNorm(Pix pixs, int sizeX, int sizeY, int minDiff, int smoothX, int smoothY)Adaptively attempts to expand the contrast to the full dynamic range ineach tile. -
-
Method Detail
-
backgroundNormMorph
static Pix backgroundNormMorph(Pix pixs)
Normalizes an image's background using default parameters.
- Parameters:
pixs- A source pix image.
-
backgroundNormMorph
static Pix backgroundNormMorph(Pix pixs, int normReduction, int normSize, int normBgValue)
Normalizes an image's background to a specified value.
Notes:
- This is a top-level interface for normalizing the image intensity bymapping the image so that the background is near the input value 'bgval'.
- The input image is either grayscale or rgb.
- For each component in the input image, the background value isestimated using a grayscale closing; hence the 'Morph' in the functionname.
- An optional binary mask can be specified, with the foreground pixelstypically over image regions. The resulting background map values will bedetermined by surrounding pixels that are not under the mask foreground.The origin (0,0) of this mask is assumed to be aligned with the origin ofthe input image. This binary mask must not fully cover pixs, because thenthere will be no pixels in the input image available to compute thebackground.
- The map is computed at reduced size (given by 'reduction') from theinput pixs and optional pixim. At this scale, pixs is closed to removethe background, using a square Sel of odd dimension. The product ofreduction * size should be large enough to remove most of the textforeground.
- No convolutional smoothing needs to be done on the map beforeinverting it.
- A 'bgval' target background value for the normalized image. Thisshould be at least 128. If set too close to 255, some clipping will occurin the result.
- Parameters:
pixs- A source pix image.normReduction- Reduction at which morphological closings are done.normSize- Size of square Sel for the closing.normBgValue- Target background value.
-
pixContrastNorm
static Pix pixContrastNorm(Pix pixs)
Adaptively attempts to expand the contrast to the full dynamic range ineach tile using default parameters.
- Parameters:
pixs- A source pix image
-
pixContrastNorm
static Pix pixContrastNorm(Pix pixs, int sizeX, int sizeY, int minDiff, int smoothX, int smoothY)
Adaptively attempts to expand the contrast to the full dynamic range ineach tile.
Notes:
- If the contrast in a tile is smaller than minDiff, it uses the minand max pixel values from neighboring tiles. It also can useconvolution to smooth the min and max values from neighboring tiles.After all that processing, it is possible that the actual pixel valuesin the tile are outside the computed [min ... max] range for localcontrast normalization. Such pixels are taken to be at either 0 (ifbelow the min) or 255 (if above the max).
- sizeX and sizeY give the tile size; they are typically at least 20.
- minDiff is used to eliminate results for tiles where it is likelythat either fg or bg is missing. A value around 50 or more isreasonable.
- The full width and height of the convolution kernel are (2 * smoothx+ 1) and (2 * smoothy + 1). Some smoothing is typically useful, and welimit the smoothing half-widths to the range from 0 to 8. Use 0 for nosmoothing.
- A linear TRC (gamma = 1.0) is applied to increase the contrast ineach tile. The result can subsequently be globally corrected, byapplying pixGammaTRC() with arbitrary values of gamma and the 0 and 255points of the mapping.
- Parameters:
pixs- A source pix imagesizeX- Tile widthsizeY- Tile heightminDiff- Minimum difference to accept as validsmoothX- Half-width of convolution kernel applied to min and maxarrayssmoothY- Half-height of convolution kernel applied to min and maxarrays
-
-
-
-