
Image Segmentation 233
blood.png paramecium1.png
pinenuts.png daisies.png
FIGURE 9.9: Images to be thresholded
This is an example of putting all the images into a cell array, and iterating over the array
using
cellfun, using a previously described function (in this case thresh). A cell array is
useful here as it can hold arbitrary objects.
MATLAB only supp orts Otsu’s method:
MATLAB
>> cellfun(@(x) graythresh(x),{b,p,n,d},’UniformOutput’,false)
ans =
[0.7451] [0.7529] [0.4745] [0.5137]
In Python, we can iterate over the images by putting them in a list:
Python
In : for x in [b,p,n,d]:
...: print [fl.threshold
_
otsu(x), fl.threshold
_
isodata(x)]
...:
[190, 190] ...