Skip to content

musyoku/imgplot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

imgplot

imgplot is a non-blocking image viewer for Python 3.

Requirements

  • C++14 (gcc-6)
  • OpenGL 4
  • Python 3

Installation

GLFW

sudo apt install libglfw3-dev

pybind11

pip3 install pybind11 --user

imgplot

make

Basic usage

#1

import numpy as np
import imgplot

figure = imgplot.figure()

data_rect = np.array(...)
axis = imgplot.image(data_rect)
figure.add(axis, x=0, y=0, width=1, height=1)

window = imgplot.window(figure, size=(400, 200), title="Lena")
window.show()

while True:
    if window.closed():
        exit()

    ... some computation

    data = np.array(...)
    axis.update(data)

screenshot from 2018-07-01 22-11-58

#2

axis = imgplot.image(data_square)
figure.add(axis, x=0, y=0, width=1, height=1)

window = imgplot.window(figure, size=(400, 400), title="Lena")

screenshot from 2018-07-01 22-13-56

#3

axis1 = imgplot.image(data_rect)
figure.add(axis1, x=0, y=0, width=1, height=0.5)

axis2 = imgplot.image(data_rect)
figure.add(axis2, x=0, y=0.5, width=1, height=0.5)

screenshot from 2018-07-01 21-58-14

#4

axis1 = imgplot.image(data_rect)
figure.add(axis1, x=0, y=0, width=1, height=1.0 / 3.0)

axis2 = imgplot.image(data_rect)
figure.add(axis2, x=0, y=1.0 / 3.0, width=1, height=1.0 / 3.0)

axis3 = imgplot.image(data_rect)
figure.add(axis3, x=0, y=2.0 / 3.0, width=1, height=1.0 / 3.0)

window = imgplot.window(figure, size=(400, 600), title="Lena")

screenshot from 2018-07-01 22-17-51

#5

axis1 = imgplot.image(data_rect)
figure.add(axis1, x=0, y=0, width=1, height=0.5)

axis2 = imgplot.image(data_square)
figure.add(axis2, x=0, y=0.5, width=0.5, height=0.5)

axis3 = imgplot.image(data_square)
figure.add(axis3, x=0.5, y=0.5, width=0.5, height=0.5)

window = imgplot.window(figure, size=(400, 400), title="Lena")

screenshot from 2018-07-01 22-23-36

#6

axis1 = imgplot.image(data_rect)
figure.add(axis1, x=0, y=0.0, width=2.0 / 3.0, height=1)

axis2 = imgplot.image(data_square)
figure.add(axis2, x=2.0 / 3.0, y=0, width=1.0 / 3.0, height=1)

window = imgplot.window(figure, size=(600, 200), title="Lena")

screenshot from 2018-07-01 22-26-14

#7

for n in range(16):
    axis = imgplot.image(data_square)
    x = n % 4 / 4.0
    y = n // 4 / 4.0
    figure.add(axis, x=x, y=y, width=1.0 / 4.0, height=1.0 / 4.0)

window = imgplot.window(figure, size=(400, 400), title="Lena")

screenshot from 2018-07-01 22-42-50

Advanced usage

#1

axis1 = imgplot.image(data_rect)
figure.add(axis1, x=0, y=0, width=1, height=0.5)

axis2 = imgplot.image(data_rect)
figure.add(axis2, x=0, y=0.5, width=1, height=0.5)

window = imgplot.window(figure, size=(400, 400), title="Lena")
window.show()

for loop in range(1000):
    if window.closed():
        exit()

    data = np.uint8(data_rect * abs(math.cos(0.05 * loop * math.pi)))
    axis1.update(data)
    time.sleep(0.1)

peek 2018-07-01 22-52

About

Non-blocking image viewer for Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published