Blurring your image may seem odd, but it often serves to reduce noise, which helps with further processing. With mahotas, it is just a function call:
im16 = mh.gaussian_filter(image, 16)
Notice that we did not convert the grayscale image to unsigned integers; we just made use of the floating point result as is. The second argument to the gaussian_filter function is the size of the filter (the standard deviation of the filter). Larger values result in more blurring, as shown in the following screenshot:
We can use the preceding screenshot and the threshold with Otsu (using the previous code). Now, the boundaries are smoother, without the jagged edges, as shown in the following screenshot: