Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 32f656f

Browse filesBrowse files
authored
implement yuv and other colorspaces and "bufferless" TextureArray (#1033)
* implement yuv and 'bufferless' TextureArraY * unbuffered and yuv420 works * warning on tooltip * NDImage always uses unbuffered, support colorspaces in NDIMage * update docstrings * by default disable AA and set pixel_scale=1.0 for performance * unpacked yuv support * independent graphics and texture features for rgb and yuv * docstrings * docstrings * import order * yuv graphic working nicely * add enum to top level namespace * update script to produce add graphics mixin * add yuv example * update ndimage with yuv stuff * fixes * yuv video working well with NDWidget
1 parent b7c15de commit 32f656f
Copy full SHA for 32f656f

21 files changed

+1,086-278Lines changed: 1086 additions & 278 deletions
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎examples/image/image_yuv.py‎

Copy file name to clipboard
+56Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""
2+
YUV Image
3+
=========
4+
5+
Example that shows how to use YUV images. Most videos are stored in this colorspace.
6+
Y stores luma at full resolution, UV stores chroma values.
7+
In yuv420p UV channels are stored at half the resolution of Y. In yuv444p, UV channels are stored
8+
at full resolution.
9+
10+
YUV is also called YCbCr for digital images.
11+
12+
For more info: https://en.wikipedia.org/wiki/Y%E2%80%B2UV
13+
14+
You can see the slight differences between yuv420 and yuv444 if you zoom into parts of the image where colors change
15+
rapidly over space, such as the astronaut's patch.
16+
"""
17+
18+
# test_example = true
19+
# sphinx_gallery_pygfx_docs = 'screenshot'
20+
21+
import fastplotlib as fpl
22+
import numpy as np
23+
from skimage.color import rgb2ycbcr
24+
import imageio.v3 as iio
25+
26+
# convert an rgb image to ycbcr for example purposes
27+
img = iio.imread("imageio:astronaut.png")
28+
img_yuv = rgb2ycbcr(img).astype(np.uint8)
29+
30+
y = img_yuv[..., 0]
31+
u = img_yuv[..., 1]
32+
v = img_yuv[..., 2]
33+
34+
figure = fpl.Figure(
35+
shape=(1, 2), names=["yuv420p", "yuv444p"], controller_ids="sync", size=(700, 400)
36+
)
37+
38+
image1 = figure[0, 0].add_image_yuv(
39+
data=(y, u[::2, ::2], v[::2, ::2]), colorspace="yuv420p"
40+
)
41+
42+
image2 = figure[0, 1].add_image_yuv(data=(y, u, v), colorspace="yuv444p")
43+
44+
cursor = fpl.Cursor()
45+
46+
for subplot in figure:
47+
cursor.add_subplot(subplot)
48+
49+
figure.show()
50+
51+
52+
# NOTE: fpl.loop.run() should not be used for interactive sessions
53+
# See the "JupyterLab and IPython" section in the user guide
54+
if __name__ == "__main__":
55+
print(__doc__)
56+
fpl.loop.run()
Collapse file

‎fastplotlib/__init__.py‎

Copy file name to clipboardExpand all lines: fastplotlib/__init__.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .utils import loop # noqa
77
from .utils import (
88
config,
9+
enums,
910
enumerate_adapters,
1011
select_adapter,
1112
print_wgpu_report,
Collapse file

‎fastplotlib/graphics/__init__.py‎

Copy file name to clipboardExpand all lines: fastplotlib/graphics/__init__.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from ._base import Graphic
22
from .line import LineGraphic
33
from .scatter import ScatterGraphic
4-
from .image import ImageGraphic
4+
from .image import ImageGraphic, ImageYUVGraphic
55
from .image_volume import ImageVolumeGraphic
66
from ._vectors import VectorsGraphic
77
from .mesh import MeshGraphic, SurfaceGraphic, PolygonGraphic
@@ -14,6 +14,7 @@
1414
"LineGraphic",
1515
"ScatterGraphic",
1616
"ImageGraphic",
17+
"ImageYUVGraphic",
1718
"ImageVolumeGraphic",
1819
"VectorsGraphic",
1920
"MeshGraphic",
Collapse file

‎fastplotlib/graphics/features/__init__.py‎

Copy file name to clipboardExpand all lines: fastplotlib/graphics/features/__init__.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
)
2828
from ._image import (
2929
TextureArray,
30+
TextureYUV,
31+
TupleYUV,
3032
ImageCmap,
3133
ImageVmin,
3234
ImageVmax,
@@ -93,6 +95,8 @@
9395
"VertexPointSizes",
9496
"UniformSize",
9597
"TextureArray",
98+
"TextureYUV",
99+
"TupleYUV",
96100
"ImageCmap",
97101
"ImageVmin",
98102
"ImageVmax",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.