0

when I calculate threshold using entropy and the convert grayscale image to binary image using imbinarize(img,T) it shows the error. How to deal with this error

1 Answer 1

1

imbinarize uses a 256 bin image histogram to compute Otsu's threshold, so it expects a 'uint' image.

From the error we can deduce that your image is double, so just convert it to uint:

img = im2uint8(img)

and then run imbinarize on top of im

im_binarized = imbinarize(img,T)

EDIT:

Also your problem might be that you don't have the image processing toolbox installed.

You can threshold an image without the toolbox, just do:

im_binarized = im > T;   % where T is your threshold
Sign up to request clarification or add additional context in comments.

2 Comments

Undefined function 'im2unit8' for input arguments of type 'double'. show this error
Probably you don't have the image processing toolbox installed. See my edit to threshold an image without the toolbox. Otherwise install the toolbox.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.