有的,函数是graythresh,代码如下,coins.png是自带的图像,代码可直接调用:
I = imread('coins.png');level = graythresh(I);BW = im2bw(I,level);imshow(BW)