JohnChiu commited on
Commit
15b4c14
·
1 Parent(s): b20e16f
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -82,12 +82,9 @@ def select_frame(frame_idx, volume):
82
  img_uint8 = (norm_img * 255).astype(np.uint8)
83
  return img_uint8
84
 
85
- # 点击图像某pixel,画该pixel在所有帧的强度曲线(X轴是T帧索引)
86
  def plot_pixel_histogram(evt, volume):
87
- if volume is None:
88
- return None
89
- x, y = evt.index # evt.index 是 (col, row)
90
- # 注意 volume shape是 (H, W, T),索引为 [y, x, :]
91
  values = volume[y, x, :]
92
  fig = go.Figure()
93
  fig.add_trace(go.Scatter(y=values, mode="lines+markers"))
@@ -114,8 +111,6 @@ with gr.Blocks() as demo:
114
  # 点击图像像素,绘制强度曲线
115
  # image_display.select(plot_pixel_histogram, inputs=[gr.EventData(), volume_state], outputs=histogram)
116
 
117
- # 绑定点击事件
118
- image_display.select(plot_pixel_histogram, inputs=[gr.SelectData(), volume_state], outputs=histogram)
119
-
120
 
121
  demo.launch()
 
82
  img_uint8 = (norm_img * 255).astype(np.uint8)
83
  return img_uint8
84
 
85
+
86
  def plot_pixel_histogram(evt, volume):
87
+ x, y = evt.index
 
 
 
88
  values = volume[y, x, :]
89
  fig = go.Figure()
90
  fig.add_trace(go.Scatter(y=values, mode="lines+markers"))
 
111
  # 点击图像像素,绘制强度曲线
112
  # image_display.select(plot_pixel_histogram, inputs=[gr.EventData(), volume_state], outputs=histogram)
113
 
114
+ image_display.select(plot_pixel_histogram, inputs=[volume_state], outputs=histogram)
 
 
115
 
116
  demo.launch()