Check out sessions from the WiML Symposium covering diffusion models with KerasCV, on-device ML, and more. Watch on demand Show
Performs Gamma Correction. View aliasesCompat aliases for migration See Migration guide for more details.
on the input image. Also known as Power Law Transform. This function converts the input images at first to float representation, then transforms them pixelwise according to the equation Intensity transformations are applied on images for contrast manipulation or image thresholding. These are in the spatial domain, i.e. they are performed directly on the pixels of the image at hand, as opposed to being performed on the Fourier transform of the image. The following are commonly used intensity transformations:
Spatial Domain Processes – Image Negatives – Image negatives are discussed in this article. Mathematically, assume that an image goes from intensity levels 0 to (L-1). Generally, L = 256. Then, the negative transformation can be described by the expression s = L-1-r where r is the initial intensity level and s is the final intensity level of a pixel. This produces a photographic negative. Log Transformations –Mathematically, log transformations can be expressed as Consider the following input image. Below is the code to apply log transformation to the image.
Below is the log-transformed output. Power-Law (Gamma) Transformation –Power-law (gamma) transformations can be mathematically expressed as
Below are the gamma-corrected outputs for different values of gamma. Gamma = 0.1: Gamma = 0.5: Gamma = 1.2: Gamma = 2.2: As can be observed from the outputs as well as the graph, gamma>1 (indicated by the curve corresponding to ‘nth power’ label on the graph), the intensity of pixels decreases i.e. the image becomes darker. On the other hand, gamma<1 (indicated by the curve corresponding to 'nth root' label on the graph), the intensity increases i.e. the image becomes lighter. Piecewise-Linear Transformation Functions –These functions, as the name suggests, are not entirely linear in nature. However, they are linear between certain x-intervals. One of the most commonly used piecewise-linear transformation functions is contrast stretching. Contrast can be defined as:
This process expands the range of intensity levels in an image so that it spans the full intensity of the camera/display. The figure below shows the graph corresponding to the contrast stretching. With (r1, s1), (r2, s2) as parameters, the function stretches the intensity levels by essentially decreasing the intensity of the dark pixels and increasing the intensity of the light pixels. If Below is the Python code to perform contrast stretching.
|