필터 지우기
필터 지우기

find spots in image

조회 수: 25 (최근 30일)
PJM
PJM 2013년 7월 27일
댓글: Image Analyst 2014년 3월 30일
and I use the code, then I can find the spots.
----------
clear all;
Cimg=imread('CropTest1.jpg','jpg');
Gimg=rgb2gray(Cimg);
BW=Gimg>150;
rp=regionprops(BW,Gimg,'WeightedCentroid');
disp('Centroiding is done.');
figure(1); image(Cimg); axis image; hold on;
n=numel(rp);
for i=1:n
plot(rp(i).WeightedCentroid(1), rp(i).WeightedCentroid(2), 'r*')
end
----------
and I have coordinates of all spots.
then I want to do these
- express Center spot -> (0,0)
- find missing spots (-1,3),(5,1),(1,-5) and output the message: '(-1,3),(5,1),(1,-5) are missing!'
- delete one spot in double spots that use this idea: distance of two spots(well, I seem to be able to do this.)
thank you for your advice and help.

채택된 답변

Image Analyst
Image Analyst 2013년 7월 27일
I can't see your images, though I'm in Beijing this week and imageshack.us seems to be another domain in a long list of web sites I've encountered that are banned by the government of China. Nonetheless, I'll try to help as best I can without seeing your images. I'm assuming that you have a 10 by 10 array of possible locations of the circles. You first define a logical array initialized to false that says whether or not you have a circle there. Then set it to true when you find a circle there. Try something like this (untested)
circlePresent = false(10,10);
% Then loop over circles you have found setting the array to true.
centroids = [rp.WeightedCentroid];
[rows, columns] = size(BW);
for k = 1 : length(rp)
if centroids(k, 2) < rows/10
row = 1;
elseif centroid(k, 2) < 2*rows/10
row = 2;
elseif centroid(k, 2) < 3*rows/10
row = 3;
% and so on up to 10.
% Then do the same for columns.
if centroids(k, 1) < columns/10
column = 1;
% etc.
% Now set the array to true for this circle
circlePresent(row, column) = true;
end
% Now find missing elements
[missingRows, missingColumns] = find(~circlePresent);
% Print out all the missing circles array locations.
for k = 1 : length(missingRows)
fprintf('There is a circle missing at row %d, column %d.\n', ...
missingRows(k), missingColumns(k));
end
  댓글 수: 5
ajinkya nikam
ajinkya nikam 2014년 3월 30일
i did not get anything. matlab only tells that CONTINUE ENTERING STATEMENT what should do
Image Analyst
Image Analyst 2014년 3월 30일
I have no idea what you're referring to. Start your own thread, post your own code and image, and I'll see what I can do.

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

추가 답변 (1개)

Elad
Elad 2013년 7월 27일
I would try imfindcircles(), (or hough transform to find circles if you don't have the toolbox). You can adjust the sensitivity and edge until you find all the spots. Than you can calculate the average intesity in each circle and have full control on your results.
Here is an example in the image processing blog, using imfindcircles: http://imageprocessingblog.com/detecting-and-counting-objects-with-circular-features/
  댓글 수: 4
Elad
Elad 2013년 7월 27일
편집: Elad 2013년 7월 27일
[centers, radii] = imfindcircles(clb1,[8 15],'Sensitivity',0.91,'Edge',0.01);
gets all the spots but one.
[centers, radii] = imfindcircles(clb1,[8 15],'Sensitivity',0.9,'Edge',0.01,'ObjectPolarity','dark');
gets the last spot.
PJM
PJM 2013년 7월 27일
Wow! actually, I feel the limit of regionprops when bright backgrounds. I will try this way.
Thank you for your help. :D

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

카테고리

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