Skip to main content

Applying some image kernel(s) on a grayscale or RGB color-scale image

Project description

Pyimkernel

License: MIT GitHub repo size GitHub forks GitHub User's stars GitHub pull requests GitHub issues

With this package, You can apply various image kernels such as Blur, Sobel, Scharr and so forth (The comprehensive list of image kernels is mentioned below) on a grayscale or RGB color-scale image, and then show them. These effects and enhancements in digital images can be achieved using the "ApplyKernels" class, allowing for a wide range of transformations.

Image kernels

Image kernels are listed below:

  • blur
  • bottom sobel
  • emboss
  • identity
  • left sobel
  • outline
  • right sobel
  • sharpen
  • top sobel
  • horizontal edge
  • vertical edge
  • box blur
  • laplacian
  • prewitt horizontal edge
  • prewitt vertical edge
  • high-pass filter
  • unsharp masking
  • dilate
  • soften
  • scharr horizontal edge
  • scharr vertical edge
  • motion blur

Installation

pip install pyimkernel

Usage

from pyimkernel import ApplyKernels
import mnist # pip install mnist
import cv2
import os

# Load data
X_train, X_test, y_train, y_test = mnist.train_images(), mnist.test_images(), mnist.train_labels(), mnist.test_labels()

# Create an instance
imkernel = ApplyKernels(random_seed=0)

# Grayscale
# Show image 9 
imkernel.imshow(X_train[19], cmap=plt.cm.gray)

# Apply blur kernel on a grayscale image 9
filtered_image = imkernel.apply_filter_on_gray_img(X_train[19], kernel_name='blur')

# Show the filtered image 9
imkernel.imshow(image=filtered_image, cmap='gray')

# the Color-Scale image
# Read the flower image
image1 = cv2.imread(os.path.join('Images', '1.jpg'))

# Show the flower image
# Convert a color-scale image to a grayscale one and then visualize it
imkernel.imshow(cv2.cvtColor(image1, cv2.COLOR_BGRA2GRAY), cmap='gray', figsize=(6, 6))

# Show the filtered flower image
blurred_image = imkernel.apply_filter_on_color_img(image1, kernel_name='box blur', with_resize=True, dsize=(100, 100))
imkernel.imshow(image=blurred_image)

sharpened_image = imkernel.apply_filter_on_color_img(image1, kernel_name='sharpen', with_resize=True)
imkernel.imshow(image=sharpened_image, figsize=(6, 6))

imkernel.imshow(image=imkernel.apply_filter_on_color_img(sharpened_image, kernel_name='soften'),
                figsize=(6, 6))

The Grayscale Output

Before Applying the Blur Kernel on a grayscale image 9



After Applying the Blur Kernel on a grayscale image 9

The Color Scale Output

Before Applying the Box Blur Kernel on a color-scale flower image



After Applying the Box Blur Kernel on a color-scale flower image and assigning True to the with_resize parameter and (100, 100) to the dsize parameter



After Applying the Sharpen Kernel on a color-scale flower image and assigning True to the with_resize parameter and 'auto' to the dsize parameter



After Applying the Soften Kernel on a color-scale image, which was filtered using the Sharpen Blur Kernel before, and assigning False to the with_resize parameter

Package Status

All Tests Passed.

Maintainer Contact

Links

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

pyimkernel-0.8.3.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

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

pyimkernel-0.8.3-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file pyimkernel-0.8.3.tar.gz.

File metadata

  • Download URL: pyimkernel-0.8.3.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for pyimkernel-0.8.3.tar.gz
Algorithm Hash digest
SHA256 166d1ad16ebbdd30463f9a07cd26076b76134c20cf53a8c2cbaaad74e9801e1e
MD5 f0fe71abd4dd5efaaba4c9cf513f8896
BLAKE2b-256 e362830677886104b1b52b95e305bfde914ab742f21a8c78f5b7457cb5d749a6

See more details on using hashes here.

File details

Details for the file pyimkernel-0.8.3-py3-none-any.whl.

File metadata

  • Download URL: pyimkernel-0.8.3-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for pyimkernel-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 eb1bb6f306bb0de9a5223c5c1ac84181fb3164e5adda31d42da3ce02ebebe7db
MD5 e5110f14c7b545cd8f69c44a829fa3a2
BLAKE2b-256 229c548b3d385c4fdf395798d6f6d753b4ea37fc0e82fd7e66f3811ccaf86476

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