by jcupitt · 8mo ago · 0 comments
image = pyvips.Image.new_from_file(filename, access="sequential")
scale = min(200 / image.width, 200 / image.height)
thumbnail = image.colourspace("oklab").resize(scale).extract_bands(0, n=3)
rgbf = thumbnail.write_to_memory()
That'll stream the source image and make a RGBRGBRGB memory buffer of single precision floats. You could perhaps use kernel="linear" and avoid any ringing from lanczos3.
I think I would downsample in a linear light space, like scRGB. Averaging there means averaging photons, which will surely be better than OKLab. Maybe switch to OKLab for clustering. Though of course I've not tested it.
No comments yet.