Skip to main content

Using matplotlib_imshow for images read by cv2

Project description

cv2_plt_imshow

Using matplotlib_imshow for images read by cv2

Introduction

One of the major issue faced while using cv2, especially when you are using jupyter-notebooks, is to perform cv2.imshow the kernel breaks. Apart from this, most of the users are comfortable using matplotlib for display, specially its display in notebook using %matplotlib inline magic.

This package provides two of the main function, converting the image to a format more suitable in matplotlib, and plotting the image using matplotlib in the notebooks.

Table of contents

Setup

pip install cv2_plt_imshow

Usage

import cv2
import matplotlib.pyplot as plt
from cv2_plt_imshow import cv2_plt_imshow, plt_format

# read image
im1 = cv2.imread('./images/potrait.jpg')

# use cv2_plt_imshow function to plot any image that was read by cv2, but is plotted using pyplot
cv2_plt_imshow(im1)

# Convert the image to be suitable for pyplot format and later use it for plotting using pyplot functions
im2 = cv2.imread('./images/landscape.jpg')
fig, axs = plt.subplots(2 , figsize=(20,20))
fig.suptitle('Vertically stacked subplots')
axs[0].imshow(plt_format(im1))
axs[1].imshow(plt_format(im2))

Dependencies

Contact

Project details


Download files

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

Files for cv2-plt-imshow, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size cv2_plt_imshow-0.0.1-py3-none-any.whl (3.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size cv2_plt_imshow-0.0.1.tar.gz (2.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page