On Fri, Sep 21, 2012 at 8:46 PM, Stéfan van der Walt email@example.com:
On Wed, Sep 19, 2012 at 4:01 AM, ashz firstname.lastname@example.org wrote:
Granulometry of Snowflakes:
Tony, do you think the morphological reconstruction would work for this?
Yes and no. Morphological reconstruction (specifically, h-dome, a.k.a. h-maxima or regional max) tries to enhance features (maxima) based on the local region. So the h-dome of a dim snowflake and bright snowflake will look similar if they have a similar peakiness. In the original example, dim peaks are still much dimmer than the bright peaks, even after the adaptive histogram equalization.
Also, the h-dome of an image will tend to remove the corona-like blurring around the larger snowflakes since the middle is so much brighter than the surrounding region. I've attached an image of the results, along with the code to generate it (although you can't run it without the snowflakes image, which I probably shouldn't email). You'll notice that dim peaks are much brighter than in the example, and the large snowflakes are smaller (because of suppression of the corona region). These differences alter the intensity curve quite a bit (I'm not sure what the "right" output is, though).
Otherwise perhaps one of the segmentation algorithms. Translating the example line-by-line is pretty easy, except that we do not have adaptive histogram equalization implemented yet.
BTW, there's a pending PR to add adaptive histogram equalizationhttps://github.com/scikits-image/scikits-image/pull/242. (Although, I'm not sure how I feel about the large header file required for that PR.)
As for the original post about these Matlab examples: Thanks for bringing this up, ashz! These are exactly the type of examples I'd like to see in the user guide: Something that takes the user all the way from image loading to data extraction. We'd probably want to write our own instead of simply translating the Matlab examples. It'd be great if people on this list could provide examples from their own research.
[image: Inline image 1]
# Code to generate image above # Note: this won't run without image from Matlab install: # toolbox/images/imdemos/snowflakes.png
from skimage import io from skimage import img_as_float import skimage.morphology as morph from skimage import exposure from scipy import ndimage
# snowflake image from a Matlab install img = io.imread('snowflakes.png') # convert from uint8 to float since we'll be subtracting (prevent underflow) orig = img_as_float(img)
img = exposure.equalize(img) img = ndimage.gaussian_filter(img, 1)
# look for regional maxima greater than surrounding regions by h h = 0.2 img_background = morph.reconstruction(img-h, img) img_hdome = img - img_background img = exposure.rescale_intensity(img_hdome)
io.imshow(img) # io.imsave('snowflakes_enhanced.png', img) io.show()