How Do I represent the number of dots detected? total numbers of dots detected in every snapshot of the camera

I want to display the present, and after next snapshot the present would be a previous, total result of the dots detected in my GUI if every snapshot of the caemra at the GUI, how di i calculate it?..... this is my code..
originalImage = wa; % wa = the input image or video from snapshot
G = rgb2gray(im2double(originalImage));
B = im2bw(imfilter(G, fspecial('gaussian', sigma*3, sigma), 'replicate'), thres);
B1 = bwlabel(B);
dots = max(B1(:))
%calculate number of dots
presentdots = int2str(dots);
set(handles.pres, 'String', presentdots);
% and no idea for previous and total number of dots

Answers (3)

totaldots = 0;
before the loop that gets the images.
After presentdots is calculated,
previousdots = totaldots;
totaldots = totaldots + presentdots;
and then format and send them to the appropriate places.
Hi Sir.. I am still getting error.. =( if i detect 1 dot it gives me a result of 49 which is that sir? =( if 25 dots i get two results 50 , 50 ? =(
dots = max(B1(:))
%calculate number of dots
presentdots = int2str(dots);
set(handles.pres, 'String', presentdots);
previousdots = totaldots;
totaldots = totaldots + presentdots;
set(handles.pres, 'String', totaldots);
%%%THIS IS THE CODE OF THE GUI FOR TESTING LOAD IMAGE
[F,PathName,FilterIndex] = uigetfile({'*.jpg*','Image File(*.jpg*)'}, 'Select Image File');
if FilterIndex ~= 0
b = strcat(PathName,F);
Input = importdata(b);
wa = Input;
axes(handles.live_camera);
imshow(wa);
jonaseye;
You're not doing it right. The number of dots is returned by bwlabel. Try this:
[B1, presentdots] = bwlabel(B);
% Now that we have presentdots, put up info into a label on the GUI.
myLabel = sprintf('The present number of dots = %d', presentdots);
set(handles.pres, 'String', myLabel);

3 Comments

Ty Sir The present result is shown in the GUI, how about for if new number of circles detected in a snapshot so the presentdots would make as a previousdots? how to do that?
and then the total sir ?
do we need if else statement on this?
I appreciate your reply..
I believe you already had a question on that. Either keep track of the last number of dots by setting it equal to the current number of dots, or just make the number of dots an array where each index is the number of dots for that image or iteration.
I follow your code it gives me 1 = 49 in total, 2 = 50 in total =( why is it sir? i guess I need iteration on this to pass the string of the present to the previous and do not yet show in the GUI, then if 2nd snapshot that's the time previous will be shown in the GUI as well as total.. how do I make that in iteration sir? can you help me?
labelString1 = sprintf('previous dots = %d',priorNumberOfDots);
set(handles.prev, 'String', labelString1);
labelString2 = sprintf('current dots = %d', numberOfDots);
set(handles.pres, 'String', labelString1);
totalNumberOfDots = priorNumberOfDots + numberOfDots
labelString3 = sprintf('The total dots = %d', totalNumberOfDots);
set(handles.total, 'String', labelString1);

Sign in to comment.

Categories

Asked:

on 3 Feb 2013

Community Treasure Hunt

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

Start Hunting!