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

2 views (last 30 days)
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)

Walter Roberson
Walter Roberson on 3 Feb 2013
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.

michael Longard
michael Longard on 3 Feb 2013
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;

Image Analyst
Image Analyst on 3 Feb 2013
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
Image Analyst
Image Analyst on 3 Feb 2013
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.
michael Longard
michael Longard on 3 Feb 2013
Edited: michael Longard on 3 Feb 2013
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

Find more on MATLAB Report Generator in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!