imageruler


Nameimageruler JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryMeasure minimum sollid/void lengthscales in binary images.
upload_time2024-03-30 02:11:21
maintainerIan A. D. Williamson, Ardavan Oskooi
docs_urlNone
authorIan A. D. Williamson, Ardavan Oskooi
requires_python>=3.7
licenseNone
keywords topology optimization length scale
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Build Status](https://github.com/NanoComp/imageruler/workflows/CI/badge.svg)](https://github.com/NanoComp/imageruler/actions)
`v0.2.0`

Imageruler is a free Python program to compute the minimum length scale of binary images which are typically designs produced by topology optimization. The algorithm is described in Section 2 of [J. Optical Society of America B, Vol. 42, pp. A161-A176 (2024)](https://opg.optica.org/josab/abstract.cfm?uri=josab-41-2-A161) and is based on morphological transformations implemented using [OpenCV](https://github.com/opencv/opencv). Imageruler also supports 1d binary images.

## Algorithm for Determining Minimum Length Scale

The procedure used by Imageruler for determining the minimum length scale of the solid regions in a binary image involves four steps:

1. Binarize the 2d array $\rho$ representing the image such that each of its elements is a Boolean value for solid (true) and void (false).
2. For a circular-ball [kernel](https://en.wikipedia.org/wiki/Kernel_(image_processing)) with diameter $d$, compute the morphological opening $\mathcal{O}_d(\rho)$ and obtain its difference with the original array via $\mathcal{O}_d(\rho) \oplus \rho$, where $\oplus$ denotes the exclusive-or operator.
3. Check whether $\mathcal{O}_d(\rho) \oplus \rho$ contains a solid pixel within the interior solid regions of $\rho$. If no, $d$ is less than the minimum length scale of solid regions. If yes, $d$ is equal or greater than the minimum length scale of the solid regions. The interior of the solid regions of $\rho$ is obtained by morphological erosion using a "cross" kernel of size $3\times3$ pixels.
4. Use a [binary search](https://en.wikipedia.org/wiki/Binary_search_algorithm) and repeat Steps 2 and 3 to find the smallest $d$ for which the check in Step 3 evaluates to true. This value of $d$ is considered to be the minimum length scale of the solid regions.

To estimate the minimum length scale of the void regions, the binary image is inverted after the binarization of Step 1: $\rho \rightarrow \neg \rho$ such that the solid and void regions are interchanged. The remaining Steps 2-4 are unchanged. This approach is equivalent to computing $\mathcal{C}_d(\rho) \oplus \rho$ in Step 2 and then checking its overlap with the interior pixels of the void regions of $\rho$ in Step 3. $\mathcal{C}_d(\rho)$ denotes morphological closing.

The minimum length scale of $\rho$ is the smaller of the minimum length scales of the solid and void regions. Rather than determining these separately, it is possible to compute their minimum simultaneously using $\mathcal{O}_d(\rho) \oplus \mathcal{C}_d(\rho)$ in Step 2 and then to check its overlap with the union of the interior pixels of the solid and void regions of $\rho$ in Step 3. This approach involves a single binary search rather than two.

For a 1d binary image, the algorithm simply finds the minimum length among all solid or void segments.

## Note on Accuracy

The accuracy of the minimum length scale computed by Imageruler is limited by the finite resolution of the input image. A fundamental feature is that length scales smaller than a single pixel cannot be measured. Also, in certain situations, length scales of a few pixels may be indistinguishable from discretization artifacts such as the "staircasing" of curved surfaces. As an example, a sharp 90° corner corresponds to a length scale (radius of curvature) of *zero* at infinite resolution. However, at a finite resolution, a sharp corner is indistinguishable from one that is rounded with a radius of curvature of a few pixels. Imageruler will therefore return a length scale proportional to the pixel size rather than zero. In general, the measured length scale should be viewed as having an "error bar" on the few-pixel level.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "imageruler",
    "maintainer": "Ian A. D. Williamson, Ardavan Oskooi",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "Wenchao Ma <mawc@mit.edu>, Martin Schubert <mfschubert@gmail.com>, \"Steven G. Johnson\" <stevenj@mit.edu>",
    "keywords": "topology, optimization, length scale",
    "author": "Ian A. D. Williamson, Ardavan Oskooi",
    "author_email": "Wenchao Ma <mawc@mit.edu>, Martin Schubert <mfschubert@gmail.com>, \"Steven G. Johnson\" <stevenj@mit.edu>",
    "download_url": "https://files.pythonhosted.org/packages/8c/86/5542f901304cca9aba3bc0a0fce549ee653360e1a207eba039936e31c5f0/imageruler-0.2.0.tar.gz",
    "platform": null,
    "description": "[![Build Status](https://github.com/NanoComp/imageruler/workflows/CI/badge.svg)](https://github.com/NanoComp/imageruler/actions)\n`v0.2.0`\n\nImageruler is a free Python program to compute the minimum length scale of binary images which are typically designs produced by topology optimization. The algorithm is described in Section 2 of [J. Optical Society of America B, Vol. 42, pp. A161-A176 (2024)](https://opg.optica.org/josab/abstract.cfm?uri=josab-41-2-A161) and is based on morphological transformations implemented using [OpenCV](https://github.com/opencv/opencv). Imageruler also supports 1d binary images.\n\n## Algorithm for Determining Minimum Length Scale\n\nThe procedure used by Imageruler for determining the minimum length scale of the solid regions in a binary image involves four steps:\n\n1. Binarize the 2d array $\\rho$ representing the image such that each of its elements is a Boolean value for solid (true) and void (false).\n2. For a circular-ball [kernel](https://en.wikipedia.org/wiki/Kernel_(image_processing)) with diameter $d$, compute the morphological opening $\\mathcal{O}_d(\\rho)$ and obtain its difference with the original array via $\\mathcal{O}_d(\\rho) \\oplus \\rho$, where $\\oplus$ denotes the exclusive-or operator.\n3. Check whether $\\mathcal{O}_d(\\rho) \\oplus \\rho$ contains a solid pixel within the interior solid regions of $\\rho$. If no, $d$ is less than the minimum length scale of solid regions. If yes, $d$ is equal or greater than the minimum length scale of the solid regions. The interior of the solid regions of $\\rho$ is obtained by morphological erosion using a \"cross\" kernel of size $3\\times3$ pixels.\n4. Use a [binary search](https://en.wikipedia.org/wiki/Binary_search_algorithm) and repeat Steps 2 and 3 to find the smallest $d$ for which the check in Step 3 evaluates to true. This value of $d$ is considered to be the minimum length scale of the solid regions.\n\nTo estimate the minimum length scale of the void regions, the binary image is inverted after the binarization of Step 1: $\\rho \\rightarrow \\neg \\rho$ such that the solid and void regions are interchanged. The remaining Steps 2-4 are unchanged. This approach is equivalent to computing $\\mathcal{C}_d(\\rho) \\oplus \\rho$ in Step 2 and then checking its overlap with the interior pixels of the void regions of $\\rho$ in Step 3. $\\mathcal{C}_d(\\rho)$ denotes morphological closing.\n\nThe minimum length scale of $\\rho$ is the smaller of the minimum length scales of the solid and void regions. Rather than determining these separately, it is possible to compute their minimum simultaneously using $\\mathcal{O}_d(\\rho) \\oplus \\mathcal{C}_d(\\rho)$ in Step 2 and then to check its overlap with the union of the interior pixels of the solid and void regions of $\\rho$ in Step 3. This approach involves a single binary search rather than two.\n\nFor a 1d binary image, the algorithm simply finds the minimum length among all solid or void segments.\n\n## Note on Accuracy\n\nThe accuracy of the minimum length scale computed by Imageruler is limited by the finite resolution of the input image. A fundamental feature is that length scales smaller than a single pixel cannot be measured. Also, in certain situations, length scales of a few pixels may be indistinguishable from discretization artifacts such as the \"staircasing\" of curved surfaces. As an example, a sharp 90\u00b0 corner corresponds to a length scale (radius of curvature) of *zero* at infinite resolution. However, at a finite resolution, a sharp corner is indistinguishable from one that is rounded with a radius of curvature of a few pixels. Imageruler will therefore return a length scale proportional to the pixel size rather than zero. In general, the measured length scale should be viewed as having an \"error bar\" on the few-pixel level.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Measure minimum sollid/void lengthscales in binary images.",
    "version": "0.2.0",
    "project_urls": null,
    "split_keywords": [
        "topology",
        " optimization",
        " length scale"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6411fd3cf89382bd41c2ac0d0d2ed97d965dfa23eacb66297648e97afbcb05cc",
                "md5": "e1baa1da59cfc355e65fb3341d64a748",
                "sha256": "60ed7bdabb4c1963241b2b6059ecab6fdc6ec0ed2c7458aba6a8435b9e44e531"
            },
            "downloads": -1,
            "filename": "imageruler-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e1baa1da59cfc355e65fb3341d64a748",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 11325,
            "upload_time": "2024-03-30T02:11:19",
            "upload_time_iso_8601": "2024-03-30T02:11:19.894696Z",
            "url": "https://files.pythonhosted.org/packages/64/11/fd3cf89382bd41c2ac0d0d2ed97d965dfa23eacb66297648e97afbcb05cc/imageruler-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8c865542f901304cca9aba3bc0a0fce549ee653360e1a207eba039936e31c5f0",
                "md5": "20a753ae5458552747f6dfacd99a2547",
                "sha256": "e2a5fc9ff7e1f5b65bb310c2fc3964c4446954201b066a6ae2119f2ba8ae0f00"
            },
            "downloads": -1,
            "filename": "imageruler-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "20a753ae5458552747f6dfacd99a2547",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 17275,
            "upload_time": "2024-03-30T02:11:21",
            "upload_time_iso_8601": "2024-03-30T02:11:21.942206Z",
            "url": "https://files.pythonhosted.org/packages/8c/86/5542f901304cca9aba3bc0a0fce549ee653360e1a207eba039936e31c5f0/imageruler-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-30 02:11:21",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "imageruler"
}
        
Elapsed time: 0.24998s