cztile


Namecztile JSON
Version 0.1.2 PyPI version JSON
download
home_page
SummaryA set of tiling utilities
upload_time2023-06-29 16:20:33
maintainer
docs_urlNone
authorNuno Mesquita
requires_python>3.6,<3.12
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # cztile - Python package to simplify the process of tiling arrays

This project provides simple-to-use tiling functionality for arrays. It is not linked directly to the CZI file format, but can be of use to process such images in an efficient and **tile-wise** manner, which is especially important when dealing with larger images.  

## Samples
The basic usage can be inferred from this sample notebook:  
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/zeiss-microscopy/OAD/blob/master/jupyter_notebooks/cztile/cztile_0_0_2.ipynb)

## System setup
The current version of this toolbox only requires a fresh Python 3.x installation. 
Being a pure Python wheel, it was tested with Python 3.9 on Windows.

## Supported Tiling Strategies

This package features the following tiling strategies:  

### AlmostEqualBorderFixedTotalAreaStrategy2D

This covers a total area with a minimal number of tiles of constant total area such that:
- the image area is completely covered by tiles and is filled up with as few tiles as possible
- the overlap/border between tiles is as small as possible, but it is ensured that at least a minimum border size is used
- all interior tiles have the same size
- a possible excess border is split among tiles and can lead to slightly different tile and border sizes at the edge  
- all interior tiles have at least a minimum border width/height on all sides  
- the edge tiles have zero border at the edge and at least the minimum border width on their inner sides.  
- The sizes of all non-zero borders differ at most by one pixel.  

![cztile - AlmostEqualBorderFixedTotalAreaStrategy2D](https://raw.githubusercontent.com/zeiss-microscopy/OAD/master/jupyter_notebooks/cztile/cztile_algo.png)

The core functionality is of course also available for 1D.  

The __AlmostEqualBorderFixedTotalAreaStrategy2D__ is based on the following algorithm:  

#### Inputs

Image width: ![equation](https://latex.codecogs.com/svg.image?W)  
Minimum interior border width (left or right): ![equation](https://latex.codecogs.com/svg.image?%5Cdelta)  
Fixed total tile width: ![equation](https://latex.codecogs.com/svg.image?w)  

#### Calculation of tile positions and borders

**Case 1:** ![equation](https://latex.codecogs.com/svg.image?W%3Cw)  
There is no solution. Fail!  

**Case 2:** ![equation](https://latex.codecogs.com/svg.image?W=w)  
Use a single tile with no borders.  

**Case 3:** ![equation](https://latex.codecogs.com/svg.image?W%3Ew)  
Maximum inner tile width of edge tiles: ![equation](https://latex.codecogs.com/svg.image?%5Chat%7B%5Comega%7D=w-%5Cdelta)  
Maximum inner tile width of interior tiles: ![equation](https://latex.codecogs.com/svg.image?%5Chat%7Bw%7D=w-2%5Cdelta)  
Total interior tile width: ![equation](https://latex.codecogs.com/svg.image?%5COmega=%5Cmax%5C%7B%5C0,W-2%5C,%5Chat%7B%5Comega%7D%5C%7D)  
Number of tiles: ![equation](https://latex.codecogs.com/svg.image?N=%5Cleft%5Clceil%7B%5COmega/%5Chat%7Bw%7D%7D%5Cright%5Crceil&plus;2)  
Excess border: ![equation](https://latex.codecogs.com/svg.image?E=2%5Chat%7B%5Comega%7D&plus;(N-2)%5Chat%7Bw%7D-W)  
Total number of non-zero left and right borders: ![equation](https://latex.codecogs.com/svg.image?%5Cnu=2(N-1))  
Fractional excess border: ![equation](https://latex.codecogs.com/svg.image?e=E/%5Cnu)  
The first non-zero border has index ![equation](https://latex.codecogs.com/svg.image?j=1), the last has index ![equation](https://latex.codecogs.com/svg.image?j=%5Cnu). Tile ![equation](https://latex.codecogs.com/svg.image?i) is surrounded by the borders with index ![equation](https://latex.codecogs.com/svg.image?2i) and ![equation](https://latex.codecogs.com/svg.image?2i&plus;1).  
Cumulative excess border for all borders up to border ![equation](https://latex.codecogs.com/svg.image?j): ![equation](https://latex.codecogs.com/svg.image?E_j=%5Cleft%5Clfloor%7Bje%7D%5Cright%5Crfloor) for ![equation](https://latex.codecogs.com/svg.image?j=0,...,%5Cnu)  
Cumulative border for all borders up to border ![equation](https://latex.codecogs.com/svg.image?j): ![equation](https://latex.codecogs.com/svg.image?%5CDelta_j=E_j&plus;j%5Cdelta) for ![equation](https://latex.codecogs.com/svg.image?j=0,...,%5Cnu)  
Tile boundaries: ![equation](https://latex.codecogs.com/svg.image?x_i=%5Cbegin%7Bcases%7D0%7Ci=0%5C%5Ci%5C,w-%5CDelta_%7B2i-1%7D%7Ci=1,...,N-1%5C%5CW%7Ci=N%5Cend%7Bcases%7D)  
Tile ![equation](https://latex.codecogs.com/svg.image?i) for ![equation](https://latex.codecogs.com/svg.image?i=0,...,N-1):  
- Left-most pixel of inner tile: ![equation](https://latex.codecogs.com/svg.image?L_i=x_i)  
- Right-most pixel of inner tile: ![equation](https://latex.codecogs.com/svg.image?R_i=x_%7Bi&plus;1%7D-1)  
- Inner tile width: ![equation](https://latex.codecogs.com/svg.image?w_i=x_%7Bi&plus;1%7D-x_i)  
- Total border width: ![equation](https://latex.codecogs.com/svg.image?b_i=w-w_i)  
- Left border width: ![equation](https://latex.codecogs.com/svg.image?%5Clambda_i=%5Cbegin%7Bcases%7D0%7Ci=0%5C%5C%5CDelta_%7B2i%7D-%5CDelta_%7B2i-1%7D%7Ci=1,...,N-2%5C%5Cb_i%7Ci=N-1%5Cend%7Bcases%7D)  
- Right border width: ![equation](https://latex.codecogs.com/svg.image?%5Crho_i=b_i-%5Clambda_i)  
- Left-most border pixel: ![equation](https://latex.codecogs.com/svg.image?%5Cl_i=L_i-%5Clambda_i)  
- Right-most-border pixel: ![equation](https://latex.codecogs.com/svg.image?r_i=R_i&plus;%5Crho_i)

## Disclaimer

The libary and the notebook are free to use for everybody. Carl Zeiss Microscopy GmbH undertakes no warranty concerning the use of those tools. Use them at your own risk.

**By using any of those examples you agree to this disclaimer.**

Version: 2022.04.06

Copyright (c) 2022 Carl Zeiss AG, Germany. All Rights Reserved.  


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "cztile",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">3.6,<3.12",
    "maintainer_email": "",
    "keywords": "",
    "author": "Nuno Mesquita",
    "author_email": "nuno.mesquita@zeiss.com",
    "download_url": "https://files.pythonhosted.org/packages/47/7a/068e2f755f116ac109f2943fc707bf13aded9ce3bccd6191c65019af1ea0/cztile-0.1.2.tar.gz",
    "platform": null,
    "description": "# cztile - Python package to simplify the process of tiling arrays\r\n\r\nThis project provides simple-to-use tiling functionality for arrays. It is not linked directly to the CZI file format, but can be of use to process such images in an efficient and **tile-wise** manner, which is especially important when dealing with larger images.  \r\n\r\n## Samples\r\nThe basic usage can be inferred from this sample notebook:  \r\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/zeiss-microscopy/OAD/blob/master/jupyter_notebooks/cztile/cztile_0_0_2.ipynb)\r\n\r\n## System setup\r\nThe current version of this toolbox only requires a fresh Python 3.x installation. \r\nBeing a pure Python wheel, it was tested with Python 3.9 on Windows.\r\n\r\n## Supported Tiling Strategies\r\n\r\nThis package features the following tiling strategies:  \r\n\r\n### AlmostEqualBorderFixedTotalAreaStrategy2D\r\n\r\nThis covers a total area with a minimal number of tiles of constant total area such that:\r\n- the image area is completely covered by tiles and is filled up with as few tiles as possible\r\n- the overlap/border between tiles is as small as possible, but it is ensured that at least a minimum border size is used\r\n- all interior tiles have the same size\r\n- a possible excess border is split among tiles and can lead to slightly different tile and border sizes at the edge  \r\n- all interior tiles have at least a minimum border width/height on all sides  \r\n- the edge tiles have zero border at the edge and at least the minimum border width on their inner sides.  \r\n- The sizes of all non-zero borders differ at most by one pixel.  \r\n\r\n![cztile - AlmostEqualBorderFixedTotalAreaStrategy2D](https://raw.githubusercontent.com/zeiss-microscopy/OAD/master/jupyter_notebooks/cztile/cztile_algo.png)\r\n\r\nThe core functionality is of course also available for 1D.  \r\n\r\nThe __AlmostEqualBorderFixedTotalAreaStrategy2D__ is based on the following algorithm:  \r\n\r\n#### Inputs\r\n\r\nImage width: ![equation](https://latex.codecogs.com/svg.image?W)  \r\nMinimum interior border width (left or right): ![equation](https://latex.codecogs.com/svg.image?%5Cdelta)  \r\nFixed total tile width: ![equation](https://latex.codecogs.com/svg.image?w)  \r\n\r\n#### Calculation of tile positions and borders\r\n\r\n**Case 1:** ![equation](https://latex.codecogs.com/svg.image?W%3Cw)  \r\nThere is no solution. Fail!  \r\n\r\n**Case 2:** ![equation](https://latex.codecogs.com/svg.image?W=w)  \r\nUse a single tile with no borders.  \r\n\r\n**Case 3:** ![equation](https://latex.codecogs.com/svg.image?W%3Ew)  \r\nMaximum inner tile width of edge tiles: ![equation](https://latex.codecogs.com/svg.image?%5Chat%7B%5Comega%7D=w-%5Cdelta)  \r\nMaximum inner tile width of interior tiles: ![equation](https://latex.codecogs.com/svg.image?%5Chat%7Bw%7D=w-2%5Cdelta)  \r\nTotal interior tile width: ![equation](https://latex.codecogs.com/svg.image?%5COmega=%5Cmax%5C%7B%5C0,W-2%5C,%5Chat%7B%5Comega%7D%5C%7D)  \r\nNumber of tiles: ![equation](https://latex.codecogs.com/svg.image?N=%5Cleft%5Clceil%7B%5COmega/%5Chat%7Bw%7D%7D%5Cright%5Crceil&plus;2)  \r\nExcess border: ![equation](https://latex.codecogs.com/svg.image?E=2%5Chat%7B%5Comega%7D&plus;(N-2)%5Chat%7Bw%7D-W)  \r\nTotal number of non-zero left and right borders: ![equation](https://latex.codecogs.com/svg.image?%5Cnu=2(N-1))  \r\nFractional excess border: ![equation](https://latex.codecogs.com/svg.image?e=E/%5Cnu)  \r\nThe first non-zero border has index ![equation](https://latex.codecogs.com/svg.image?j=1), the last has index ![equation](https://latex.codecogs.com/svg.image?j=%5Cnu). Tile ![equation](https://latex.codecogs.com/svg.image?i) is surrounded by the borders with index ![equation](https://latex.codecogs.com/svg.image?2i) and ![equation](https://latex.codecogs.com/svg.image?2i&plus;1).  \r\nCumulative excess border for all borders up to border ![equation](https://latex.codecogs.com/svg.image?j): ![equation](https://latex.codecogs.com/svg.image?E_j=%5Cleft%5Clfloor%7Bje%7D%5Cright%5Crfloor) for ![equation](https://latex.codecogs.com/svg.image?j=0,...,%5Cnu)  \r\nCumulative border for all borders up to border ![equation](https://latex.codecogs.com/svg.image?j): ![equation](https://latex.codecogs.com/svg.image?%5CDelta_j=E_j&plus;j%5Cdelta) for ![equation](https://latex.codecogs.com/svg.image?j=0,...,%5Cnu)  \r\nTile boundaries: ![equation](https://latex.codecogs.com/svg.image?x_i=%5Cbegin%7Bcases%7D0%7Ci=0%5C%5Ci%5C,w-%5CDelta_%7B2i-1%7D%7Ci=1,...,N-1%5C%5CW%7Ci=N%5Cend%7Bcases%7D)  \r\nTile ![equation](https://latex.codecogs.com/svg.image?i) for ![equation](https://latex.codecogs.com/svg.image?i=0,...,N-1):  \r\n- Left-most pixel of inner tile: ![equation](https://latex.codecogs.com/svg.image?L_i=x_i)  \r\n- Right-most pixel of inner tile: ![equation](https://latex.codecogs.com/svg.image?R_i=x_%7Bi&plus;1%7D-1)  \r\n- Inner tile width: ![equation](https://latex.codecogs.com/svg.image?w_i=x_%7Bi&plus;1%7D-x_i)  \r\n- Total border width: ![equation](https://latex.codecogs.com/svg.image?b_i=w-w_i)  \r\n- Left border width: ![equation](https://latex.codecogs.com/svg.image?%5Clambda_i=%5Cbegin%7Bcases%7D0%7Ci=0%5C%5C%5CDelta_%7B2i%7D-%5CDelta_%7B2i-1%7D%7Ci=1,...,N-2%5C%5Cb_i%7Ci=N-1%5Cend%7Bcases%7D)  \r\n- Right border width: ![equation](https://latex.codecogs.com/svg.image?%5Crho_i=b_i-%5Clambda_i)  \r\n- Left-most border pixel: ![equation](https://latex.codecogs.com/svg.image?%5Cl_i=L_i-%5Clambda_i)  \r\n- Right-most-border pixel: ![equation](https://latex.codecogs.com/svg.image?r_i=R_i&plus;%5Crho_i)\r\n\r\n## Disclaimer\r\n\r\nThe libary and the notebook are free to use for everybody. Carl Zeiss Microscopy GmbH undertakes no warranty concerning the use of those tools. Use them at your own risk.\r\n\r\n**By using any of those examples you agree to this disclaimer.**\r\n\r\nVersion: 2022.04.06\r\n\r\nCopyright (c) 2022 Carl Zeiss AG, Germany. All Rights Reserved.  \r\n\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A set of tiling utilities",
    "version": "0.1.2",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "560e8d6f2a6f67130bf36a49d3bfb230ef0aa5cf07d1ed9bff143f95f03a71ee",
                "md5": "91374b8c1ff5a7a6e021fb69a9f8bf53",
                "sha256": "043c31d42079cd5ee389647754c28520f70b938a464bece234116e257198034b"
            },
            "downloads": -1,
            "filename": "cztile-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "91374b8c1ff5a7a6e021fb69a9f8bf53",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">3.6,<3.12",
            "size": 12359,
            "upload_time": "2023-06-29T16:20:31",
            "upload_time_iso_8601": "2023-06-29T16:20:31.593909Z",
            "url": "https://files.pythonhosted.org/packages/56/0e/8d6f2a6f67130bf36a49d3bfb230ef0aa5cf07d1ed9bff143f95f03a71ee/cztile-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "477a068e2f755f116ac109f2943fc707bf13aded9ce3bccd6191c65019af1ea0",
                "md5": "4f052d209f4c5f26e844dce3d787704f",
                "sha256": "3e42c4a93fd7b2df985b42e66dc3c585b3ebd9c1167e9f7e7d5c34c57697b929"
            },
            "downloads": -1,
            "filename": "cztile-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "4f052d209f4c5f26e844dce3d787704f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">3.6,<3.12",
            "size": 11696,
            "upload_time": "2023-06-29T16:20:33",
            "upload_time_iso_8601": "2023-06-29T16:20:33.014688Z",
            "url": "https://files.pythonhosted.org/packages/47/7a/068e2f755f116ac109f2943fc707bf13aded9ce3bccd6191c65019af1ea0/cztile-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-29 16:20:33",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cztile"
}
        
Elapsed time: 0.09214s