nvjpeg-python icon indicating copy to clipboard operation
nvjpeg-python copied to clipboard

To decode images immediately into the desired format

Open SalimMaxHigh opened this issue 4 years ago • 1 comments

Hey! Thanks for a great library for decoding images. I would like to know if there is a possibility to decode images immediately into the desired format. For example in gray, such as in OpenCV: cv2.imdecode(some_image, cv2.IMREAD_GRAYSCALE).

SalimMaxHigh avatar Jun 02 '21 04:06 SalimMaxHigh

Thanks for using.

If you want to get a gray image. You can try:

from nvjpeg import NvJpeg 
import numpy as np
nj = NvJpeg()
nv_img = nj.read(YOUR_IMG_PATH).dot([0.114,0.587,0.299]).astype(np.uint8)
cv2.imshow("GrayImg", nv_img)
cv2.waitKey(0)

zeng-qinghui avatar Jun 05 '21 22:06 zeng-qinghui