필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
AminaOsmanova
AminaOsmanova 2017년 2월 22일
댓글: AminaOsmanova 2017년 2월 27일
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
AminaOsmanova
AminaOsmanova 2017년 2월 22일
편집: AminaOsmanova 2017년 2월 22일
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

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2017년 2월 25일
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).
  댓글 수: 1
AminaOsmanova
AminaOsmanova 2017년 2월 27일
Thanks for your reply and explanation,you helped me a lot

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2017년 2월 23일
편집: Image Analyst 2017년 2월 23일
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
Image Analyst
Image Analyst 2017년 2월 25일
This is a commonly enough asked question that I'm working on a demo. I'll post something tomorrow.
AminaOsmanova
AminaOsmanova 2017년 2월 25일
Thank you for your help

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by