Functions > Image Processing > Combinations of Images > Example: Blending and Masking
Example: Blending and Masking
Use the blend and mask functions for combining and masking images.
For information on using this example, refer to About Image Processing Examples.
blend
1. Use the READ_IMAGE function to read in two 256 x 256 grayscale images.
Click to copy this expression
Click to copy this expression
(fruit.bmp)
(lena.bmp)
2. Apply the blend function to the two images. The images must be of the same size.
Click to copy this expression
3. Use the WRITEBMP function to write the blended image to a file.
Click to copy this expression
(fruit_lena.bmp)
4. Define two equally-sized matrices Q and R, and apply the function to view the result of blend mathematically.
Click to copy this expression
Click to copy this expression
Click to copy this expression
The blend matrix is constructed using the following formula:
Click to copy this expression
When an element of either M or N is 255, blend returns 255 (the desired clipping response). When M or N is zero, blend returns only the remaining element.
mask
Use the mask function to black out a part of an image so that the remaining features can be processed individually.
1. Read in and display a brain image.
Click to copy this expression
(brain.bmp)
2. Read in a mask image.
Click to copy this expression
Click to copy this expression
(mask.bmp)
3. Count the rows and columns in the two matrices:
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
The head image has one more row than the brain mask matrix. Use the submatrix function to extract the first 256 rows:
Click to copy this expression
4. Mask the brain out of the input head image.
Click to copy this expression
Click to copy this expression
(masked_brain.bmp)
Was this helpful?