Skip to content

Commit

Permalink
Add sphynx docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vfdev-5 committed Apr 25, 2018
1 parent 58bd6b3 commit 80db8b3
Show file tree
Hide file tree
Showing 10 changed files with 386 additions and 96 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
## Linux backup files
*~

## Docs
docs/src

## Arhives
*.zip

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![Build Status](https://travis-ci.org/vfdev-5/ImageTilingUtils.svg?branch=master)](https://travis-ci.org/vfdev-5/ImageTilingUtils)
[![Coverage Status](https://coveralls.io/repos/github/vfdev-5/ImageTilingUtils/badge.svg?branch=master)](https://coveralls.io/github/vfdev-5/ImageTilingUtils?branch=master)
[![Documentation Status](https://readthedocs.org/projects/imagetilingutils/badge/?version=latest)](http://imagetilingutils.readthedocs.io/en/latest/?badge=latest)

# Image Tiling Utils
Minimalistic set of image reader agnostic tools to easily iterate over large images
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = ImageTilingUtils
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
3 changes: 3 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sphinx
recommonmark
-e git://github.com/snide/sphinx_rtd_theme.git#egg=sphinx_rtd_theme
170 changes: 170 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/stable/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('../..'))
import tiling
import sphinx_rtd_theme
from recommonmark.parser import CommonMarkParser


# -- Project information -----------------------------------------------------

project = 'ImageTilingUtils'
copyright = '2018, vfdev-5'
author = 'vfdev-5'

# The short X.Y version
version = 'master (' + tiling.__version__ + ' )'
# The full version, including alpha/beta/rc tags
release = 'master'


# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
source_parsers = {
'.md': CommonMarkParser,
}
source_suffix = ['.rst', '.md']

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {
'collapse_navigation': False,
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'ImageTilingUtilsdoc'


# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'ImageTilingUtils.tex', 'ImageTilingUtils Documentation',
'vfdev-5', 'manual'),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'imagetilingutils', 'ImageTilingUtils Documentation',
[author], 1)
]


# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'ImageTilingUtils', 'ImageTilingUtils Documentation',
author, 'ImageTilingUtils', 'One line description of project.',
'Miscellaneous'),
]

# -- Extension configuration -------------------------------------------------
67 changes: 67 additions & 0 deletions docs/source/const_stride.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
tiling.const_stride
===================

.. currentmodule:: tiling.const_stride

Class provides tile parameters (offset, extent) to extract data from image.

Generated tile extents starts from an origin, has constant stride and can optionally include nodata paddings.
For example, tiling can look like this (origin is negative, include nodata)

.. code-block:: text
tile 0 tile 2 tile 4
|<------->| |<------>| |<------>| etc
tile 1 tile 3 tile 5 tile n-1
^ |<------->| |<------>| |<------>| |<------>|
| |<------------------------------------>|
origin | IMAGE |
| |
Another example, tiling can look like this (origin is negative, no nodata, tile size is not constant at boundaries)

.. code-block:: text
tile 0 tile 2 tile 4
|<->| |<------>| |<------>| etc
tile 1 tile 3 tile 5 tile n-1
^ |<------>| |<------>| |<------>| |<->|
| |<------------------------------------>|
origin | IMAGE |
| |
Another example, tiling can look like this (origin is postive, no nodata, tile size is not constant at boundaries)

.. code-block:: text
tile 0 tile 2
|<------->| |<------>| etc
tile 1 tile 3 tile n-1
^ |<------->| |<------>| |<-->|
|<-------------------------------------->|
| | IMAGE |
| origin |
Basic usage:

.. code-block:: python
from tiling import ConstStrideTiles
tiles = ConstStrideTiles(image_size=(500, 500), tile_size=(256, 256), stride=(100, 100))
print("Number of tiles: %i" % len(tiles))
for x, y, width, height, out_width, out_height in tiles:
data = read_data(x, y, width, height, out_width, out_height)
print("data.shape: {}".format(data.shape))
# Get a tile params at linear index:
extent, out_size = tiles[len(tiles)//2]
.. autoclass:: ConstStrideTiles
:members:
:undoc-members:
39 changes: 39 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Image Tiling Utils
====================
.. image:: https://travis-ci.org/vfdev-5/ImageTilingUtils.svg?branch=master
:target: https://travis-ci.org/vfdev-5/ImageTilingUtils

.. image:: https://coveralls.io/repos/github/vfdev-5/ImageTilingUtils/badge.svg?branch=master
:target: https://coveralls.io/github/vfdev-5/ImageTilingUtils?branch=master


Minimalistic set of image reader agnostic tools to easily iterate over large images


Installation
------------

Package installation is very simple

.. code-block:: bash
pip install git+https://github.com/vfdev-5/ImageTilingUtils.git
Examples
--------

For more practical examples, see this `notebook <https://github.com/vfdev-5/ImageTilingUtils/blob/master/examples/example_const_stride_tiling.ipynb>`_.


.. toctree::
:maxdepth: 2
:caption: Notes

quickstart

.. toctree::
:maxdepth: 2
:caption: Package Reference

const_stride
39 changes: 39 additions & 0 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Quickstart
==========

Let's iterate over a large image with overlapping and extracting always the
same size tiles (in pixels). Let's assume the data access is provided with an example function


.. code-block:: python
def read_data(x, y, width, height, out_width=None, out_height=None):
out_width = width if out_width is None else out_width
out_height = height if out_height is None else out_height
img.read(x, y, width, height, out_width, out_height)
Thus, overlapping tiles can be extracted as

.. code-block:: python
from tiling import ConstStrideTiles
tiles = ConstStrideTiles(image_size=(500, 500), tile_size=(256, 256),
stride=(100, 100))
print("Number of tiles: %i" % len(tiles))
for extent, out_size in tiles:
x, y, width, height = extent
data = read_data(x, y, width, height,
out_width=out_size[0],
out_height=out_size[1])
print("data.shape: {}".format(data.shape))
# Access a tile:
i = len(tiles) // 2
extent, out_size = tiles[i]
.. image:: https://github.com/vfdev-5/ImageTilingUtils/raw/master/examples/example_tiles.png

Loading

0 comments on commit 80db8b3

Please sign in to comment.