Functions > Image Processing > Image Manipulation > Example: Function and Level Mapping
Example: Function and Level Mapping
Use the funmap and levelmap functions to map a function of intensity, or a vector of new intensity levels, onto an existing image. Function and level maps specify a uniform transformation on intensity levels in an image or image transform. Like equalization, you can also use these functions to optimize the display of an image.
For information on using this example, refer to About Image Processing Examples.
funmap
This function applies the defined function to each element of the matrix.
1. Construct a test matrix:
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
2. Define a function.
Click to copy this expression
3. Call funmap to apply function f on every element of matrix M.
Click to copy this expression
The same result can be achieved by using the vectorize operator:
Click to copy this expression
4. Read in a sample image.
Click to copy this expression
5. Define a new function.
Click to copy this expression
6. Call funmap to apply function f to the image R. Use the Re function to make sure all the values returned are real.
Click to copy this expression
7. Display the original and transformed images.
Click to copy this expression
(arcs.bmp)
(arcs_fm.bmp)
8. Try other definitions of function f and view the different transformations.
Click to copy this expression Click to copy this expression
Click to copy this expression
(arcs_fm2.bmp)
Click to copy this expression
Click to copy this expression
Click to copy this expression
(arcs_fm3.bmp)
Click to copy this expression
Click to copy this expression
Click to copy this expression
(arcs_fm4.bmp)
levelmap
The levelmap function replaces the intensities in an image with the intensity levels given by vector vec. For example, the 100th element in vec gives the new level for pixels with intensity 100.
0 < the entries of M < (vec - 1)
1. To compensate an image with a squared intensity scale, create the following vector.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
2. Define a level map that maps the image display irregularities to their correct values.
Recall that:
Click to copy this expression
The level map is:
Click to copy this expression
3. Apply levelmap to the sample image and view the effect.
Click to copy this expression
Click to copy this expression
(arcs_level.bmp)
Was this helpful?