Maybe not completely what you want, but if I change the following from your code it seems to work a lot better:
cmap = pn.widgets.Select(
value="binary_r", options=cmaps, name="Color Map"
)
before_img = hv.Image(image, bounds=bounds).apply.opts(
cmap=cmap, title="Before", active_tools=["box_zoom"], responsive=True
)
after_img = hv.Image(edges, bounds=bounds).apply.opts(
cmap=cmap, title="After", active_tools=["box_zoom"], responsive=True
)
before = pn.panel(before_img)
after = pn.panel(after_img)
component = pn.Row(before, after, height=2 * height)
