uber-research / jpeg2dct

Other
257 stars 44 forks source link

Feature Request: Load function using a RGB numpy array #3

Closed saikia1 closed 5 years ago

saikia1 commented 5 years ago

For NN training we use data augmentation mostly; the image returned by augmentation function is either a tensor/ndarray; to use DCT based training inputs we will need to save the augmented image to the disk and read again; which is very inefficient.

Can you add one feature to load dct representation using a numpy array (RGB).

im = cv2.imread('test.img')
y,cb,cr = load_numpy(im)
gueguenster commented 5 years ago

actually there is such a function, but it works directly with image bytes. You can do the following:

`

read the image into numpy

import cv2 im = cv2.imread('test.img')

collect the jpeg bytes into byte string

from jpeg2dct.numpy import load, loads _, bytes = cv2.imencode('.jpg', im) # these bytes might need a further transform for the right type y, cb, cr = loads(bytes.tostring()) `