= plt.subplots(1, 3, figsize=(6, 2))
fig, (ax1, ax2, ax3)
plt.close(fig); ax1.set_yticks([]); ax2.set_xticks([]);
ax1.set_xticks([]); ax3.set_xticks([]); ax3.set_yticks([])
ax2.set_yticks([])
1337)
np.random.seed(= np.random.rand(10, 10, 3)
r
= (r*256).astype(np.uint8)
x =10, ax=ax1)
fig_rgb(x, scale
= r.astype(np.float16)
x =10, ax=ax2)
fig_rgb(x, scale
> 0.5), scale=10, ax=ax3) fig_rgb((r
๐๏ธ View as RGB images
rgb
rgb (x:numpy.ndarray, denorm:Any=None, cl:Any=True, gutter_px:int=3, frame_px:int=1, scale:int=1, view_width:int=966, clip:bool=True, ax:Optional[matplotlib.axes._axes.Axes]=None)
Type | Default | Details | |
---|---|---|---|
x | ndarray | Array to display. [[โฆ], C,H,W] or [[โฆ], H,W,C] | |
denorm | Any | None | Reverse per-channel normalizatoin |
cl | Any | True | Channel-last |
gutter_px | int | 3 | If more than one tensor -> tile with this gutter width |
frame_px | int | 1 | If more than one tensor -> tile with this frame width |
scale | int | 1 | Stretch the image. Only itegers please. |
view_width | int | 966 | target width of the image |
clip | bool | True | Selently clip RGB values to [0, 1] |
ax | Optional | None | Matplotlib axes |
Returns | RGBProxy |
rgb(image)
= np.stack([image]*2)
two_images lo(two_images)
array[2, 196, 196, 3] f32 n=230496 (0.9Mb) xโ[-2.118, 2.640] ฮผ=-0.388 ฯ=1.073
= ( (0.485, 0.456, 0.406), # Mean
in_stats 0.229, 0.224, 0.225) ) # std
(=in_stats) rgb(two_images, denorm
# Make 8 images with progressively higher brightness and stack them 2x2x2.
= (np.stack([image]*8) + np.linspace(-2, 2, 8)[:,None,None,None])
eight_images = (eight_images
eight_images *np.array(in_stats[1])
+np.array(in_stats[0])
0,1).reshape(2,2,2,196,196,3)
).clip(
lo(eight_images)
array[2, 2, 2, 196, 196, 3] n=921984 (7.0Mb) xโ[0., 1.000] ฮผ=0.382 ฯ=0.319
rgb(eight_images)
# You can do channel-first too (default in PyTorch):
# Also, can scale up the image
-1, 0, 1), cl=False, scale=2) rgb(image.transpose(