Borrar filtros
Borrar filtros

How can I detect regions in image using x,y coordinates?

3 visualizaciones (últimos 30 días)
I am a newbie in Image Processing using Matlab. have been successful in doing Marked Circle recognition using Template Matching.This is the code I used:
function[res] = findtemplate(image, template, th, showtemp)
im = rgb2gray(imread(image));
temp = rgb2gray(imread(template));
close all
out = normxcorr2(temp, im);
[m, n] = size(temp);
out = out(m+1: end, n+1: end);
bw = out > th;
r = regionprops(bwlabel(bw));
if nargin > 3
im(1:m, 1:n) = temp;
end
res = r;
clf
imshow(im, [])
hold on
for i=1:length(r)
rectangle('position', [r(i).Centroid(1), r(i).Centroid(2), m, n], 'EdgeColor','r','LineWidth',2);
end
Output image looks like this:
And now I must detect that numbers using x,y coordinates.It would be helpful if someone explains it better since I am a newbie.Thanks in advance!
  1 comentario
AminaOsmanova
AminaOsmanova el 22 de Feb. de 2017
Editada: AminaOsmanova el 22 de Feb. de 2017
I already detected for example that student chose 'A' in question '1' in attached image,now i need to detect each question number(ex:from 1-105) thanks in advance

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 25 de Feb. de 2017
I may still work on the demo, but try what I have so far using the attached m-file and the attached PNG image file (slightly cropped from the one you uploaded).

Más respuestas (1)

Image Analyst
Image Analyst el 23 de Feb. de 2017
Editada: Image Analyst el 23 de Feb. de 2017
I don't understand how or why you found that the filled-in circle for question #1 was A instead of B, but whatever....
For the rest of the circles, simply use your template (list of circle locations) to determine which circle on the row has the most non-white and non-red pixels on it. I.e. find the most gray, black, or blue pixels. If none have enough, then that question went unanswered. Just do what you did to find the first question for all the other questions. What's the difficulty?
[EDIT] Ooooohhhh. I just took a look at your code. That's not good. Bad idea. I know you might think it's a good idea (like many other beginners), but it's not. And if someone says to try findcircles() or hough(), don't pay attention to them either. It's another idea that some beginners might suggest but it is ridiculous. What you need to do is to have a list of rows and columns where the circles are, then simply look in those regions. This is a much, much simpler approach. Simply use the FAQ http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F to build a binary mask at each circle centroid location, and check the darkness by asking regionprops for MeanIntensity of the blue channel of the image.
  3 comentarios
Image Analyst
Image Analyst el 25 de Feb. de 2017
This is a commonly enough asked question that I'm working on a demo. I'll post something tomorrow.
AminaOsmanova
AminaOsmanova el 25 de Feb. de 2017
Thank you for your help

Iniciar sesión para comentar.

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by