|
|
|
Dilation your
face
Task 1
Get
your image from digital cam and process it.
Solution
im = imread('zeeya2.bmp');
imshow(im)
g = rgb2gray(im);
figure, imshow(g)
h = g > 115;
figure, imshow(h)
se = eye(3);
c = bwmorph(h,'open');
figure, imshow(c)
d = bwmorph(h,'close');
figure, imshow(d)
Result




Note:
1) When we performed bwmorph(h,'open'),
it converted image's light portion to white and dark
portion to black.
2) When we performed bwmorph(h,'close'),
it did the same job in addition produced much smoother image than
above.
Text Aligning
Task 2
Read
the image text.tif, perform some closing operations on it, try
to merge the letters together to form word 'Colate'.
Solution
BW1 = imread( 'text.tif');
SE = ones(8,8);
BW2 =
dilate(BW1,SE);
imshow(BW1)
figure, imshow(BW2)
SE2 = ones(9,9);
BW2 =
erode(BW2,SE2);
figure, imshow(BW2)
Result
.  
HELP
ERODE
ERODE Perform erosion on binary image.
BW2 = ERODE(BW1,SE) performs erosion on the binary image BW1
using the binary structuring element SE. SE is a matrix
containing only 1's and 0's.
BW2 = ERODE(BW1,SE,ALG) performs erosion using the specified
algorithm. ALG is a string that can have one of these values:
'spatial' (default) - processes the image in the spatial
domain. This algorithm works well for relatively small images
and structuring elements, but for large images and structuring
elements it can be slow.
'frequency' - processes the image in the frequency domain.
This algorithm is faster for large images and structuring
elements than 'spatial', but uses much more memory.
The spatial and frequency algorithms produce the same result,
but make different tradeoffs between speed and memory usage.
If you want to speed up erosion, specify the 'frequency'
algorithm. If you receive "out of memory" messages or if your
computer slows down because of disk paging, specify the
'spatial' algorithm.
BW2 = ERODE(BW1,SE,...,N) performs the erosion operation N
times.
Class Support
The input image BW1 can be of class double or uint8. The
output image BW2 is of class uint8.
Example
BW1 = imread('text.tif');
SE = ones(3,1);
BW2 = erode(BW1,SE);
imshow(BW1), figure, imshow(BW2)
EYE
EYE Identity matrix.
EYE(N) is the N-by-N identity matrix.
EYE(M,N) or EYE([M,N]) is an M-by-N matrix with 1's on the
diagonal and zeros elsewhere.
EYE(SIZE(A)) is the same size as A.
COLORMAP
COLORMAP Color look-up table.
COLORMAP(MAP) sets the current figure's colormap to MAP.
COLORMAP('default') sets the current figure's colormap to the
root's default, whose setting is JET.
MAP = COLORMAP retrieves the current colormap. The values are
in the range from 0 to 1.
A color map matrix may have any number of rows, but it must
have exactly 3 columns. Each row is interpreted as a color,
with the first element specifying the intensity of red light,
the second green, and the third blue. Color intensity
can be specified on the interval 0.0 to 1.0.
For example, [0 0 0] is black, [1 1 1] is white, [1 0 0]
is pure red, [.5 .5 .5] is gray, and [127/255 1 212/255] is
aquamarine.
Graphics objects that use pseudocolor -- SURFACE and PATCH
objects, which are created by the functions MESH, SURF, and
PCOLOR -- map a color matrix, C, whose values are in the range
[Cmin, Cmax], to an array of indices, k, in the range [1, m].
The values of Cmin and Cmax are either min(min(C)) and
max(max(C)), or are specified by CAXIS. The mapping is linear,
with Cmin mapping to index 1 and Cmax mapping to index m. The
indices are then used with the colormap to determine the color
associated with each matrix element. See CAXIS for details.
Type HELP GRAPH3D to see a number of useful colormaps.
COLORMAP is an M-file that sets the Colormap property of the
current figure.
IMAGESC
IMAGESC Scale data and display as image.
IMAGESC(...) is the same as IMAGE(...) except the data is
scaled to use the full colormap.
IMAGESC(...,CLIM) where CLIM = [CLOW CHIGH] can specify the
scaling.
DILATE
DILATE Perform dilation on binary image.
BW2 = DILATE(BW1,SE) performs dilation on the binary image
BW1, using the binary structuring element SE. SE is a matrix
containing only 1's and 0's.
BW2 = DILATE(BW1,SE,ALG) performs dilation using the specified
algorithm. ALG is a string that can have one of these values:
'spatial' - processes the image in the spatial domain. This
algorithm works well for relatively small images and
structuring elements, but for large images and structuring
elements it can be slow. This is the default algorithm.
'frequency' processes the image in the frequency domain. This
algorithm is faster for large images than 'spatial', but uses
much more memory.
The spatial and frequency algorithms produce the same result,
but make different tradeoffs between speed and memory use. If
you want to speed up dilation, specify the 'frequency'
algorithm. If you receive "out of memory" messages when you
perform dilation, specify the 'spatial' algorithm.
BW2 = DILATE(BW1,SE,...,N) performs the dilation operation N
times.
Class Support
The input image BW1 can be of class double or uint8. The
output image BW2 is of class uint8.
Example
BW1 = imread('text.tif');
SE = ones(6,2);
BW2 = dilate(BW1,SE);
imshow(BW1)
figure, imshow(BW2)
ERODE
ERODE Perform erosion on binary image.
BW2 = ERODE(BW1,SE) performs erosion on the binary image BW1
using the binary structuring element SE. SE is a matrix
containing only 1's and 0's.
BW2 = ERODE(BW1,SE,ALG) performs erosion using the specified
algorithm. ALG is a string that can have one of these values:
'spatial' (default) - processes the image in the
spatial domain. This algorithm works well for relatively small
images and structuring elements, but for large images and
structuring elements it can be slow.
'frequency' - processes the image in the frequency
domain. This algorithm is faster for large images and
structuring elements than 'spatial', but uses much more
memory.
The spatial and frequency algorithms produce the same result,
but make different tradeoffs between speed and memory usage.
If you want to speed up erosion, specify the 'frequency'
algorithm. If you receive "out of memory" messages or if your
computer slows down because of disk paging, specify the
'spatial' algorithm.
BW2 = ERODE(BW1,SE,...,N) performs the erosion operation N
times.
Class Support
The input image BW1 can be of class double or uint8. The
output image BW2 is of class uint8.
Example
BW1 = imread('text.tif');
SE = ones(3,1);
BW2 = erode(BW1,SE);
imshow(BW1), figure, imshow(BW2)
CV
Lab 1 CV
Lab2
CV
Lab 3
CV Lab4
CV
Lab 5
CV
Lab 6
CV
Lab7 CV
Lab8
Other
material
|
|
|