I don’t think you’ll have to change much.
PILBase does some more stuff than just loading the image, so it would be better to subclass it instead of Image.
The problem might be within your load_raw_image function. Maybe this will help?
def load_raw_image(fn):
fn=str(fn)
raw_file=rawpy.imread(fn)
raw_converted_file=raw_file.raw_image_visible.astype(np.float32)
ndarr -= ndarr.min() # make min 0
ndarr /= ndarr.max() # make max 1
# if you want to return a unit8 array
# scale to 0 and 255
# ndarr *= 255
# convert to uint8
# ndarr = ndarr.astype(np.uint8)
return ndarr
class PILRaw(PILBase):
_bypass_type=Image.Image
_show_args = {'cmap':'viridis'}
_open_args = {'mode': 'F'} # F (32-bit floating point pixels)
@classmethod
def create(cls,fn:(Path,str), *args, **kwargs)->None:
return cls(load_raw_image(fn, *args, **kwargs))
