Hi,
I am using pytorch to generate a temporal median across “n” images in an array and this works very well. But now I would like to mask out image regions I dont need to compute the median for and set these regions to zero in the image array, ie. mask.
Now I have a stacked array of images that are mostly zero values, but the pytorch median function takes same time to compute.
How do I construct a torch.median(image_array) to ignore zeros, but retain the image shape in the result. If I do torch.nonzero I get tuples and if I set as_tupples=False, pytorch says there is no such thing as “as_tupples”.
Any help would be appreciated. Image array is [1920x1080x1] by 21 frames stacked into a buffer, converted to torch tensor, then apply torch.median to the buffer. This works fine and retains shape provided I use np.array(tensor) to convert back to an image.
thanks in advance