Saturday 11 April 2015

Matlab code:- Dilation and erosion example:-


%input image given below in code save it as "finger.tif"
original=imread('finger.tif');
figure(1);
subplot(2,3,1);
imshow(original);
title('Original image');
%SE element B
se=strel('square',3);

%A erode B
A=imerode(original,se);
subplot(2,3,2);
imshow(A);
title('image after erode original with se');

%dilate with (A-B) and then B

A1=imdilate(A,se);
subplot(2,3,3);
imshow(A1);
title('result of (A-B)+B');
% Above result again dialed

A2=imdilate(A1,se);
subplot(2,3,4);
imshow(A2);
title('above image dilated again to fill gaps');

%Eroded with B
final=imerode(A2,se);
subplot(2,3,5);
imshow(final);
title('Final proceed image');

Input:- image :-
finger.tif

OUUPUT:-




Puzzle :- 
             Given 10 table having 10 boxes placed on each table , such that 1st table contains boxes of weight 1gm. ,2nd table contains boxes of weight 2gm . and so on upto 10th table contains boxes of length 10gm. ..
              Now  by mistake one table boxes had been misplaced with 1gm. less weight eg.;- 4 th table boxes are placed with 3 gm boxes  . find out the misplaced table no from given tables.
              [Note:-You have given a weighing machine which weights only once after which it closes ]

Answer:-
               Take out the 1 box from 1st table 2 boxes from 2nd table 3 boxes from 3rd table and so on upto10 boxes from 10th table..
now make weight and take difference with 385 (i.e. idle case when there are no boxes on table were misplaced ) we will get difference as table no.

Ex.;-

(A*B)=A-> no. of boxes    and B=> weight of the box.


Idle case:=  (1*1)+(2*2)+(3*3)+(4*4)+(5*5)+(6*6)+(7*7)+(8*8)+(9*9)+(10*10)  = 385

consider case:-3rd table was misplaced with 1gm less weight so equation becomes 
                  (1*1)+(2*2)+(3*2)+(4*4)+(5*5)+(6*6)+(7*7)+(8*8)+(9*9)+(10*10)  = 382


Difference (TABLE NO:-)==  385-382
                                           ==  3

Friday 10 April 2015

Make the following fish to face on opposite side moving only 3 sticks?

Input
Output
Answer:-

Answer
Note :- More orientations of  moving of sticks are possible above is one of the possibility.