Re: Segmentation and Granulometry with scikit-image
Hi, Thanks for the rapid respnse, I am using 0.7.2 on windows. The error is now: Traceback (most recent call last): File "C:/Users/DK/PProjects/skimage_seg/scikit_seg.py", line 3, in <module> import skimage.morphology as morph File "C:\Python27\lib\site-packages\skimage\morphology\__init__.py", line 7, in <module> from ._skeletonize import skeletonize, medial_axis ImportError: cannot import name skeletonize Any idea why?. Thanks El sábado, 15 de diciembre de 2012 16:24:31 UTC-5, Tony S Yu escribió:
On Sat, Dec 15, 2012 at 1:58 PM, Dan <dk...@walla.co.il <javascript:>>wrote:
Dear Tony,
Thanks for the script.
I was running the script and I got this error: Traceback (most recent call last): File "C:/Users/DK/PProjects/skimage_seg/scikit_seg.py", line 18, in <module> img_background = morph.reconstruction(img-h, img) AttributeError: 'module' object has no attribute 'reconstruction'
Process finished with exit code 1
Any reason why?
Thanks a lot, Dan
Hi Dan,
Which version of scikit-image are you running? You'll need at least 0.7 (the latest stable release). You can check the version with the following shell command:
$ python -c "import skimage; print skimage.__version__"
-Tony
El lunes, 24 de septiembre de 2012 18:58:19 UTC-4, Tony S Yu escribió:
On Fri, Sep 21, 2012 at 8:46 PM, Stéfan van der Walt <ste...@sun.ac.za>wrote:
On Wed, Sep 19, 2012 at 4:01 AM, ashz <ashz...@gmail.com> wrote:
Granulometry of Snowflakes: http://www.mathworks.com/**products/image/examples.html?** file=/products/demos/shipping/**images/ipexsnow.html<http://www.mathworks.com/products/image/examples.html?file=/products/demos/s...>
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 equalization<https://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.
Best, -Tony
[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()
--
On Sat, Dec 15, 2012 at 6:45 PM, Dan <dkin@walla.co.il> wrote:
Hi,
Thanks for the rapid respnse, I am using 0.7.2 on windows.
The error is now:
Traceback (most recent call last): File "C:/Users/DK/PProjects/skimage_seg/scikit_seg.py", line 3, in <module> import skimage.morphology as morph File "C:\Python27\lib\site-packages\skimage\morphology\__init__.py", line 7, in <module> from ._skeletonize import skeletonize, medial_axis ImportError: cannot import name skeletonize
Any idea why?.
Thanks
Hi Dan, How did you install scikit-image? Also, what's the output of the following? import skimage print skimage.__version__ print skimage.__file__ -Tony
El sábado, 15 de diciembre de 2012 16:24:31 UTC-5, Tony S Yu escribió:
On Sat, Dec 15, 2012 at 1:58 PM, Dan <dk...@walla.co.il> wrote:
Dear Tony,
Thanks for the script.
I was running the script and I got this error: Traceback (most recent call last): File "C:/Users/DK/PProjects/**skimage_seg/scikit_seg.py", line 18, in <module> img_background = morph.reconstruction(img-h, img) AttributeError: 'module' object has no attribute 'reconstruction'
Process finished with exit code 1
Any reason why?
Thanks a lot, Dan
Hi Dan,
Which version of scikit-image are you running? You'll need at least 0.7 (the latest stable release). You can check the version with the following shell command:
$ python -c "import skimage; print skimage.__version__"
-Tony
participants (2)
-
Dan
-
Tony Yu