Skip to main content

Image kernel.

Project description

imgkernel

An image kernel is a small matrix used to apply effects like the ones you might find in Photoshop or Gimp, such as blurring, sharpening, outlining or embossing. They're also used in machine learning for 'feature extraction', a technique for determining the most important portions of an image.

安装

pip install imgkernel

使用

import imgkernel
import matplotlib.pyplot as plt
%matplotlib inline

def show2imgs(img1, img2, title=None):
    fig = plt.figure(figsize=(10, 5))

    if title is not None:
        fig.suptitle(title)

    plt.subplot(121)
    plt.axis('off')
    plt.imshow(img1)

    plt.subplot(122)
    plt.axis('off')
    plt.imshow(img2)

    plt.show()

imgpath = 'image.jpeg'

1. 鲜明

show2imgs(*imgkernel.identity(imgpath, gray=False, iden=1.6), 'imgkernel.identity()')

2. 模糊

show2imgs(*imgkernel.blur(imgpath, gray=False), 'imgkernel.blur()')

3. 锐利

show2imgs(*imgkernel.sharpen(imgpath, gray=False, inner=1.7,  edge=-0.08), 'imgkernel.sharpen()')

4. 浮雕

show2imgs(*imgkernel.emboss(imgpath, gray=False), 'imgkernel.emboss()')

5. 轮廓线

show2imgs(*imgkernel.outline(imgpath, gray=False, inner=8.9, outer=-1.29), 'imgkernel.outline()')

6. 边沿检测

6.1 上边沿

show2imgs(*imgkernel.sobel(imgpath, gray=False, direction='top', base=0.03), 'imgkernel.sobel(top)')

6.2 下边沿

show2imgs(*imgkernel.sobel(imgpath, gray=False, direction='bottom', base=0.03), 'imgkernel.sobel(bottom)')

6.3 左边沿

show2imgs(*imgkernel.sobel(imgpath, gray=False, direction='left', base=0.03), 'imgkernel.sobel(left)')

6.4 右边沿

show2imgs(*imgkernel.sobel(imgpath, gray=False, direction='right', base=0.03), 'imgkernel.sobel(right)')

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

imgkerneliu-0.0.2.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

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

imgkerneliu-0.0.2-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file imgkerneliu-0.0.2.tar.gz.

File metadata

  • Download URL: imgkerneliu-0.0.2.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for imgkerneliu-0.0.2.tar.gz
Algorithm Hash digest
SHA256 94a1560ccedbfcb2bb0d7f6cc0bb1092db42e223c124ad36c0efe9c5f9d9f262
MD5 ad552733e20dd44eefb2dea141b17854
BLAKE2b-256 2e5d11686ebd0a4b86b73df24008a05dc442cec1055e2e5373faf9c15a4b459a

See more details on using hashes here.

File details

Details for the file imgkerneliu-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: imgkerneliu-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for imgkerneliu-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a44103b38f8553abb207bf33c6e234a63368da3a4ffc67869b3f807558e61aa8
MD5 ef4e8a6381144eed3b05d42cca252486
BLAKE2b-256 da9330ad7becd3b59abbb58d8d9c7bcc37a6c353cd601cfa306396520ef57a7f

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