19
Kfir Wolfson & Adi Barchan Final project, autumn 2006

Kfir Wolfson & Adi Barchan Final project, autumn 2006

Embed Size (px)

DESCRIPTION

The main problem: Drawing is handwritten => not very accurate and grid-aligned. The program also outputs these inaccuracies in the student's drawing.

Citation preview

Page 1: Kfir Wolfson & Adi Barchan Final project, autumn 2006

Kfir Wolfson & Adi Barchan Final project, autumn 2006

Page 2: Kfir Wolfson & Adi Barchan Final project, autumn 2006

GoalGoalThe goal of this project is to recognize a given The goal of this project is to recognize a given Electron-Configuration Graph, of a chemical Electron-Configuration Graph, of a chemical matter. These graphs are in extensive use in matter. These graphs are in extensive use in chemistry studies, laboratories and textbooks. chemistry studies, laboratories and textbooks. This project helps a Chemistry student to top-up This project helps a Chemistry student to top-up his his handwrittenhandwritten electron-configuration drawing electron-configuration drawing abilities, and help him recognize different atom abilities, and help him recognize different atom drawings.drawings.

Page 3: Kfir Wolfson & Adi Barchan Final project, autumn 2006

The main problem:Drawing is handwritten=> not very accurate and grid-aligned.

The program also outputs these inaccuracies in the student's drawing.

Page 4: Kfir Wolfson & Adi Barchan Final project, autumn 2006

Scientific introductionScientific introduction The electron configuration of an atom is the The electron configuration of an atom is the

arrangement of the electrons in it's electron arrangement of the electrons in it's electron orbitalsorbitals. . These are the quantum states of an individual electron These are the quantum states of an individual electron in the electron cloud. in the electron cloud.

The orbitals are arranged in The orbitals are arranged in sub-shellssub-shells, we call , we call levelslevels, , which are numbered: 1s 2s 2p 3s 3p, etc.which are numbered: 1s 2s 2p 3s 3p, etc.

Page 5: Kfir Wolfson & Adi Barchan Final project, autumn 2006

orbital

Level 4 (3s)

Level 3 (2p)

Level 2 (2s)

Level 1 (1s)

Level 5 (3p)

Example of an electron Example of an electron configuration graphconfiguration graph::

((Limitations existLimitations exist))

Page 6: Kfir Wolfson & Adi Barchan Final project, autumn 2006

1.1. Each orbital hold a max of 2 electrons, in different Each orbital hold a max of 2 electrons, in different spinsspins

2.2. Levels will be filled in a bottom-up order (Level x will Levels will be filled in a bottom-up order (Level x will have no electrons, unless all previous levels are full)have no electrons, unless all previous levels are full)

3.3. The orbitals in a level are filled with electrons in a The orbitals in a level are filled with electrons in a left-to-right order, and all orbitals must accommodate left-to-right order, and all orbitals must accommodate an electron before the first one can accommodate two.an electron before the first one can accommodate two.

=> => 1-1 correlation1-1 correlation between an atom of an between an atom of an element, and a configuration graph (drawing). Our element, and a configuration graph (drawing). Our

program can thus return the atom of an input program can thus return the atom of an input drawing.drawing.

Page 7: Kfir Wolfson & Adi Barchan Final project, autumn 2006

The AlgorithmThe Algorithm

The program asks the The program asks the user to input a 1-bit user to input a 1-bit Bitmap image for Bitmap image for analyzing, i.e. a analyzing, i.e. a scanned drawing of scanned drawing of an electron-an electron-configuration graph. configuration graph.

Page 8: Kfir Wolfson & Adi Barchan Final project, autumn 2006

Stage IStage I - - Edge Detection of Edge Detection of horizontal lineshorizontal lines

Using the Prewitt edge detector,Using the Prewitt edge detector,we discover edge points alongwe discover edge points alongwith the direction of the edge atwith the direction of the edge ateach point. each point. We then save only the points We then save only the points with a horizontal directionwith a horizontal direction (0(0 or 180 or 180). ). This stage reduces the effect of This stage reduces the effect of non-relevant items in the non-relevant items in the drawing (vertical lines etc.) drawing (vertical lines etc.) and noise on the algorithm and noise on the algorithm used in Stage II. used in Stage II.

Page 9: Kfir Wolfson & Adi Barchan Final project, autumn 2006

Stage II - Horizontal lines Stage II - Horizontal lines detectiondetection

Horizontal lines detection usingHorizontal lines detection usingthe the Hough transformHough transform for linear for linear lines. The transform is applied lines. The transform is applied to the output of Stage I.to the output of Stage I.As we are interested only inAs we are interested only inhorizontal lines, we don't needhorizontal lines, we don't needthe "a" (tangent) value of the the "a" (tangent) value of the line, but just the "b" (elevation)line, but just the "b" (elevation)value. The following figurevalue. The following figureshows the original image, withshows the original image, withthe detected electron levels, i.e.the detected electron levels, i.e.non-adjacent horizontal lines non-adjacent horizontal lines

Page 10: Kfir Wolfson & Adi Barchan Final project, autumn 2006

Stage III - Find centers of orbitals, Stage III - Find centers of orbitals, using the K-Clustering algorithmusing the K-Clustering algorithm

We first need to segment the We first need to segment the image into horizontal image into horizontal stripes, one for each level.stripes, one for each level.

According to Chemistry rules, According to Chemistry rules, each level has a known each level has a known number of orbitals. This number of orbitals. This number is used as the "K", number is used as the "K", or the number of clusters to or the number of clusters to search for, in the K-search for, in the K-Clustering algorithm. Clustering algorithm.

In the following image each section In the following image each section (horizontal stripe) is marked in a (horizontal stripe) is marked in a specific color, and the cluster-specific color, and the cluster-centers found by the algorithm are centers found by the algorithm are marked as red circles.marked as red circles.

Page 11: Kfir Wolfson & Adi Barchan Final project, autumn 2006

Stage IV - Segment image into small Stage IV - Segment image into small sub-images sub-images )of orbital()of orbital(

Each red circle is an approximation to the center of Each red circle is an approximation to the center of gravity of an orbital. Taking a rectangular window gravity of an orbital. Taking a rectangular window around each circle, will give us a sub-image, which around each circle, will give us a sub-image, which will hopefully contain only the orbital. Here are a will hopefully contain only the orbital. Here are a few examples of sub-images taken in this way:few examples of sub-images taken in this way:

Page 12: Kfir Wolfson & Adi Barchan Final project, autumn 2006

Stage VStage V – – Detect and count Detect and count vertical lines in each sub imagevertical lines in each sub image

As we have an algorithm for detecting horizontal lines, all As we have an algorithm for detecting horizontal lines, all we need to do is rotate by 90we need to do is rotate by 90 and apply stages I and II, to and apply stages I and II, to each sub-image. each sub-image.

The number of lines (electrons) detected in each sub-image The number of lines (electrons) detected in each sub-image (orbital) is saved in a simple data structure, a vector, for (orbital) is saved in a simple data structure, a vector, for the next stage.the next stage.

Page 13: Kfir Wolfson & Adi Barchan Final project, autumn 2006

Stage VIStage VI – – Approximate chemical Approximate chemical element and report errorselement and report errors

The approximation is done by calculating the distance The approximation is done by calculating the distance between the result vector and the database. The between the result vector and the database. The closest element in the DB, and the distance from it, is closest element in the DB, and the distance from it, is plotted to the user. plotted to the user.

This distance represents the difference between the This distance represents the difference between the measured drawing and the approximated element: the measured drawing and the approximated element: the smaller the distance, the closer the drawing is to this smaller the distance, the closer the drawing is to this element.element.

The norm for the distance calculation can be changed The norm for the distance calculation can be changed by the user.by the user.

Page 14: Kfir Wolfson & Adi Barchan Final project, autumn 2006
Page 15: Kfir Wolfson & Adi Barchan Final project, autumn 2006
Page 16: Kfir Wolfson & Adi Barchan Final project, autumn 2006

Logical and SemanticLogical and Semantic errors in the drawing errors in the drawing

Number of levelsNumber of levels Distance between levelsDistance between levels Aligned ColumnsAligned Columns Correct distribution of electrons in the orbitals across the levelCorrect distribution of electrons in the orbitals across the level

Page 17: Kfir Wolfson & Adi Barchan Final project, autumn 2006

Results & ConclusionsResults & ConclusionsThe main stages of the algorithm work on most inputs.

Problems arise in the vertical lines detection.

Example of correct recognition

Example of incorrect recognition

Page 18: Kfir Wolfson & Adi Barchan Final project, autumn 2006

Another problem arises when the arrows are too tall, and so intrude into the image-strip of the above level, thus interfering with the K-Clustering algorithm

Page 19: Kfir Wolfson & Adi Barchan Final project, autumn 2006

THE ENDTHE END.….…