OMR Sheet Evaluation Toolbox Using MATLAB
OMR Sheet Evaluation Toolbox Using MATLAB
Report on
“OMR Sheet Evaluation Toolbox Using MATLAB”
Submitted to:
Md. Mukhlasur Rahman Tanvir
Mohammad Tariqul Islam
Submitted by
Md. Mehedi Hossen Limon (Student ID- 1406059)
Fariba Islam (Student ID- 1406060)
Department: EEE
Section: A-2
Level 2; Term 2
1
December 17, 2016
Md. Mukhlasur Rahman Tanvir
Mohammad Tariqul Islam
Department of Electrical and Electronic Engineering
BUET
Dear Teachers,
We have the pleasure to present the report on “OMR Sheet Evaluation Toolbox Using
MATLAB”. We would like to take this occasion to express our sincere gratitude to you for
giving us such an opportunity to make a report which has enhanced our knowledge on such an
important software like MATLAB whose use is almost inevitable in engineering world.
OMR sheets are used to answer MCQs of different examinations here we tried to make an OMR
sheet evaluation toolbox so that without requiring an OMR reader one would be able to check
OMR sheets easily.
We tried our best to explain our project in this report as far as possible. But limitation of time
restrained us to make it as illustrative as it should be. Yet we think this report will help the readers
to understand how this project will come into use.
Thank you for your consideration.
Faithfully Yours,
Md. Mehedi Hossen Limon
Student ID- 1406059
Fariba Islam
Student ID- 1406060
Section: A-2
Level-2, Term 2
Department: EEE;
2
Abstract:
MCQs are very common type of questions nowadays. These MCQs are answered in OMR
sheets. Checking these sheets require an OMR reader which is large and money needs to be spent
to buy it.
The aim of this project is to develop a code in MATLAB using which OMR sheets can be
checked using PC. Effort has been given to make this application user-friendly and as less time
consuming as possible.
A graphical user interface is introduced to make the application user friendly. One would need to
load the solution of the question paper and the scanned image of the answer script to evaluate the
answer script. The actual script needs to be scanned, image of photocopied script results in error.
3
Contents
1. Introduction .................................................................................................................................... 5
2. Methodology .................................................................................................................................... 5
2.1loading and working with the solution of the question and image of the answer script ..................... 5
2.3 Determination of the answer given to each question and evaluation ........................................ 7
2.4 Graphical User Interface (GUI) .................................................................................................... 7
3. Result ............................................................................................................................................... 8
4
1. Introduction:
Nowadays multiple choice questions (MCQs) are inevitable part of almost all examinations.
Even in admission tests of different schools, colleges and universities a significant part of the
question paper comprises of MCQs. Checking MCQs manually would have been a tiring and
troublesome task for human beings and that is why OMR sheets were invented. This sheet can be
scanned and read by an OMR reader to find out the marks obtained by the students. In this
project it was aimed to make an OMR reader using MATLAB to lessen the requirement of
needing an OMR reader for checking the MCQs, rather having a PC with MATLAB installed
will be enough for that purpose. This will help to digitalize the education system even more.
Because the students can fill up the scanned image of the blank OMR sheet in Microsoft paint or
other such software and email it to the examiner the examiner can then easily check the script
using this program. Even students can use it for self-assessment.
Here we introduced GUI to make the OMR reader easier to use.
2. Methodology
5
Once the image is loaded the program check whether the four black points at four corners have
their centers at the correct places if not an error message is shown.
If the solution uploaded is not in .xls or .xlsx format or if it is blank then again an error message
is shown.
6
2.3 Determination of the answer given to each question and evaluation
From the magnified view it was found that there are 12 pixels within the length ‘h’ which is
considered the width of first pixel column stored in newwidy variable. As it goes ahead along the
diameter parallel to the x axis the height of pixel column increases and after certain period it
becomes fixed. Then at a certain position the height of pixel column started to decrease and
returns to the starting value at the end of the diameter.
A pixel is counted as black if its intensity is below a certain value stored in ‘t’ variable. This is
called threshold intensity value. In this case, the threshold intensity 200 is considered. The total
pixel number, n and black pixel number, totpix are counted by considering each pixel column
along the diameter parallel to x axis.
By accessing each mcq, the circles of the mcq is sent to the blackpixelcounter function which
returns number of black pixel and total pixel in a circle. If the number of black pixel is greater
than a specified percent of total pixel, the circle is considered filled. If filled, the letter related to
that circle is compared with the solution of that question. Mark will be added if the answer is
right. When more than one option is filled in a mcq, the mark of that answer is considered
uncountable.
7
3. Result:
Once the user loads the image
and the solution and the number
of questions, the Roll of the
student his or her marks, Test ID
and any remarks regarding the
marks appears in the
corresponding box. The loaded
image appears in the axes.
It takes a few seconds for the
output to appear.
If one fills up the correct answer
containing circle he gets one
mark and if wrong answer is
given or more than one circle is
filled then the student scores Figure 4: output in the GUI
zero for that question. The
output comes as shown in figure 4.
5. The code
Function For GUI:
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
9
function finalproject_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
[path,user_cance]=imgetfile();
if user_cance
return
end
im=rgb2gray(imread(path));
siz = size(im);
handles.im = im;
axes = handles.axes1;
imshow(handles.im);
guidata(hObject,handles);
qu_no = str2num(get(handles.qno,'String'));
[marks,Remark,Roll,Test] = finalver7(handles.im,handles.solution,qu_no);
handles.marks = marks;
10
set(handles.mark,'String',num2str(marks))
handles.Roll = Roll;
set(handles.remarks,'String',Remark)
handles.Remark= Remark;
set(handles.roll,'String',num2str(Roll))
handles.Test = Test;
set(handles.testid,'String',num2str(Test))
guidata(hObject,handles);
h = msgbox({'Here is our Help Window','Please read to solve your problem or to know what
you want!','','Load OMR','Click the Load Image button', ...
'a file open dialog box will open','Go to OMR Image folder in which the scanned
image of OMR sheets are stored', ...
'Select an image and click open.' ...
'','','In the input box give the number of question you want to evaluate(maximum
60)','','Load Solution','','Click the Load Image button', ...
'a file open dialog box will open.',' Go to OMR Solution folder in which the
solution excel file of OMR sheets are stored.', ...
'Select a file and click open.','','IF YOU CAN NOT SEE ANY FILE,THEN CHANGE THE FILE
TYPE TO *all files ','AND SELECT YOUR SOLUTION FILE.', ...
'NOTE THAT THIS FILES ARE EXCEL FILES.,','','click Evaluate OMR button and wait to
see roll,test id,marks,remarks in the specified field.', ...
'The Roll, marks,Test ID and Remarks are shown In the Specified Field', ...
'','','Click restart if any problem arises or you want to evaluate freshly.','','',
...
'Note: After first omr sheet evaluation', 'you can change the omr or the solution
according to your wish until you press restart button.', ...
'Hope, Your query is Satisfied!'},'HELP');
[path,user_cance]=imgetfile();
if user_cance
return
end
[~,~,sol] = xlsread(path,'A1:A60');
solution = upper(char (sol));
handles.solution = solution;
guidata(hObject,handles);
11
function restart_Callback(hObject, eventdata, handles)
axes(handles.axes1);
imshow('C:\Users\ASUS\Desktop\Final\OMR IMAGE\restartimage.png');
set(handles.qno,'String','');
set(handles.mark,'String','')
set(handles.remarks,'String','')
set(handles.roll,'String','')
set(handles.testid,'String','')
guidata(hObject,handles);
xwid = 22;
ywid = 22;
for l = 1:4
if l == 1
startx= 128;
starty = 261;
elseif l==2
startx = 2324;
starty = 264;
elseif l==3
startx = 130;
starty = 3214;
elseif l==4
startx = 2325;
starty = 3215;
end
synew = starty;
sxnew = startx;
n = 0;total =0;
for i = 1:xwid
for j = 1:ywid
12
a = I(synew+j-1,sxnew+i-1);
if a<=t
n = n + 1;
end
total = total + 1;
end
end
if n>=.4*total
blackblock = blackblock +1;
end
end
if blackblock ==4
oka =1;
else
oka =0;
end
end
function [mark,remarks,Roll,TD]=finalver7(I,solution,num)
% Function: finalver7
% Written By-
% Md. Mehedi Hossen Limon
% Fariba Islam
% Department of Electrical & Electronic Engineering
% Bangladesh University of Engineering and Technology
%
% Inputs :
% I = image file
% solution = a xlsx solution file
% num = number of question
% Outputs:
% mark = Total Correct answer
% remarks = Comment on the Result
% Roll = Roll of the examinee
% TD = Test ID
diffcol = 57;
diffrow = 116;
diffsection = 462;
solution = solution(1:num);
if length(solution)==0
msgbox(sprintf('Error!! Please Restart!'),'Error','Error');
return
end
13
p = .6;
str = 'ABCD';
c = zeros(num,5);
c(:,1) = 1:num;
mark = 0;
R = zeros(10);
Roll = 0;
T = zeros(10,3);
TD = 0;
% for MCQ
for k = 1:num
end
else
c(k,l+1) = 1;
end
% check double fill ;
if l == 4
dob = 0;markdouble = 0;
for a = 1:l
if c(k,a+1) == 0
dob = dob+1;
if Result == solution(k)
markdouble = markdouble +1;
end
end
end
if dob>1 && markdouble ~=0
mark = mark -1;
disp('double')
end
end
end
end
% for roll
14
for k = 1:10
% for test id
for k = 1:10
startx = 949;
starty = 737;diffrow = 57;
sy = starty +(k-1)*diffrow;
for l = 1:3
sx = startx + (l-1)*diffcol;
[n,total] = blackpixelcounter(I,sx,sy);
if n>= p*total
if k ~= 10
TD = TD + k*10^(2-(l-1));
end
else
T(k,l) = 1;
end
end
end
if(mark>=floor(.33*num))
status='Great! Passed!';
else
status='Sorry! Failed! Need Improvement';
end
remarks = status;
end
15
Function for Pixel Counting of a circle:
for i = 1:diameter
end
16