JohnChiu commited on
Commit
81ba37c
·
1 Parent(s): 9a6d25d
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -37,12 +37,17 @@ def load_bin(file):
37
  img = np.sum(volume[:, :, :-2], axis=2)
38
  norm_img = (img - img.min()) / (img.max() + 1e-8)
39
  img_uint8 = (norm_img * 255).astype(np.uint8)
40
- return img_uint8, volume
 
 
 
41
 
42
 
43
  def plot_pixel_histogram(evt: gr.SelectData, volume):
44
- print("evt:", evt)
45
  x, y = evt.index # Gradio SelectData 对象
 
 
46
  values = volume[y, x, :]
47
  fig = go.Figure()
48
  fig.add_trace(go.Scatter(y=values, mode="lines+markers"))
@@ -58,7 +63,7 @@ with gr.Blocks() as demo:
58
  gr.Markdown("## 上传 96×240×256 int16 `.bin/.raw` 文件,点击图像像素查看该像素的 256 帧直方图")
59
 
60
  file_input = gr.File(label="上传 .raw/.bin 文件", file_types=[".raw", ".bin"])
61
- image_display = gr.Image(interactive=True, label="点击像素显示强度曲线",height=192*2, width=480*2)
62
  histogram = gr.Plot(label="像素强度曲线")
63
  volume_state = gr.State()
64
 
 
37
  img = np.sum(volume[:, :, :-2], axis=2)
38
  norm_img = (img - img.min()) / (img.max() + 1e-8)
39
  img_uint8 = (norm_img * 255).astype(np.uint8)
40
+
41
+ img_zoomed = np.repeat(np.repeat(img_uint8, 2, axis=0), 2, axis=1) # (96→192, 240→480)
42
+
43
+ return img_zoomed, volume
44
 
45
 
46
  def plot_pixel_histogram(evt: gr.SelectData, volume):
47
+ # print("evt:", evt)
48
  x, y = evt.index # Gradio SelectData 对象
49
+ x = x // 2
50
+ y = y // 2
51
  values = volume[y, x, :]
52
  fig = go.Figure()
53
  fig.add_trace(go.Scatter(y=values, mode="lines+markers"))
 
63
  gr.Markdown("## 上传 96×240×256 int16 `.bin/.raw` 文件,点击图像像素查看该像素的 256 帧直方图")
64
 
65
  file_input = gr.File(label="上传 .raw/.bin 文件", file_types=[".raw", ".bin"])
66
+ image_display = gr.Image(interactive=True, label="点击像素显示强度曲线")
67
  histogram = gr.Plot(label="像素强度曲线")
68
  volume_state = gr.State()
69