Filter löschen
Filter löschen

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

3 Ansichten (letzte 30 Tage)
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 Kommentar
AminaOsmanova
AminaOsmanova am 22 Feb. 2017
Bearbeitet: AminaOsmanova am 22 Feb. 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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 25 Feb. 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).

Weitere Antworten (1)

Image Analyst
Image Analyst am 23 Feb. 2017
Bearbeitet: Image Analyst am 23 Feb. 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 Kommentare
Image Analyst
Image Analyst am 25 Feb. 2017
This is a commonly enough asked question that I'm working on a demo. I'll post something tomorrow.
AminaOsmanova
AminaOsmanova am 25 Feb. 2017
Thank you for your help

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by