| [Top] [Up] [Prev] [Next] | [Up] [Tutorial] | mmtutor V1.0 30abr2001 |
mm015union In the following, we have an interesting visualization of the union of gray-scale images. The sequence of commands below present the union of the two synthetic images.
f1=uint8(repmat( ones(15,1)*[1:15], 3 )); f2=uint8([1:45]' * ones(1,45)/3); f3=mmunion(f1,f2); mmshow(f1); mmshow(f2); mmshow(f3);
|
The next example presents the union of a binary time signal, converted to the intensity range [0,255], with another time signal.
The union requires that both images are of same data type. It is shown below the result when the images are not of the same type and mmfreedom is 0, i.e., no automatic data type conversions are allowed:
mmfreedom(0); % put the toolbox in no automatic data type conversion mode f_bin = mmbinary(uint8([1 1 0 0 1 0])); f_gray = uint8( [0 100 150 120 30 200]); mmunion(f_gray,f_bin) ??? automatic conversion from logical binary uint8 to uint8 is not allowed (see MMFREEDOM) mmunion - Invalid input par: f2. |
If we allow automatic conversion with warning, by changing the mmfreedom value to 1, the binary image is automaticaly converted to uint8 gray-scale by a simple casting. Note that value of the first pixel as 1.
mmfreedom(1); % put back in automatic conversion mode with warning
mmunion(f_gray,f_bin)
warning: converting from type binary uint8 to uint8
ans =
1 100 150 120 30 200
|
The proper way of doing this is by using an explicit convertion from binary to gray-scale image using the mmgray function. In this case the 1 values are converted to 255.
f_bin = mmbinary(uint8([1 1 0 0 1 0])); mmgray(f_bin) ans = 255 255 0 0 255 0 mmunion(f_gray, mmgray(f_bin)) ans = 255 255 150 120 255 200 |
The next example presents the construction of an image from two input images (upper and lower case letters presented, respectively, in the first and second figures, and a template image (presented in the third figure). The template is used to select if the pixels come from the lower case or upper case images. If a pixel in the template is 1, an upper image pixel is selected, otherwise a lower case image pixel is chosen.
The function mmtext is used to build the letters. The template is built by a composition of constant 0 and constant 1 images, that are built, respectively, by the subtraction of two same letter images, and its complement. In this way fzero and fone images are of the same size of a letter image.
The resulting image is presented in the fourth figure below:
f1 = mmtext('ABCDEF'); % input image 1
f2 = mmtext('abcdef'); % input image 2
fzero = mmsubm(mmtext('A'),mmtext('A')); % zero template
fone = mmneg(fzero); % one template
f3 = [fzero fone fzero fone fzero fone];
f4 = mmunion(mmintersec(f1,f3),mmintersec(f2,mmneg(f3)));
mmshow(f1);
mmshow(f2);
mmshow(f3);
mmshow(f4);
|
| [Top] [Up] [Prev] [Next] | [Up] [Tutorial] |
|
| Copyright (c) 1998-20001 by SDC Information SystemsCopyright (c) 1998-20001 by SDC Information Systems | ||