11 views

Uploaded by raoz81

basics of matlab

- A Web Page Topic Segmentation Algorithm Based on Visual Criteria and Content Layout
- Enhancement Techniques and Methods for Brain MRI Imaging
- Final Year Matlab Project List With Abstract 2012
- Color Based Segmentation
- Chan Vese Algorithm
- 4-July-Data Analysis and Mathematical Modelling Using MATLAB
- ARIA User Guide
- Component Activities in Liquid Mixture, Using NRTL - File Exchange - MATLAB Central
- Matlab Intro 1
- A 43040105
- Image Segmentation
- PENTOOLS - A MATLAB Toolkit for on-line Pen-Based
- Writer Identification For Handwritten Document Based On Structured Learning
- Yun Thesesgg
- Image Segment at i On
- IJIREEICE3G a ragini RECOGNITION OF VEHICLE NUMBER PLATE USING MATLAB (1).pdf
- V.kartHIKEYAN Published Article4
- Read Me First
- How Do I Extract Data From MATLAB Figures_ - MATLAB Answers - MATLAB Central
- 090611-ebimage-pau-2

You are on page 1of 27

Varun K. Nagaraja

Final Year, Dept of ECE

NITK Surathkal

Activity Recognition

Image Stitching

Image Morphing

% Use colon at the end to suppress

% output

% Transpose of a matrix

A_trans = A

A = [5 3 7; 8 9 2; 1 4.2 6e-2]

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

% elements

X = [5+3*j 7+8j; 9+2j 1+4j;]

X =

5.0000 + 3.0000i

9.0000 + 2.0000i

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

% Matrix multiplication (element wise)

C = A .* A_trans

C =

25.0000

24.0000

7.0000

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

MATLAB command prompt or as Script files (.m)

Either

type edit <filename>.m in MATLAB command

prompt to open the editor or

go File - New - Blank M File

numbers in an image.

Characters are in white and of a fixed

size.

Background is black in color.

The image is in binary format.

We will explore various concepts as we

implement this.

% Set working directory to directory

% containing this tutorial

% Reading an image

% A = IMREAD(FILENAME,FMT) or

% A = IMREAD('FILENAME.FMT')

im=imread('.\char recog\testimage.bmp');

% It is better to suppress outputs when

% reading images. Try once without the

% colon at the end of command

% Displaying an image

imshow(im)

% To open a separate window for the

% figure and not overwrite in the

% existing window

figure

imshow(im)

figure, imshow(im)

Now read the image same color.jpg and display it on a window.

Once the image is displayed in the window, select Tools Data Cursor or select the shortcut

toolbar.

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

Now read the image same color.jpg and display it on a window.

Once the image is displayed in the window, select Tools Data Cursor or select the shortcut

toolbar.

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.

What are the RGB values at the two points?

B

A

Lets write a function charrec(im)which when called with an image file, will

display the characters as shown earlier

>> im=imread('.\char recog\testimage.bmp');

>> imshow(im);

>> charrec(im);

The digits found in the image are:

0

3

5

The letters found in the image are:

L

N

Few examples of functions in MATLAB

% Function returning no output

function sample(ip1,ip2,ip3,)

.

.

.

end

% Function with outputs

function [op1,op2,]=sample(ip1,ip2,ip3,)

.

.

.

End

% save the code as sample.m. Function name

% and m-file name should be the same

The Algorithm

Dilation

number of pixels added from the objects in an image

depends on the size and shape of the structuring element

function strel() can be used to generate the SEs.

>> SE = strel('diamond', 1)

SE =

Flat STREL object containing 5 neighbors.

Neighborhood:

0

1

1

1

0

1

0

1

0

>> SE = strel('square',3)

SE =

Flat STREL object containing 9 neighbors.

Neighborhood:

1

1

1

1

1

1

1

1

1

various combinations

SE =

Flat STREL object containing 5 neighbors.

Neighborhood:

0

0

0

0

0

0

0

1

1

0

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

want to recognize. (For all those individual character

images in the folder)

>>

>>

>>

>>

>>

SE = strel('square',3);

N1 = imdilate(N,SE);

N2 = N1 - N;

figure,imshow(N2)

Function, bwhitmiss is employed to check if a particular character is present in

the given image.

bwhitmiss(BW1,SE1,SE2) performs the hitmiss operation defined by the

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

You can now use charrec.m to recognize few characters in a crude way.

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);

%

%

%

%

function graythresh to calculate the

threshold. Otsus method is implemented in

graythresh function.

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,[])

% processing time and k on thresholding

% level

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

%

%

%

%

form objects in the image. These are

called connected components. Read more

about 4-connectivity and 8-connectivity

% a particular number as pixel value to one CC

>> [bw_labelled num]=bwlabel(im_recon);

>> figure,imshow(bw_labelled,[])

% We can use regionprops() to extract some

% properties of the CCs

>> areas = regionprops(bw_labelled,'Area')

% Here areas is a struct variable

% Try experimenting with other properties and

% explore what property can be used to

% distinguish between CCs

>> areas1=[];

>> for i=1:length(areas)

areas1=[areas1; areas(i,1).Area];

end

>> areas1

areas1 =

415711

26440

10350

8630

17971

8282

5243

% We are interested in objects (the squares) with area in range 8000% 9000

>> index=find(areas1>8000 & areas1<9000);

>> finalimg=zeros(size(bw_labelled));

>> for i=1:length(index)

finalimg=finalimg+(bw_labelled==index(i));

end

>> 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.

You can try

Edge detection

>>

>>

>>

>>

im=imread('ouch.jpg');

im_gray=rgb2gray(im);

imedge=edge(im_gray,'canny',[0.1 0.2]);

figure,imshow(imedge)

% threshold levels

and

Removing Noise By Median Filtering

(MATLAB Help)

- A Web Page Topic Segmentation Algorithm Based on Visual Criteria and Content LayoutUploaded byIDIR2002
- Enhancement Techniques and Methods for Brain MRI ImagingUploaded byRahul Sharma
- Final Year Matlab Project List With Abstract 2012Uploaded byMohit Sngg
- Color Based SegmentationUploaded byZaib Un Nisa Hafeez
- Chan Vese AlgorithmUploaded bynikesharai
- 4-July-Data Analysis and Mathematical Modelling Using MATLABUploaded bychmscem
- ARIA User GuideUploaded byNitheshksuvarna
- Component Activities in Liquid Mixture, Using NRTL - File Exchange - MATLAB CentralUploaded bybakhtyar21
- Matlab Intro 1Uploaded byMahmoud Basho
- A 43040105Uploaded byAnonymous 7VPPkWS8O
- Image SegmentationUploaded byAshish
- PENTOOLS - A MATLAB Toolkit for on-line Pen-BasedUploaded bysm-malik
- Writer Identification For Handwritten Document Based On Structured LearningUploaded byInnovative Research Publications
- Yun ThesesggUploaded bynannurah
- Image Segment at i OnUploaded bySuresh Ibk
- IJIREEICE3G a ragini RECOGNITION OF VEHICLE NUMBER PLATE USING MATLAB (1).pdfUploaded byMuhammad Azhar Iqbal
- V.kartHIKEYAN Published Article4Uploaded bykarthikeyan.v
- Read Me FirstUploaded byDinesh Kumar
- How Do I Extract Data From MATLAB Figures_ - MATLAB Answers - MATLAB CentralUploaded bymjasd
- 090611-ebimage-pau-2Uploaded byRony Castro Alvarez
- 06544186Uploaded byWilliam Davis
- IntroductiontoMatlab_cse802Uploaded byAndrea Fields
- Segmentation of SAR images using improved artificial bee colony algorithm and neutrosophic setUploaded byMia Amalia
- 5936Uploaded byswonera
- Matlab TutorialUploaded bykober2124
- iris bio metricUploaded byMehdi Hafeez
- Variation on Displacements Due to Change in Modulus of Elasticity and Moment of InertiaUploaded byBijay ban
- NR-410507-Digital Speech and Image Processing-CUploaded byvasuvlsi
- Diskritisasi Pada Sistem Persamaan Diferensial ParUploaded byarum citra
- Assignment ImageUploaded byAmirul Hafiz

- Casting Defects and RemediesUploaded byraoz81
- Big Daishowa s00 Features Catalogue en 2009Uploaded byraoz81
- imageprocessingbasedintelligenttrafficcontrolsystemmatlabgui-140625205454-phpapp01Uploaded byraoz81
- Aluminium-Alloy-AMS4101-QQ-A-25029-T851-Plate_228.pdfUploaded byraoz81
- DefectsUploaded byErin Hutchinson
- Aluminium Alloy AMS 4050 T7451 Plate 223Uploaded byraoz81
- Application Form Corrected Dha PeshawarUploaded byraoz81

- Distributed Databases.docxUploaded byKandiga Parandhaman
- JD Edwards EnterpriseOne Mapping Fields for Batch ProcessingUploaded bynick_bc688
- Module 16 – Backup and RecoveryUploaded bykamakom78
- Dcs 500 ProcedureUploaded byBoobalan Gnanam
- CFP-JAIS-2Uploaded byRahmath Safeena
- Práctica 7Uploaded byItzzy Prin
- Playing on the Digital CommonsUploaded byTupayMachado
- L4portUploaded byMona Ali
- snapdeal_casestudyUploaded byNaval Garg
- Elias Sleiman ResumeUploaded byTravis Turner
- 2-Microsoft Excel MCQsUploaded byNazyah Mehdi
- Revit 2009 TutorialUploaded byRashmi Mehadia
- datasheet_98-8970-0_enUploaded byYihad
- 2000 E-ASEAN Framework Agreement-PDFUploaded byAnnisa Alifa
- Net Admin QuestionsUploaded byDc Link
- 248 Ford ModulesUploaded byraffael07
- TM-1002 AVEVA Plant (12.1) Drawing Production (Basic) - Revision 2.0Uploaded byMarco Carrieri
- GS FLX System Software Manual v2.5.3 OverviewUploaded byrinsy41
- SOH GUAN CHEN 211330Uploaded byChong SiowHui
- satish 123...Uploaded byPoonam Kapadia
- 4 IPasolink Ethernet Functions 1-LibreUploaded byÉdipo Lisboa
- MRK 1103 Coursework - 201720 - Report (40) (1)Uploaded byAhmed
- Setting Up a Maven RepositoryUploaded bycomplore
- Nexia_RS232_Control_(Jan10)Uploaded bylucata17
- System Admin Course - Samsung DCSUploaded bychrismoore8
- Environmental Pollution Control by CS RAOUploaded byChandra Sekhar
- Rel-12 Description 20120924Uploaded byanadhim3
- Complexity and Self-organizationUploaded byGiorgio Bertini
- Case Study of library management systemUploaded byridihima
- Universal Trading Platform for International MarketsUploaded byNYSE Technologies