Skip to main content

Uma lib python que oferece uma serie de ferramentas para o processamento de imagem

Project description

pictokit

Introduction

pictokit is a Python library designed to perform image processing and transformations.
It serves as a foundation for applying different methods commonly studied in Image Processing courses, while also being flexible enough to be extended for research and development.


Installation

pictokit requires Python >= 3.10.

You can install it directly from PyPI:

pip install pictokit

Features

  • Basic image loading and visualization
  • Histogram analysis and equalization
  • Contrast expansion
  • [More features will be added and documented here in future versions]

How it Works

The library provides modular functions that can be combined to build image transformation pipelines.
It is meant to be lightweight and educational, focusing on clarity and usability.
Detailed usage examples will be provided in the official documentation.

Basic image loading and visualization

Images can be loaded directly from disk or from memory arrays and displayed using standard Python visualization tools. This provides a straightforward way to inspect input data before applying transformations.

from pictokit import Image

# Load image from file
img = Image(path="examples/image.png")

# Display the original image
print(img)

Image Display Example

Histogram analysis and equalization

Functions are available to compute and plot image histograms, giving insights into the distribution of pixel intensities.

from pictokit import Image

img = Image(path="examples/image.png")

# Plot histogram of the original image
img.histogram()

Plot Histogram Example

Contrast Expansion

Contrast enhancement can be achieved through expansion techniques, where pixel intensity values are stretched to span a wider range (0–255).
This adjustment improves the visibility of details that might otherwise be hidden in very dark or very bright regions of the image.

The transformation is defined by the following formula:

$$ f(D) = \frac{255}{H - L}(D - L) $$

Where:

  • D → the original pixel value
  • L → the lowest pixel intensity in the image (minimum gray level)
  • H → the highest pixel intensity in the image (maximum gray level)
  • f(D) → the new pixel value, rescaled to the 0–255 range
from pictokit import Image

img = Image(path="examples/image.png")

# Apply contrast expansion with low and high limits and show histogram
img.contrast_expansion(low_limit=50, high_limit=250, hist=True)

# Show original and transformed images side by side
img.compare_images()

Example result of contrast expansion:

Contrast Expansion Example

Thresholding

Thresholding is a point operation used to segment an image into regions based on intensity.
Pixels with values below a given threshold are set to 0 (black), while pixels equal to or above the threshold are set to a specified intensity value (A) (commonly 255, white).
This technique is widely used in image processing to separate foreground objects from the background.

The transformation is defined by the following formula:

$$ f(D) = A \cdot u(D - T) $$

Where:

  • D → the original pixel value
  • T → the threshold value
  • A → the intensity value assigned when the condition is satisfied (usually 255)
  • u(x) → the unit step function, which is 0 if (x < 0) and 1 if (x \geq 0)
  • f(D) → the new pixel value (either 0 or (A))
from pictokit import Image

img = Image(path="examples/image.png")

# Apply thresholding with threshold T and intensity A
img.thresholding(A=1, T=150, hist=True)

# Show original and transformed images side by side
img.compare_images()

Example result of contrast expansion:

Thresholding Example

Digital Negative

Digital negative is a point operation that inverts the intensity of every pixel in the image.
Dark areas become bright, and bright areas become dark, producing an effect similar to photographic film negatives.
This technique is commonly used for image enhancement and visualization.

The transformation is defined by the following formula:

$$ f(D) = 255 - D $$

Where:

  • D → the original pixel value
  • 255 → the maximum intensity value in 8-bit images
  • f(D) → the new pixel value (the inverted intensity)
from pictokit import Image

img = Image(path="examples/digital_negative.png")

# Apply digital negative transformation
img.digital_negative(hist=True)

# Show original and transformed images side by side
img.compare_images()

Example result of digital negative:

Digital Negative Example

Academic Motivation

This project was created in the context of Image Processing courses, to consolidate theoretical knowledge through practical implementations.
It aims to provide both a learning resource for students and a useful toolkit for developers who want to explore image transformations.


Notes

If you want to contribute, please check the CONTRIBUTING.md file.
Suggestions, bug reports, and improvements are always welcome.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pictokit-0.3.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pictokit-0.3.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file pictokit-0.3.0.tar.gz.

File metadata

  • Download URL: pictokit-0.3.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.13 Linux/6.11.0-1018-azure

File hashes

Hashes for pictokit-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ca5038e88fb4d4faa6c2d8ca5bd77cc13eae1fcb3abcfb3064942e0d0803a471
MD5 0bc6f491dc3cd19e1c11e25c05fa478b
BLAKE2b-256 a577250356163699f4cf7cb207555e7dff6e1333e80530802cf4be4ed45d5849

See more details on using hashes here.

File details

Details for the file pictokit-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pictokit-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.13 Linux/6.11.0-1018-azure

File hashes

Hashes for pictokit-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1efb434f3c07cb5e2fc86c11c3c3ded2a2ad91ef7027534672945cb98b6fb7f
MD5 e0f9cd274e17d428e6058fb47c1bb54f
BLAKE2b-256 a8139aae24bbd09351aa0891dadeaa3ec2152017196ccdc57e60e24446da8128

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page