What changed with image_rgba() example?


@p-himik had a clean working example here showing how to rotate a image_rgba glyph.

It worked well with the earlier Bokeh 2 versions but no longer works with Bokeh 2.3.2.

When run as a server application it gives no errors but has only a blank browser screen. No glyphs. Completely blank.

bokeh serve --show rotate_img_example.py

Did something get broken or does this issue have a clear work-around?


In fact that example never should have worked at all, since the shape of the image array is wrong:

In [2]: orig_img.shape
Out[2]: (14, 50, 1)

Image arrays have always been expected to be two-dimensional, so this “working” previously was undefined and unexpected (and most importantly: unmaintained) behavior. Singleton dimensions in NumPy arrays can removed by calling the squeeze method on the array before passing it to Bokeh.

Ok, right, that’s certainly part of the solution.

Adding the .squeeze() method and adjusting the img_rot.shape to only ask for height and width (ih, iw) allows it to display correctly.

But the rotation algorithm no longer works.

The M matrix is 2x3.

I’m not sure what this means. When I push the button, I see a rotated (if very pixelated) image. The only change I made was here, at the very last step:

def mk_data(image):
    ih, iw, _ = image.shape
    return dict(image=[image.squeeze()], ....)

hello @Bryan , this works well.

adding the .squeeze() on image within mk_data from the previous example works just fine.

I think I added the squeeze() at a different location earlier and was getting an error.

thanks for the quick reply.

1 Like