M-File Help: ipixswitch | View code for ipixswitch |
Pixelwise image merge
out = ipixswitch(mask, im1, im2) is an image where each pixel is selected from the corresponding pixel in im1 or im2 according to the corresponding pixel values in mask. If the element of mask is zero im1 is selected, otherwise im2 is selected.
im1 or im2 can contain a color descriptor which is one of:
ipixswitch(mask, im1, im2) as above but the result is displayed.
Read a uint8 image
im = iread('lena.pgm');
and set high valued pixels to red
a = ipixswitch(im>120, im, uint8([255 0 0]));
The result is a uint8 image since both arguments are uint8 images.
a = ipixswitch(im>120, im, [1 0 0]);
The result is a double precision image since the color specification is a double.
a = ipixswitch(im>120, im, 'red');
The result is a double precision image since the result of colorname is a double precision 3-vector.
© 1990-2012 Peter Corke.