MATLAB Answers

Help remove unconnected small pixel from image

3 views (last 30 days)
Hello, maybe this question have been ask from other people, but i not fully understand how this code work. when i combine with my code it appear "index exceeds the number of array element" . can u help fix my code and help me understand the function

Accepted Answer

Uday Pradhan
Uday Pradhan on 7 Jan 2021
Hi,
I found the mistake at line 132 of the code you have attached. If you notice, grayImage is already a binary image so thresholding it this way, will lead to binaryImage being a logical array with only zeros, hence the error.
% Threshold the image to binarize it.
binaryImage = grayImage > 100;
I believe you can just take:
% Threshold the image to binarize it.
binaryImage = grayImage ;
and then run the code to get the largest extracted blob. I hope this helps!

More Answers (0)

Community Treasure Hunt

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

Start Hunting!