reissvd-imgcompress


Namereissvd-imgcompress JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryImage compression using REIS-SVD with evaluation metrics like MSE, PSNR, and SSIM.
upload_time2024-10-20 01:33:32
maintainerNone
docs_urlNone
authorKatie Wen-Ling Kuo
requires_python>=3.6
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # reissvd_imgcompress

A Python package for image compression using the **REIS-SVD** algorithm. This package helps in reducing the size of images while preserving quality, and also provides various metrics for evaluating compression quality, including **MSE**, **PSNR**, and **SSIM**.

## Update
- Remove the limitation on k: The code allows k to exceed the total number of singular values and sets k to the maximum available value if necessary to avoid errors.
- Improve the precision of the Sylvester equation: Increase `max_iter` to **50** iterations and reduce `tol` to **1e-6**, which allows for a more accurate solution of the equation.

## Features
- Compress grayscale images using REIS-SVD.
- Compute compression metrics: 
  - Compression Ratio (CR) 
  - Mean Squared Error (MSE)
  - Peak Signal-to-Noise Ratio (PSNR)
  - Structural Similarity Index (SSIM)
- Visualize compressed images with different singular values.

## Installation

To install the package, first clone the repository or download the code, then navigate to the package directory and run:

```bash
pip install .
```

## Usage
```python
from reissvd_imgcompress import (
    rgb2gray, reis_svd, compute_metrics, plot_compressed_images
)
import numpy as np
from PIL import Image

# Load an image and convert it to grayscale
image = np.array(Image.open('sample_image.png'))
gray_image = rgb2gray(image) # If grayscale conversion is not needed, you can skip this step.


# Define singular value counts for testing
k_values = [1, 2, 5, 10, 20, 50, 100, 200, 500]

# Iterate over k_values, compress images, and compute metrics
for k in k_values:
    compressed = reis_svd(gray_image, k)
    CR, mse, psnr, ssim_index = compute_metrics(gray_image, compressed, k)
    print(f"k={k}: CR={CR:.2f}, MSE={mse:.2f}, PSNR={psnr:.2f} dB, SSIM={ssim_index:.4f}")

# Plot compressed images for visual comparison
plot_compressed_images(gray_image, k_values)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "reissvd-imgcompress",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Katie Wen-Ling Kuo",
    "author_email": "katie20030705@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/eb/d1/2de8b5443d1cd54c5e7699831f2de52f845af5f06814ba6aeaf8c66fbf31/reissvd_imgcompress-0.2.0.tar.gz",
    "platform": null,
    "description": "# reissvd_imgcompress\r\n\r\nA Python package for image compression using the **REIS-SVD** algorithm. This package helps in reducing the size of images while preserving quality, and also provides various metrics for evaluating compression quality, including **MSE**, **PSNR**, and **SSIM**.\r\n\r\n## Update\r\n- Remove the limitation on k: The code allows k to exceed the total number of singular values and sets k to the maximum available value if necessary to avoid errors.\r\n- Improve the precision of the Sylvester equation: Increase `max_iter` to **50** iterations and reduce `tol` to **1e-6**, which allows for a more accurate solution of the equation.\r\n\r\n## Features\r\n- Compress grayscale images using REIS-SVD.\r\n- Compute compression metrics: \r\n  - Compression Ratio (CR) \r\n  - Mean Squared Error (MSE)\r\n  - Peak Signal-to-Noise Ratio (PSNR)\r\n  - Structural Similarity Index (SSIM)\r\n- Visualize compressed images with different singular values.\r\n\r\n## Installation\r\n\r\nTo install the package, first clone the repository or download the code, then navigate to the package directory and run:\r\n\r\n```bash\r\npip install .\r\n```\r\n\r\n## Usage\r\n```python\r\nfrom reissvd_imgcompress import (\r\n    rgb2gray, reis_svd, compute_metrics, plot_compressed_images\r\n)\r\nimport numpy as np\r\nfrom PIL import Image\r\n\r\n# Load an image and convert it to grayscale\r\nimage = np.array(Image.open('sample_image.png'))\r\ngray_image = rgb2gray(image) # If grayscale conversion is not needed, you can skip this step.\r\n\r\n\r\n# Define singular value counts for testing\r\nk_values = [1, 2, 5, 10, 20, 50, 100, 200, 500]\r\n\r\n# Iterate over k_values, compress images, and compute metrics\r\nfor k in k_values:\r\n    compressed = reis_svd(gray_image, k)\r\n    CR, mse, psnr, ssim_index = compute_metrics(gray_image, compressed, k)\r\n    print(f\"k={k}: CR={CR:.2f}, MSE={mse:.2f}, PSNR={psnr:.2f} dB, SSIM={ssim_index:.4f}\")\r\n\r\n# Plot compressed images for visual comparison\r\nplot_compressed_images(gray_image, k_values)\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Image compression using REIS-SVD with evaluation metrics like MSE, PSNR, and SSIM.",
    "version": "0.2.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9fb5d6479541ced12ea0182a00a211cfbafaf0d5865e745dcf80b183d8143691",
                "md5": "8619ec4fe804c9077f39b5e62df51e9d",
                "sha256": "1941990c085e7e47071dfae7ebe49ca5c2a9b852f41c79cd31cfd0794c084ae2"
            },
            "downloads": -1,
            "filename": "reissvd_imgcompress-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8619ec4fe804c9077f39b5e62df51e9d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5133,
            "upload_time": "2024-10-20T01:33:30",
            "upload_time_iso_8601": "2024-10-20T01:33:30.649537Z",
            "url": "https://files.pythonhosted.org/packages/9f/b5/d6479541ced12ea0182a00a211cfbafaf0d5865e745dcf80b183d8143691/reissvd_imgcompress-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ebd12de8b5443d1cd54c5e7699831f2de52f845af5f06814ba6aeaf8c66fbf31",
                "md5": "4d08d70b7820e49bf38653ec5eee47ee",
                "sha256": "1b9ffdf47b099a3866a960c16a4697e5a6738232aa778142b35604ce954022ce"
            },
            "downloads": -1,
            "filename": "reissvd_imgcompress-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4d08d70b7820e49bf38653ec5eee47ee",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 4597,
            "upload_time": "2024-10-20T01:33:32",
            "upload_time_iso_8601": "2024-10-20T01:33:32.314060Z",
            "url": "https://files.pythonhosted.org/packages/eb/d1/2de8b5443d1cd54c5e7699831f2de52f845af5f06814ba6aeaf8c66fbf31/reissvd_imgcompress-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-20 01:33:32",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "reissvd-imgcompress"
}
        
Elapsed time: 0.31761s