You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to add functionality to also parse out the number of channels in the image? I'd like to distinguish between grayscale, RGB, and RGBA images. It would be OK it it got confused by things like color pallets.
The reason is that I'd like to incorporate this into my kwimage.load_image_shape function as it is stupidly faster than PIL and GDAL:
>>># For large files, PIL is much faster GDAL>>>fromosgeoimportgdal>>>fromPILimportImage>>>importtimerit>>>#>>>importkwimage>>>fpath=kwimage.grab_test_image_fpath()
>>>#>>>ti=timerit.Timerit(100, bestof=10, verbose=2)
>>>fortimerinti.reset('gdal'):
>>>withtimer:
>>>gdal_dset=gdal.Open(fpath, gdal.GA_ReadOnly)
>>>width=gdal_dset.RasterXSize>>>height=gdal_dset.RasterYSize>>>gdal_dset=None>>>#>>>fortimerinti.reset('PIL'):
>>>withtimer:
>>>pil_img=Image.open(fpath)
>>>width, height=pil_img.size>>>pil_img.close()
>>># The imagesize module is quite fast>>>importimagesize>>>fortimerinti.reset('imagesize'):
>>>withtimer:
>>>width, height=imagesize.get(fpath)
Timed gdal for: 100 loops, best of 10
time per loop: best=83.266 µs, mean=85.919 ± 2.1 µs
Timed PIL for: 100 loops, best of 10
time per loop: best=38.191 µs, mean=38.981 ± 0.7 µs
Timed imagesize for: 100 loops, best of 10
time per loop: best=8.269 µs, mean=8.516 ± 0.2 µs
But in those use-cases it's often important to know how many channels there will be as well. Is that possible to parse out of the headers?
The text was updated successfully, but these errors were encountered:
Is it possible to add functionality to also parse out the number of channels in the image? I'd like to distinguish between grayscale, RGB, and RGBA images. It would be OK it it got confused by things like color pallets.
The reason is that I'd like to incorporate this into my
kwimage.load_image_shape
function as it is stupidly faster than PIL and GDAL:But in those use-cases it's often important to know how many channels there will be as well. Is that possible to parse out of the headers?
The text was updated successfully, but these errors were encountered: