I need help with a computer vision-related assignment, I have to build an OMR in MATLAB using the specified instructions but I am not able to do so.
This is the assignment:
You are provided with images of sample answer sheets. Using morphological image processing operators, you are required to develop a system in Matlab which extracts the answers provided by the student for each question.
Hints:
- Binarize the image – The initial Binarization may be a crude one.
- Apply dilation with a horizontal structuring element to merge components in lines.
- Extract each line using CC labeling.
- If required, again binarize each line separately.
- For each line, use CC labeling to find different components. Use the area information to distinguish filled and non-filled bubbles. _ For each question, find the correct answer of the student. Input: Camera-based image of answer sheet
Output: A vector of correct answers provided by the students.
Assumptions: There are no lines with multiple answers and answers for all questions are provided.
Useful MATLAB functions
bwlabel,regionprops,imdilate,imerode,strel
This is the code I have written but it's not bringing me the results, I need some more code or preferably some module which will help me extract the correct answers from the filled answer sheet, attached is the code and input sheet
%reading the images
[fn, pn]=uigetfile('.');
InputImage = im2bw(imread([pn fn]));
figure, imshow(InputImage ), title('Original Binary Image');
% Removing Noise Pixels
% Rnp = bwareaopen(InputImage,45);
%figure,imshow(Rnp),title('Removed Noise Pixels');
% Strcuturing element
% se = strel('rectangle',[1,1]);
se = strel('rectangle', [15,1]);
% Erosion
%img_eroded = imerode(InputImage,se);
% figure,imshow(img_eroded), title('Eroded Image');
%Dilation
img_dilated = imdilate(InputImage, se);
figure, imshow(img_dilated), title('Dilated Image')
% figure,imshow(InputImage);
% Calculate the connected components
CC = bwconncomp(img_dilated);
% Create a label matrix
L = labelmatrix(CC);
% Find the maximum value of the label matrix, this value indicates the number of detected objects
numObjects = max(L(:))
% Display the label matrix
figure, imshow(L,[]);
%subplot (1,3,1), imshow(InputImage ), title('Orignal Binary Image');
%subplot (1,3,2), imshow(img_eroded), title('Eroded Image');
%subplot (1,3,3), imshow(img_dilated), title('Dilated Image');
% To make it easier to differentiate the different connected components, display the label matrix as an RGB Image
figure, imshow(label2rgb(L,'jet', 'k', 'shuffle'));





