MATLAB Answers


how can thresold the gray scale image manually using canny method for thresholding and get the only object in image

Asked by andhavarapu lokesh on 10 Dec 2016
Latest activity Commented on by Image Analyst
on 7 May 2018
please tell me how to do thresholding and get only one object projectdir = 'E:\SHIVA BACKUP\THYROID\P1\newcodes\data1\13002'; %y = 72; X = zeros(128, 128, 1, 72,'uint16'); % Read the series of images. % for p=1 p=1; thisfile = sprintf('IM_%d.dcm', p); filename = fullfile( projectdir, thisfile ); imdata = dicomread(filename); imsize = size(imdata); if ~isequal( imsize, [128 128 1 72] ) fprintf('file is unexpected size %s instead of [128 128 1 72], skipping "%s"\n', mat2str(imsize), filename); else X(:, :, :, :,p) = imdata; end figure(); montage(X(:,:,:,:,p), [0 100])
for i=1:18 v(:,:,i)=X(:,:,:,i); s(:,:,i)=edge(v(:,:,i),'canny',THRESH);%'both',10); figure() imshow(s(:,:,i),[]) end


Sign in to comment.

2 Answers

Answer by Image Analyst
on 10 Dec 2016

We can't read your code because you have not read this link yet.
See my interactive/visual thresholding application here:


thanks a lot your code worked but iam having a problem actually i wanted to return the thresholded binary image and crop that can you please tell me what should i add to return the binary image to your code
That's a good suggestion for me to add this line to the OutputFcn. But until then, just after you call the function, use this code to get the binary image:
binaryImage = (lowThreshold <= grayImage) & (grayImage<= highThreshold);

Sign in to comment.

Answer by Adebabay Belie on 7 May 2018

hello image analyst,finding the actual thresold is so I find it

  1 Comment

Just move the sliders in my app until you get something that looks best.

Sign in to comment.