Functions > Image Processing > Image Manipulation > Example: Scaling and Clipping
Example: Scaling and Clipping
Use scale and clip to scale an image's intensity levels to lie between a minimum and maximum, or truncate them to a minimum and maximum. The processed images are scaled or clipped to a standard grayscale range of 0–255.
For information on using this example, refer to About Image Processing Examples.
scale
This function converts the relative intensities of an image to lie between the optional values Min and Max, or between the default range of 0–255, by using the following algorithm:
Click to copy this expression
1. Define an image matrix M.
Click to copy this expression
2. Scale matrix M into the range 0–255.
Click to copy this expression
3. Verify that scaling using the default Min and Max yields the same scaled matrix.
Click to copy this expression
Click to copy this expression
clip
This function truncates all intensities below the optional value Min to Min and all intensities above the optional value Max to Max.
Clipping can be used to remove unwanted features, noise, or extraneous information from an image.
1. Clip matrix M into the range 0–255.
Click to copy this expression
Clipping using the default Min and Max yields the same scaled matrix:
Click to copy this expression
2. Remove the bright spots from a picture.
Click to copy this expression
Click to copy this expression
The brightest spot in the clipped image is 220 instead of 255 as in original image:
Click to copy this expression
Click to copy this expression
3. Compare the clipped image with the original image.
Click to copy this expression
(tank.bmp)
(mclip.bmp)
Was this helpful?