Skip to main content

A Try at Better Understanding Space.

Project description

Simple-Space

A Try at Better Understanding Space

Table of Contents

Installation

To use all these utilities, just following Python package should be installed:

pip install simple-space

Structure

simple-space/
│
├── SimpleS/
│   ├── __init__.py
│   ├── utils.py
│   └── Points/
│       ├── __init__.py
│       ├── dimentions.py
│   └── ImageRelated/
│       ├── __init__.py
│       ├── enhancements.py
│       └── basics.py
├── README.md
├── LICENSE
└── pyproject.toml

Submodules

  1. Points

    • dim3.py: Contains functions for 3D point data processing and visualization.
    • dim2.py: Contains some simple and basic functions for 2D point data processing and visualization.
  2. ImageRelated

    • enhancements.py: Provides functions for image enhancement, including erosion and dilation.
    • basics.py: Contains basic image processing utilities like edge detection and color inversion.

dim3

The dim3 script offers tools for visualizing and processing 3D point data in Python, using libraries such as numpy, matplotlib, and scipy.

Features

  • Rotate 3D Points: Rotate points around a specified axis by a given angle in degrees.
  • Plot 3D Points/Mesh: Visualize 3D points or a mesh, with customizable visual attributes.
  • Create Grayscale Image from 3D Points: Project 3D points onto a 2D plane using the z-coordinate for intensity.
  • Fill Points in Binary Image: Use morphological dilation to fill gaps in binary images.

Usage

Initializing the Class

from SimpleS.Points import dim3
# But I recommend You Simply Use this one:

from SimpleS.Points.dim3 import *

# This one Lets you use all the functions inside dim3 script without any initialize word;
# FOR EXAMPLE:

dim3.rotate_points()

# WOULD BE JUST:

rotate_points()

If you encounter any trouble determining the specifics of an import, such as which functions it includes, simply use the dir() function:

from SimpleS.Points import dim3

dir(dim3)

This will show you the names of all functions inside the dim3 script.

After that, we will return to our simpler method:

from SimpleS.Points.dim3 import *

Rotating 3D Points

rotated_points = rotate_points(points, 45, 'z')

Plotting 3D Points or Mesh

plot_points(vertices, faces)

Creating a Grayscale Image from 3D Points

image = create_bool_image_from_points(points)

Filling Points in a Binary Image

filled_image = fill_points(binary_image)

For more detailed information on each method, please refer to the inline documentation within the class methods.

ImageRelated Scripts : enhancements.py

Introduction

This Python script, titled "enhancements", is an enhanced version of the original image processing examples provided by OpenCV. It includes functionalities for applying erosion and dilatation transformations to images. This script can be used for educational purposes or integrated into larger image processing projects.

Features

  • Erosion and Dilatation: Apply morphological transformations to enhance or reduce features in images.
  • Flexible File Handling: Load images from file paths or directly from images in memory.
  • Visualization: Compare original and transformed images side by side.
  • Save Results: Optionally save the resulting images with a timestamp and transformation details.

Prerequisites

Before running the script, ensure you have Python installed on your system. This script is compatible with Python 3.6 or higher.

Usage

To use this script, you need to create an instance of the ErosAndDilat class with either a path to an image file or an image object. Here's a quick example on how to use the class:

from SimpleS.enhancements import ErosAndDilat

# Initialize with an image path
image_processor = ErosAndDilat('path/to/your/image.jpg')

# Perform erosion and dilatation, display results, and save them
image_processor.main(eros=True, dilate=True, show=True, save=True)

Parameters

  • eros: Enable erosion (default: True)
  • dilate: Enable dilatation (default: True)
  • show: Display the images using matplotlib (default: True)
  • save: Save the images to disk (default: False)
  • save_path: Directory to save the images (default: 'results')
  • file_name: Base file name for saved images (default: None)

Acknowledgements

Special thanks to the OpenCV community for providing the base examples which were enhanced in this project. Also, check out the original script and documentation at OpenCV GitHub.

ImageRelated Scripts : basics.py

This script, titled "basics", provides a collection of image processing utilities written in Python. These functions can be used for tasks such as edge detection, image inversion, and binary image creation.

Functions

invert_image_color

  • Inverts the colors of an image. Can optionally save the result to a file.

  • Parameters:

    • image: Path to the image file or a numpy array.
    • save (optional): Whether to save the result.
    • save_path (optional): Directory to save the result.
    • file_name (optional): Name of the saved file.
  • Example:

from SimpleS import basics

# Or :

from SimpleS.basics import invert_image_color

#Or:

from SimpleS.basics import * # Access to all

show_image

  • Displays an image using matplotlib.

  • Parameters:

    • image: Path to the image file or a numpy array.
    • title (optional): Title of the image window.
    • c_map (optional): Color map for displaying the image.
    • interpolation (optional): Interpolation method for - - - displaying the image.
    • save (optional): Whether to save the result.
    • save_path (optional): Directory to save the result.
    • file_name (optional): Name of the saved file.
  • Example:

from SimpleS.basics import *

show_image('path_to_image.png', title="Example Image", save=True, save_path='./', file_name='example_image.png')

fill_shape

  • Fills an area of a shape in an image based on the points defining the edges of the shape.

  • Parameters:

    • image: The image where the shape is to be filled.
    • points: A list of (x, y) tuples defining the vertices of the shape.
    • color: A tuple defining the color to fill the shape.
  • Example:

from SimpleS.basics import *

filled_image = fill_shape(image, points, color=(255, 0, 0))

force_image_to_GRAYSCALE

  • Converts a color image to grayscale.

  • Parameters:

    • image: The color image.
  • Example:

from SimpleS.basics import *

grayscale_image = force_image_to_GRAYSCALE(color_image)

read_image_in_grayscale

  • Reads an image in grayscale mode and optionally converts it to binary.

  • Parameters:

    • image_path: Path to the image file.
    • thrhold (optional): Threshold value for binarization.
    • type (optional): Thresholding type.
    • also_make_it_binary (optional): Whether to convert to binary.
    • binary_image_color (optional): Color for binary conversion.
  • Example:

from SimpleS.basics import *

binary_image = read_image_in_grayscale('path_to_image.png', thrhold=127, type='THRESH_BINARY', also_make_it_binary=True)

simple_binary_image_creator

  • Creates a binary image from a list of points.

  • Parameters:

    +points: List of tuples (x, y) representing the coordinates of points.

    • image_size (optional): Tuple (width, height) for the output image size.
    • size_of_edge_points (optional): Size of the points to enlarge.
    • iterations (optional): Number of iterations for dilation.
    • enlarge_points (optional): Whether to enlarge points.
    • smoothing (optional): Whether to apply Gaussian blur.
  • Example:

from SimpleS.basics import *

binary_image = simple_binary_image_creator(points, image_size=(100, 100))

advance_binary_image_creator

  • Creates an advanced binary image from a list of points.

  • Parameters:

    • points: List of tuples (x, y) representing the coordinates of points.
    • shape_size (optional): Size of the shape.

detect_edges

  • Detects edges in an image and optionally displays or saves the result.

  • Parameters:

    • image: Path to the image file or a numpy array.
    • n1 (optional): Lower threshold for the Canny edge detector.
    • n2 (optional): Upper threshold for the Canny edge detector.
    • show_edges (optional): Whether to display the detected edges.
    • show_contours (optional): Whether to display the detected contours.
    • title_for_detected_edges (optional): Title for the detected edges plot.
    • title_for_detected_contours (optional): Title for the detected contours plot.
    • return_edges (optional): Whether to return the detected edges.
    • return_contours (optional): Whether to return the detected contours.
    • range_color_start (optional): Start of the range for random colors.
    • range_color_end (optional): End of the range for random colors.
    • save (optional): Whether to save the result.
    • save_path (optional): Directory to save the result.
    • file_name (optional): Name of the saved file.

License

This project is open-sourced under the MIT License. See the LICENSE file for more details.

Mistakes and Corrections

To err is human, and nobody likes a perfect person! If you come across any mistakes or if you have questions, feel free to raise an issue or submit a pull request. Your contributions to improving the content are highly appreciated.

Contact

Any Time: cloner174.org@gmail.com

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

simple_space-0.6.0.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

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

Simple_Space-0.6.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file simple_space-0.6.0.tar.gz.

File metadata

  • Download URL: simple_space-0.6.0.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for simple_space-0.6.0.tar.gz
Algorithm Hash digest
SHA256 cd3e7c4b81d0a9efa54ed6ab4d70ce168f7a1f7eb61e26e2259ad4310c324dca
MD5 9af48e1e346497557d05fd84b1a667d7
BLAKE2b-256 e30e45c3b0f373b88101ceeeb09e82ed408d97bb7bc13807484190401e571634

See more details on using hashes here.

File details

Details for the file Simple_Space-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: Simple_Space-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for Simple_Space-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e24ee1ec922152a551ad438f86ddd298b4aa6f2cc218ef125821c74d665560c
MD5 a72f45475b0cdf3c82867b8db8d5b1de
BLAKE2b-256 305ba540acf0d7ede28a1df670be8cf4ed775de4a37002e60d3575316ad7856b

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