Professional Documents
Culture Documents
Varun K. Nagaraja
Final Year, Dept of ECE
NITK Surathkal
Activity Recognition
Image Stitching
Image Morphing
% Transpose of a matrix
A_trans = A
A_trans =
5.0000
3.0000
7.0000
A =
5.0000
8.0000
1.0000
3.0000
9.0000
4.2000
7.0000
2.0000
0.0600
7.0000 + 8.0000i
1.0000 + 4.0000i
8.0000
9.0000
2.0000
1.0000
4.2000
0.0600
% Matrix addition
C = A + A_trans
C =
10.0000
11.0000
8.0000
11.0000
18.0000
6.2000
8.0000
6.2000
0.1200
24.0000
81.0000
8.4000
7.0000
8.4000
0.0036
% Matrix multiplication
C = A * A_trans
C =
83.0000
81.0000
18.0200
81.0000
149.0000
45.9200
18.0200
45.9200
18.6436
on the
Click on point A as shown, on the image. It displays three values (RGB) since it is a color image. You
can try reading pixel values for the previous image. It will be either 0/1 since it is binary image.
Hold Alt and Click on point B. This creates something called as a new datatip.
B
A
on the
Click on point A as shown, on the image. It displays three values (RGB) since it is a color image. You
can try reading pixel values for the previous image. It will be either 0/1 since it is binary image.
Hold Alt and Click on point B. This creates something called as a new datatip.
B
A
The Algorithm
Dilation
0
1
0
>> SE = strel('square',3)
SE =
Flat STREL object containing 9 neighbors.
Neighborhood:
1
1
1
1
1
1
1
1
1
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
Dilation does not necessarily mean dilation of the holes also. The holes get
contracted as shown above.
Also try image erosion. Use MATLABs help.
When the dilated image of the character us subtracted from the original we get
something like
structuring elements SE1 and SE2. The hitmiss operation preserves pixels
whose neighborhoods match the shape of SE1 and don't match the shape of SE2.
If the matrix returned by bwhitmiss contains non zero elements, then the
character is found in the image.
>> if ~isempty(nonzeros(bwhitmiss(im,N,N2)))
disp('N');
end
Image Segmentation
Global Thresholding Method
>> im=imread('automata.jpg');
>> im_gray=rgb2gray(im);
% im2bw converts grayscale image to binary
% image using a global threshold
>> bw1=im2bw(im_gray);
>> bw2=im2bw(im_gray, threshold);
%
%
%
%
Image Segmentation
Global Thresholding Method
Disadvantage is when there are multiple colors for objects and backgrounds.
Image Segmentation
Local Thresholding Method: Niblacks Method
255 if I( x, y ) T ( x, y )
R( x, y ) 100 if I( x, y ) T ( x, y )
0
otherwise
T ( x, y) N k N
>>
>>
>>
>>
im=imread('blocks.jpg');
im_gray=rgb2gray(im);
imt=niblack(im_gray,0.5,201);
figure,imshow(imt,[])
Image Segmentation
Local Thresholding Method: Niblacks Method
% Since our objects of interest are white pixels,
% we will consider those equal to 255
>> imwhite=(imt==255);
% observe how the above command works. It checks
% pixel by pixel for the condition and returns a
% matrix
>> figure, imshow(imwhite)
% Now we need to clear the noisier regions. We
% use an erosion process followed by reconstruction
>> im_eroded=imerode(imwhite,strel('square',51));
>> im_recon=imreconstruct(im_eroded,imwhite);
>> figure, imshow(im_recon)
Connected Components
%
%
%
%
>> figure,imshow(finalimg,[])
This was again a very crude way, since we are depending only on value of
area which might not remain constant if camera changes position.
Most of the times the standard features available with regionprops() is
not sufficient. We will have to write our own code to extract features.
Also we used hard thresholds for areas to classify CCs. Again most of the
times, this is not followed. Classifiers using Pattern Recognition techniques
are employed.
im=imread('ouch.jpg');
im_gray=rgb2gray(im);
imedge=edge(im_gray,'canny',[0.1 0.2]);
figure,imshow(imedge)
and
Removing Noise By Median Filtering
(MATLAB Help)