我的目标是让Jupyter笔记本中的一个单元格显示多个交互式小部件。具体来说,我想有四个滑块用于裁剪图像,然后又有一个单独的滑块用于旋转裁剪后的图像。当然,运行代码时应同时显示两个图。这就是我所拥有的。
def image_crop(a,b,c,d):
img_slic=frame[a:b,c:d]
plt.figure(figsize=(8,8))
plt.imshow(img_slic,cmap='RdBu')
return a,b,c,d
interactive_plot = interactive(image_crop, a = widgets.IntSlider(min=0,max=2000,step=10,value=500,description='Vertical_Uppper'),
b = widgets.IntSlider(min=0,max=2000,step=10,value=500,description='Vertical_Lower'),
c = widgets.IntSlider(min=0,max=1000,step=10,value=500,description='Horizontal_Left'),
d = widgets.IntSlider(min=0,max=1000,step=10,value=500,description='Horizontal_Right') )
interactive_plot
def image_rot(i):
img_rot=scipy.ndimage.rotate(frame_slic.T,i)
plt.figure(figsize=(8,8))
plt.imshow(img_rot,cmap='RdBu')
return i
interactive_plot_2 = interactive(image_rot, i =
widgets.IntSlider(min=-180,max=180,step=1,value=0,description='Rotation'))
我可以将其放在两个单元格中(第一个旋转时,第二个旋转),但不能一个。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句