Sunday, 7 September 2014

to print natural numbers repeating each number fixed number of times

To generate output as shown below:
1
1
1
2
2
2
3
3
3

the code is
myfun=[];
for i = 1:3
temp=ones(3,1)*i; %the first parameter in ones function i,e, 3 can be changed to any number, say 6 to print six 1's and then six 2's and so on......
myfun= [myfun;temp];
end

How to draw a circle on detected face using vision toolbox in matlab with center of the circle highlighted

I = imread('KA.SA3.35.png');% this image has been extracted from japanese female expression %database
bb=step(fdetect,I);
c=bb(3)/2;
d=bb(4)/2;
cx=bb(1)+c
cy=bb(2)+d
position=[cx,cy,c];
videoout=insertObjectAnnotation(I,'circle',position,'face');
imshow(videoout);
hold on; plot(cx,cy,'+','MarkerSize',10);
hold off;

Results: