Display raw pixel array

Hi,

I’m using Viewer version 4.12.30, deployed locally. I’m developing a small extension for a proof of concept of a simple ML workflow.

My goal is to:

  1. send the displayed image to a server
  2. process it and send back to the viewer
  3. display the processed image.

I was able to complete the first 2 tasks, but now I’m struggling to find out a way to complete the third task in the simplest way possible. What I’m receiving from the server is the raw pixel 2D array with the same shape of the original one. My idea is to copy all the metadata of the original image and only change the pixel data, then add the new image to the current series. Is there any way to do this?
Are there better solutions?