From dd9e7f3526671c8b05a89b76e14e81e79914cd04 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Tue, 2 Oct 2012 22:36:47 -0400 Subject: [PATCH 01/81] DOC: Save thumbnails with a fixed image shape A fixed shape improves grid alignment of images and caption in the gallery. --- doc/ext/plot2rst.py | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/doc/ext/plot2rst.py b/doc/ext/plot2rst.py index 92978723..65c77521 100644 --- a/doc/ext/plot2rst.py +++ b/doc/ext/plot2rst.py @@ -27,9 +27,10 @@ plot2rst_rcparams : dict plot2rst_default_thumb : str Path (relative to doc root) of default thumbnail image. -plot2rst_thumb_scale : float - Scale factor for thumbnail (e.g., 0.2 to scale plot to 1/5th the - original size). +plot2rst_thumb_shape : float + Shape of thumbnail in pixels. The image is resized to fit within this shape + and the excess is filled with white pixels. This fixed size ensures that + that gallery images are displayed in a grid. plot2rst_plot_tag : str When this tag is found in the example file, the current plot is saved and @@ -73,7 +74,10 @@ import numpy as np import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt -from matplotlib import image + +from skimage import io +from skimage import transform +from skimage.util.dtype import dtype_range LITERALINCLUDE = """ @@ -160,7 +164,7 @@ def setup(app): ('../examples', 'auto_examples'), True) app.add_config_value('plot2rst_rcparams', {}, True) app.add_config_value('plot2rst_default_thumb', None, True) - app.add_config_value('plot2rst_thumb_scale', 0.25, True) + app.add_config_value('plot2rst_thumb_shape', (250, 300), True) app.add_config_value('plot2rst_plot_tag', 'PLOT2RST.current_figure', True) app.add_config_value('plot2rst_index_name', 'index', True) @@ -335,7 +339,8 @@ def write_example(src_name, src_dir, rst_dir, cfg): thumb_path = thumb_dir.pjoin(src_name[:-3] + '.png') first_image_file = image_dir.pjoin(figure_list[0].lstrip('/')) if first_image_file.exists: - image.thumbnail(first_image_file, thumb_path, cfg.plot2rst_thumb_scale) + first_image = io.imread(first_image_file) + save_thumbnail(first_image, thumb_path, cfg.plot2rst_thumb_shape) if not thumb_path.exists: if cfg.plot2rst_default_thumb is None: @@ -345,6 +350,28 @@ def write_example(src_name, src_dir, rst_dir, cfg): shutil.copy(cfg.plot2rst_default_thumb, thumb_path) +def save_thumbnail(image, thumb_path, shape): + """Save image as a thumbnail with the specified shape. + + The image is first resized to fit within the specified shape and then + centered in an array of the specified shape before saving. + """ + rescale = min(float(w_1) / w_2 for w_1, w_2 in zip(shape, image.shape)) + small_shape = (rescale * np.asarray(image.shape[:2])).astype(int) + small_image = transform.resize(image, small_shape) + + if len(image.shape) == 3: + shape = shape + (image.shape[2],) + background_value = dtype_range[small_image.dtype.type][1] + thumb = background_value * np.ones(shape, dtype=small_image.dtype) + + i = (shape[0] - small_shape[0]) // 2 + j = (shape[1] - small_shape[1]) // 2 + thumb[i:i+small_shape[0], j:j+small_shape[1]] = small_image + + io.imsave(thumb_path, thumb) + + def _plots_are_current(src_path, image_path): first_image_file = Path(image_path.format(1)) needs_replot = (not first_image_file.exists or From 527e4b579d01374a9644e00f1ca0636829636d33 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Tue, 2 Oct 2012 23:42:14 -0400 Subject: [PATCH 02/81] DOC: Remove task list from docs Add link to new task list on github wiki. --- TASKS.txt | 110 +----------------------------------------------------- 1 file changed, 1 insertion(+), 109 deletions(-) diff --git a/TASKS.txt b/TASKS.txt index da715573..9a846be9 100644 --- a/TASKS.txt +++ b/TASKS.txt @@ -22,116 +22,8 @@ following challenges you'd like to solve. * Mentoring is available for those new to scientific programming in Python. * The technical detail of the `development process`_ is given below. * :doc:`How to use GitHub ` when developing skimage +* If you're looking something to implement, you can find a list of `requested features on github `__. In addition, you can browse the `open issues on github `__. .. contents:: :local: -Tasks ------ - -.. :doc:`gsoc2011` -.. :doc:`coverage_table` - -Implement Algorithms -```````````````````` -- Graph cut segmentation -- `Image colorization `__ -- Fast 2D convex hull (consider using CellProfiler version) - `Algorithm overview `__. - `One free implementation - `_. - [Compare against current implementation] -- Convex hulls of objects in a labels matrix (simply adapt current convex hull - image code--this one's low hanging fruit). Generalise this solution to also - skeletonize objects in a labels matrix. -- Add binary features (BRIEF, BRISK, FREAK) -- Add `STAR features `__ -- `Blurring kernel estimation `__ - -Drawing (directly on an ndarray) -```````````````````````````````` -- Wu's algorithm for circles -- Text rendering -- Add anti-aliasing - -Infrastructure --------------- -- Add @greyimage decorator to check if input is a greyscale image -- :strike:`Implement a new backend system so that we may start including - PyOpenCL-based algorithms` - -Adapt existing code for use -``````````````````````````` -These snippets and packages have already been written. Some need to be -modified to work as part of the scikit, others may be lacking in documentation -or tests. - - * :strike:`Connected components` - * Nadav's bilateral filtering (first compare against CellProfiler's - code, based on http://groups.csail.mit.edu/graphics/bilagrid/bilagrid_web.pdf) - Also see https://github.com/stefanv/scikits-image/tree/bilateral - * 2D image warping via thin-plate splines [ask Zach Pincus] - -Merge code provided by `CellProfiler `_ team -````````````````````````````````````````````````````````````````````````` -* Roberts filter - convolution with diagonal and anti-diagonal - kernels to detect edges -* Minimum enclosing circles of objects in a labels matrix -* spur removal, thinning, thickening, and other morphological operations on - binary images, framework for creating arbitrary morphological operations - using a 3x3 grid. - -Their SVN repository is read-accessible at - -- https://svn.broadinstitute.org/CellProfiler/trunk/CellProfiler/cellprofiler - -The files for the above algorithms are - -- https://svn.broadinstitute.org/CellProfiler/trunk/CellProfiler/cellprofiler/cpmath/cpmorphology.py -- https://svn.broadinstitute.org/CellProfiler/trunk/CellProfiler/cellprofiler/cpmath/filter.py - -There are test suites for the files at - -- https://svn.broadinstitute.org/CellProfiler/trunk/CellProfiler/cellprofiler/cpmath/tests/test_cpmorphology.py -- https://svn.broadinstitute.org/CellProfiler/trunk/CellProfiler/cellprofiler/cpmath/tests/test_filter.py - -Quoting a message from Lee Kamentsky to Stefan van der Walt sent on -5 August 2009:: - - We're part of the Broad Institute which is non-profit. We would be happy - to include our algorithm code in SciPy under the BSD license since that is - more appropriate for a library that might be integrated into a - commercial product whereas CellProfiler needs the more stringent - protection of GPL as an application. - -In 2010, Vebjorn Ljosa officially released parts of the code under a -BSD license (:doc:`cell_profiler` | `original message -`_). - -Thanks to Lee Kamentsky, Thouis Jones and Anne Carpenter and their colleagues -who contributed. - -Rework linear filters -````````````````````` -* Fast, SSE2 convolution (high priority) (see prototype in pull requests) -* Should take kernel or function for parameter (currently only takes function) -* Kernel shape should be specifiable (currently defaults to image shape) - -io -`` -* Update ``qt_plugin.py`` and other plugins to view collections. -* Rewrite GTK backend using GObject Introspection for Py3K compatibility. -* Add DICOM plugin for `GDCM `__. -* Add ``imread_collection`` to all ``imread`` backends -* Better video loading (move to plugin framework, add backends) - -viewer -`````` -* Using the visualization tools, add an FFT-domain image editor - -docs -```` -* Add examples to the gallery -* Write topics for the `user guide - `_ -* Integrate BiBTeX plugin into Sphinx build From 5e97f1f1ea0de611b09ffbe2b133cf4f72d683dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 3 Oct 2012 20:01:00 +0200 Subject: [PATCH 03/81] Fix navigation docs link --- doc/source/_templates/navbar.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/_templates/navbar.html b/doc/source/_templates/navbar.html index b0fa8026..7ef84786 100644 --- a/doc/source/_templates/navbar.html +++ b/doc/source/_templates/navbar.html @@ -1,5 +1,5 @@
  • Home
  • Download
  • Gallery
  • -
  • Documentation
  • +
  • Documentation
  • Source
  • From c6cf768a9cc25c345110bb74eba98798b43bc108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 3 Oct 2012 20:06:38 +0200 Subject: [PATCH 04/81] Extend CSS rule for all headings --- doc/source/themes/scikit-image/static/css/custom.css | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/source/themes/scikit-image/static/css/custom.css b/doc/source/themes/scikit-image/static/css/custom.css index df60739e..85a174df 100644 --- a/doc/source/themes/scikit-image/static/css/custom.css +++ b/doc/source/themes/scikit-image/static/css/custom.css @@ -14,10 +14,9 @@ pre { font-size: 11px; } -h1, h2, h3, h4 { - clear: left; +h1, h2, h3, h4, h5, h6 { + clear: left; } - h1 { font-size: 30px; line-height: 36px; From 060d92fb576fce31423f2b1e3edf7e53d049503a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 3 Oct 2012 20:31:55 +0200 Subject: [PATCH 05/81] Fix navigation home page link --- doc/source/_templates/navbar.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/_templates/navbar.html b/doc/source/_templates/navbar.html index 7ef84786..267af8e7 100644 --- a/doc/source/_templates/navbar.html +++ b/doc/source/_templates/navbar.html @@ -1,4 +1,4 @@ -
  • Home
  • +
  • Home
  • Download
  • Gallery
  • Documentation
  • From 904803184526e69dad2c3b4044e03a6298cd87f1 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Wed, 3 Oct 2012 17:03:54 -0700 Subject: [PATCH 06/81] DOC: Credit Johannes for website layout. --- CONTRIBUTORS.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 5f18e821..c73b14e2 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -107,7 +107,7 @@ - Johannes Schönberger Drawing functions, adaptive thresholding, regionprops, geometric - transformations, LBPs, polygon approximations, and more. + transformations, LBPs, polygon approximations, web layout, and more. - Pavel Campr Fixes and tests for Histograms of Oriented Gradients. From 089f7ffda049395249e5e8057ad21bff8659063e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Thu, 4 Oct 2012 09:25:24 +0200 Subject: [PATCH 07/81] Change domain name --- doc/Makefile | 2 +- doc/release/release_0.3.txt | 4 ++-- doc/release/release_0.4.txt | 4 ++-- doc/release/release_0.5.txt | 2 +- doc/source/_static/docversions.js | 2 +- doc/source/gitwash/this_project.inc | 2 +- doc/source/overview.txt | 4 ++-- doc/source/random_gallery.py | 4 ++-- doc/source/themes/scikit-image/layout.html | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index f750fb18..ea6e26e3 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -124,7 +124,7 @@ gh-pages: gitwash: python tools/gitwash/gitwash_dumper.py source scikit-image \ - --project-url=http://scikit-image.org \ + --project-url=http://skimage.org \ --project-ml-url=http://groups.google.com/group/scikit-image \ --repo-name=scikit-image \ --github-user=scikit-image \ diff --git a/doc/release/release_0.3.txt b/doc/release/release_0.3.txt index 617c3614..743e388d 100644 --- a/doc/release/release_0.3.txt +++ b/doc/release/release_0.3.txt @@ -9,11 +9,11 @@ Python (>=2.6 or 3.x), NumPy and SciPy can be installed. For more information, visit our website - http://scikit-image.org + http://skimage.org or the examples gallery at - http://scikit-image.org/docs/0.3/auto_examples/ + http://skimage.org/docs/0.3/auto_examples/ New Features ------------ diff --git a/doc/release/release_0.4.txt b/doc/release/release_0.4.txt index 04679271..2e8092dd 100644 --- a/doc/release/release_0.4.txt +++ b/doc/release/release_0.4.txt @@ -6,7 +6,7 @@ toolbox for SciPy. Please visit our examples gallery to see what we've been up to: - http://scikit-image.org/docs/0.4/auto_examples/ + http://skimage.org/docs/0.4/auto_examples/ Note that, in this release, we renamed the module from ``scikits.image`` to ``skimage``, to work around name space conflicts with other scikits (similarly, @@ -20,7 +20,7 @@ This release runs under all major operating systems where Python (>=2.6 or For more information, visit our website - http://scikit-image.org + http://skimage.org New Features ------------ diff --git a/doc/release/release_0.5.txt b/doc/release/release_0.5.txt index 652f45fa..4977046a 100644 --- a/doc/release/release_0.5.txt +++ b/doc/release/release_0.5.txt @@ -6,7 +6,7 @@ toolbox for SciPy. For more information, please visit our website - http://scikit-image.org + http://skimage.org New Features ------------ diff --git a/doc/source/_static/docversions.js b/doc/source/_static/docversions.js index 660553e0..7fbc57a0 100644 --- a/doc/source/_static/docversions.js +++ b/doc/source/_static/docversions.js @@ -12,6 +12,6 @@ function insert_version_links() { document.write(open_list); document.write('skimage VERSION \n' .replace('VERSION', labels[i]) - .replace('URL', 'http://scikit-image.org/docs/' + labels[i])); + .replace('URL', 'http://skimage.org/docs/' + labels[i])); } } diff --git a/doc/source/gitwash/this_project.inc b/doc/source/gitwash/this_project.inc index 349b92ba..6010831f 100644 --- a/doc/source/gitwash/this_project.inc +++ b/doc/source/gitwash/this_project.inc @@ -1,5 +1,5 @@ .. scikit-image -.. _scikit-image: http://scikit-image.org +.. _scikit-image: http://skimage.org .. _`scikit-image github`: http://github.com/scikit-image/scikit-image .. _`scikit-image mailing list`: http://groups.google.com/group/scikit-image diff --git a/doc/source/overview.txt b/doc/source/overview.txt index 5a4e6123..3acdeebf 100644 --- a/doc/source/overview.txt +++ b/doc/source/overview.txt @@ -1,7 +1,7 @@ Image Processing SciKit ======================= -The `scikit-image `__ SciKit (toolkit for +The `scikit-image `__ SciKit (toolkit for `SciPy `__) extends ``scipy.ndimage`` to provide a versatile set of image processing routines. It is written in the `Python `_ language. @@ -12,7 +12,7 @@ mailing list (address provided below). Homepage -------- -http://scikit-image.org +http://skimage.org Source, bugs and patches ------------------------ diff --git a/doc/source/random_gallery.py b/doc/source/random_gallery.py index 47ce89a2..3358b3f0 100644 --- a/doc/source/random_gallery.py +++ b/doc/source/random_gallery.py @@ -32,8 +32,8 @@ gallery_div = '''\ examples = glob.glob(os.path.join(example_dir, 'plot_*.py')) images, links = [], [] -image_url = 'http://scikit-image.org/docs/dev/_images/%s.png' -link_url = 'http://scikit-image.org/docs/dev/auto_examples/%s.html' +image_url = 'http://skimage.org/docs/dev/_images/%s.png' +link_url = 'http://skimage.org/docs/dev/auto_examples/%s.html' for e in examples: e = os.path.basename(e) diff --git a/doc/source/themes/scikit-image/layout.html b/doc/source/themes/scikit-image/layout.html index 58424f2f..a1755670 100644 --- a/doc/source/themes/scikit-image/layout.html +++ b/doc/source/themes/scikit-image/layout.html @@ -79,7 +79,7 @@ {%- block extrahead %}{% endblock %} - +