Monday, December 10, 2012

MATLAB CODE - VII

Hough-transform for Circle Detection

For detection circle with unknown radius, another parameter need to be make as variable, which is, the radius R.
1. Reading image and the convert to binary image. After that, the location of the value '1' is found using 'find' function. (assume the image is already preprocess, if not, the 'edge' function might help)

clear all;clc;
I = imread('pic22.bmp');
I =im2bw(I);
[y,x]=find(I);
[sy,sx]=size(I);
imshow(I);


2. Find all the require information for the transformatin. the 'totalpix' is the numbers of '1' in the image.

totalpix = length(x);

3. Preallocate memory for the Hough Matrix. The R is known in the range from 1 to 50, so we reserve 50 "layers" for the HM matrix.

HM = zeros(sy,sx,50);
R = 1:50;
R2 = R.^2;
sz = sy*sx;

4. Performing Hough Transform. Notice the accumulator is located in the inner for loop.

for cnt = 1:totalpix
for cntR = 1:50
b = 1:sy;
a = (round(x(cnt) - sqrt(R2(cntR) - (y(cnt) - [1:sy]).^2)));
b = b(imag(a)==0 & a>0);
a = a(imag(a)==0 & a>0);
ind = sub2ind([sy,sx],b,a);
HM(sz*(cntR-1)+ind) = HM(sz*(cntR-1)+ind) + 1;
end
end

5. Find for the maximum value for each layer, or in other words, the layer with maximum value will indicate the correspond R for the circle.

for cnt = 1:50
H(cnt) = max(max(HM(:,:,cnt)));
end
plot(H,'*-');



6. Extract the information from the layer with maximum value, and overlap with the original image.

[maxval, maxind] = max(H);
[B,A] = find(HM(:,:,maxind)==maxval);
imshow(I); hold on;
plot(mean(A),mean(B),'xr')
text(mean(A),mean(B),num2str(maxind),'color','green')


7. This example use the "for loop" extensively, and the speed of the program is rather slow. Vectorized the code might speed up the execution time.



Measuring Object Length (with a Reference Object)

Let's see this simple example:

1. Reading image and show the true color image.

clear all;clc;
I = imread('pic29.tif');
imshow (I);



2. Assuming that we know the length of the red object (as reference) which is 5 cm, locate the red object with simple command and find the length in pixels:



Ired_labeled = bwlabel(Ired);
Ired_props = regionprops(Ired_labeled);
Ired_length_in_pixel = Ired_props.BoundingBox(3);
disp(Ired_length_in_pixel);

212

3. To measure the length of the green object, extract the object:

Igreen_labeled = bwlabel(Igreen);
Igreen_props = regionprops(Igreen_labeled);
Igreen_length_in_pixel = Igreen_props.BoundingBox(3);
disp(Igreen_length_in_pixel);

146


4. Calculate the length of green object in cm

Igreen_length_in_cm = Igreen_length_in_pixel/Ired_length_in_pixel*5;
disp(Igreen_length_in_cm);

3.4434

Wednesday, November 28, 2012

Neural network matlab Code

Examples of neural network using matlab

Neural Network tool is one of the toolbox in matlab. Neural Network operates Artificial intelligence approach. Most research works are used this concept.This concept mostly working in pattern recognition,classification and prediction.We give some notes, how to use neural network in matlab.
Matlab is Research tool ,mainly used for research and researchers.you have use following operations for study the Neural Network.
Neural Network contain Three layers.
  1. Input Layer
  2. Hidden Layer
  3. Output Layer
Use following operation in Matlab for train the data on NeuralNetwork.
  1. Goto matlab command window.
  2. Type nftool (nftool is keyword, for load the Neural network Toolbox on matlab).
  3. Then you sea following screen.


4. Load The data s from work space.


5.Set The hidden layers of neural network.



5.Then goto Next.Then press Train button train your data.


6.Then goto 2 Next Button then press generate m file.This m file is your training file.


This method for directly using Neural Network Toolbox.
In below create Neural network with using NN toolbox codes and syntax's.
  1. Training use as following code
>> input_data = [1 2;2 3;2 2;4 2;6 6]; % Input matrix
>> output_data = [3;5;4;6;12]; %output vector
>> net = newff(input_data',output_data',20); % design a NN Structure
>> net = train(net,input_data',output_data');% Train the data's
2. Test the data's on NN.
>> pred = sim(net,[2;3]) % test the data's on neural network
 
pred =4.95

This "sim" is a function ,for test the data's on networks.you may have use large amount of data's to train and test on neural network

 

Tips For Research Scholars

Tips For Research Scholars | Pre-PhD Tips | Publishing Research Papers Tips 

Most of the research peoples struggle in them research.Here we put some simple tips for Research scholar.Please note this points for all per-research scholars.Very simple points for Research.

Select your Research Area
This is your most important things of your research.you have choose most like,interested and well knows domain areas.If you choose well know research area means you can easy to complete your PhD.Research area's are like networking,cloud computing or any area.

Find problem
Here you Find out the any one problem of your selected research area.You must implement and solve this problem on your research.Refer more tools and paper (most recent) for solve the find-out problem on your domain.You may use Google scholar and Microsoft research site for help your research works.you have easy to pick the research papers from these sites.

Problem Solving
In this section you must implement your research work and solve the problem  by yourself. Then you have do comparison with old algorithm and proposed algorithms.then you put the more intermediate result on your research paper.


Publishing Papers
This one is main important for you research. Most universities are want to publishing papers on best journals.so you careful to choose the Journal. if your papers accepted on Journals then Reviewer may give some tips for improve the quality of your research papers or ask some doubts of your research works,If they have any doubts then you must clarify all of doubts.If you solve all problems then your papers publishing on that Journal. otherwise may be rejected.