Run imagej macro on numpy array

Hi,

I built my image processing pipeline in python but am looking for some Imagej functionality such as the rolling ball background subtraction. I have the following problem:

import numpy as np
import matplotlib.pyplot as plt
from skimage import io
from jnius import autoclass

import imagej
ij = imagej.init('sc.fiji:fiji:2.0.0-pre-10')
ij.getVersion()

After initializing imagej and everything else, I import an image as numpy array (I would use a pre-processed image / numpy array in my actual workflow but it’s easier to use a web image here).

After converting the image to java, I try to run a macro on said image. However, I don’t seem to be able to open / tell imagej which image I want open.

url = 'https://wsr.imagej.net/images/Cell_Colony.jpg'
img = io.imread(url)
img = np.array(img)
img_java = ij.py.to_java(img)

macro = f'''
selectWindow("{img_java}");
run("Subtract Background...", "rolling=50 light sliding");
'''

WindowManager = autoclass('ij.WindowManager')
# Open my image / in macro?
ij.py.run_macro(macro)
curr_image = WindowManager.getCurrentImage()
output = ij.py.from_java(curr_image)
plt.imshow(output)
plt.show()

Does anybody know how I can specify open my image or if there is a workaround.
Thanks in advance for any suggestions. BBQuercus