Get the mask for a contour
Francesc Alted
francesc at continuum.io
Thu Feb 28 07:17:23 EST 2013
On 2/28/13 2:17 AM, Tony Yu wrote:
>
>
> On Wed, Feb 27, 2013 at 3:58 AM, Francesc Alted <francesc at continuum.io
> <mailto:francesc at continuum.io>> wrote:
>
> On 2/27/13 3:44 AM, Tony Yu wrote:
>
>
>
> On Mon, Feb 25, 2013 at 8:53 AM, Francesc Alted
> <francesc at continuum.io <mailto:francesc at continuum.io>
> <mailto:francesc at continuum.io <mailto:francesc at continuum.io>>>
> wrote:
>
> On 2/25/13 1:34 PM, St�fan van der Walt wrote:
>
> Hi Francesc!
>
> On Mon, Feb 25, 2013 at 1:57 PM, Francesc Alted
> <francesc at continuum.io <mailto:francesc at continuum.io>
> <mailto:francesc at continuum.io <mailto:francesc at continuum.io>>>
> wrote:
>
> This is my first post here :) I'm using scikits
> image for
> getting some
>
> Welcome :)
>
> features from images. What I'd like is, given a
> contour
> as a serie of dots,
> how can I mask (to zero) the points outside the
> contour?
>
> There happens to be an implementation of that both in
> scikit-image and
> in matplotlib. We use it only internally at the
> moment, so it is
> exposed as:
>
> from skimage._shared.geometry cimport point_in_polygon
>
> and (with a slightly more Pythonic interface) as
>
> skimage.morphology._pnpoly
>
>
> Yes! _pnpoly.grid_points_inside_poly() is what I need,
> but I can
> see points_inside_poly() being useful too. I'm working on
> a PR
> for making these public, but I'm currently getting an
> error when
> trying to process the docs:
>
> ```
> doc/$ make
> [clip]
> Making output directory...
> Running Sphinx v1.1.3
>
> /Users/faltet/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py:1005:
> UserWarning: This call to matplotlib.use() has no effect
> because the the backend has already been chosen;
> matplotlib.use() must be called *before* pylab,
> matplotlib.pyplot,
> or matplotlib.backends is imported for the first time.
>
> warnings.warn(_use_error_msg)
> loading pickled environment... not yet created
> loading intersphinx inventory from
> http://scikit-learn.org/stable/objects.inv...
> loading intersphinx inventory from
> http://docs.scipy.org/doc/scipy/reference/objects.inv...
> loading intersphinx inventory from
> http://docs.scipy.org/doc/numpy/objects.inv...
> loading intersphinx inventory from
> http://docs.python.org/2.7/objects.inv...
>
> Exception occurred:
> File "<string>", line 6, in <module>
> ImportError: No module named rank
> The full traceback has been saved in
>
> /var/folders/2q/970l17jj7sl3mb_jgmmrnw2r0000gn/T/sphinx-err-XyEnG6.log,
> if you want to report the issue to the developers.
> Please also report this if it was a user error, so that a
> better
> error message can be provided next time.
> Either send bugs to the mailing list at
> <http://groups.google.com/group/sphinx-dev/>,
> or report them in the tracker at
> <http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!
> make: *** [html] Error 1
> ```
>
> I'm using Python 2.7.3 and Sphinx 1.1.3. Any hints on this?
>
> Thanks!
>
> -- Francesc Alted
>
>
>
> Hi Francesc!
>
> Could you also post the full traceback. The path is given just
> below the ImportError ("/var/folders/....log")
>
>
> Here you have:
>
> ```
> # Sphinx version: 1.1.3
> # Python version: 2.7.3
> # Docutils version: 0.10 release
> # Jinja2 version: 2.6
> Traceback (most recent call last):
> File
> "/Users/faltet/anaconda/lib/python2.7/site-packages/sphinx/cmdline.py",
> line 188, in main
> warningiserror, tags)
> File
> "/Users/faltet/anaconda/lib/python2.7/site-packages/sphinx/application.py",
> line 134, in __init__
> self._init_builder(buildername)
> File
> "/Users/faltet/anaconda/lib/python2.7/site-packages/sphinx/application.py",
> line 195, in _init_builder
> self.emit('builder-inited')
> File
> "/Users/faltet/anaconda/lib/python2.7/site-packages/sphinx/application.py",
> line 314, in emit
> results.append(callback(self, *args))
> File
> "/Users/faltet/software/scikit-image/doc/source/../ext/plot2rst.py",
> line 183, in generate_example_galleries
> generate_examples_and_gallery(example_dir, rst_dir, cfg)
> File
> "/Users/faltet/software/scikit-image/doc/source/../ext/plot2rst.py",
> line 198, in generate_examples_and_gallery
> write_gallery(gallery_index, example_dir, rst_dir, cfg)
> File
> "/Users/faltet/software/scikit-image/doc/source/../ext/plot2rst.py",
> line 250, in write_gallery
> write_example(src_name, src_dir, rst_dir, cfg)
> File
> "/Users/faltet/software/scikit-image/doc/source/../ext/plot2rst.py",
> line 315, in write_example
> figure_list, rst = process_blocks(blocks, src_path,
> image_path, cfg)
> File
> "/Users/faltet/software/scikit-image/doc/source/../ext/plot2rst.py",
> line 483, in process_blocks
> exec(bcontent, example_globals)
>
> File "<string>", line 6, in <module>
> ImportError: No module named rank
> ```
>
> I suppose this is a bug in Sphinx itself, but thanks for looking
> into this!
>
>
> Actually, I'm not so sure about this. Could you try running the
> example in doc/examples/applications/plot_rank_filters.py (relative to
> skimage repo root)? My guess is that you'll get the same error.
Yes, you are right:
$ python doc/examples/applications/plot_rank_filters.py
Traceback (most recent call last):
File "doc/examples/applications/plot_rank_filters.py", line 78, in
<module>
from skimage.filter.rank import median
ImportError: No module named rank
I have tracked down the error to the fact that I was using the scikit
image that comes with the Anaconda distribution (0.7.1). After forcing
make to use the new scikit image, things progress more, but I still run
into a different problem:
$ PYTHONPATH=.. make
[clip]
Rotated images matched against references using LBP:
original: brick, rotated: 30deg, match result: brick
original: brick, rotated: 70deg, match result: brick
original: grass, rotated: 145deg, match result: grass
Exception occurred:
File
"/Users/faltet/anaconda/lib/python2.7/site-packages/matplotlib/image.py", line
418, in set_data
raise TypeError("Image data can not convert to float")
TypeError: Image data can not convert to float
The full traceback has been saved in
/var/folders/2q/970l17jj7sl3mb_jgmmrnw2r0000gn/T/sphinx-err-2Zhc1A.log,
if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error
message can be provided next time.
Either send bugs to the mailing list at
<http://groups.google.com/group/sphinx-dev/>,
or report them in the tracker at
<http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!
make: *** [html] Error 1
and the contents of
/var/folders/2q/970l17jj7sl3mb_jgmmrnw2r0000gn/T/sphinx-err-2Zhc1A.log are:
# Sphinx version: 1.1.3
# Python version: 2.7.3
# Docutils version: 0.10 release
# Jinja2 version: 2.6
Traceback (most recent call last):
File
"/Users/faltet/anaconda/lib/python2.7/site-packages/sphinx/cmdline.py",
line 188, in main
warningiserror, tags)
File
"/Users/faltet/anaconda/lib/python2.7/site-packages/sphinx/application.py",
line 134, in __init__
self._init_builder(buildername)
File
"/Users/faltet/anaconda/lib/python2.7/site-packages/sphinx/application.py",
line 195, in _init_builder
self.emit('builder-inited')
File
"/Users/faltet/anaconda/lib/python2.7/site-packages/sphinx/application.py",
line 314, in emit
results.append(callback(self, *args))
File
"/Users/faltet/software/scikit-image/doc/source/../ext/plot2rst.py",
line 183, in generate_example_galleries
generate_examples_and_gallery(example_dir, rst_dir, cfg)
File
"/Users/faltet/software/scikit-image/doc/source/../ext/plot2rst.py",
line 198, in generate_examples_and_gallery
write_gallery(gallery_index, example_dir, rst_dir, cfg)
File
"/Users/faltet/software/scikit-image/doc/source/../ext/plot2rst.py",
line 250, in write_gallery
write_example(src_name, src_dir, rst_dir, cfg)
File
"/Users/faltet/software/scikit-image/doc/source/../ext/plot2rst.py",
line 315, in write_example
figure_list, rst = process_blocks(blocks, src_path, image_path, cfg)
File
"/Users/faltet/software/scikit-image/doc/source/../ext/plot2rst.py",
line 483, in process_blocks
exec(bcontent, example_globals)
File "<string>", line 59, in <module>
File "<string>", line 21, in plot_img_and_hist
File
"/Users/faltet/anaconda/lib/python2.7/site-packages/matplotlib/axes.py",
line 7091, in imshow
im.set_data(X)
File
"/Users/faltet/anaconda/lib/python2.7/site-packages/matplotlib/image.py", line
418, in set_data
raise TypeError("Image data can not convert to float")
TypeError: Image data can not convert to float
Uh, that seems like a problem with my matplotlib (1.2.0) in Anaconda?
Or it is just skimage's plot2rst.py?
--
Francesc Alted
More information about the scikit-image
mailing list