# Image Decode Implementation with CV2 and nvjpeg *author: junjie.jiang*
## Description An image decode operator implementation with OpenCV and nvjpeg. In CPU env, use OpenCV, in GPU env, use nvjpeg to decode jpeg files.
## Code Example Load a image from path './src_dog.jpg'. *Write the pipeline in simplified style:* ```python from towhee import pipe, ops, DataCollection p = ( pipe.input('url') .map('url', 'image', ops.image_decode.nvjpeg()) .output('image') ) DataCollection(p('./src_dog.jpg')).show() ```
## Factory Constructor Create the operator via the following factory method: ***ops.image_decode.nvjpeg()***
## Interface An image decode operator takes an image path as input. It decodes the image back to ndarray. **Parameters:** **img**: *str* ​ Local file path or http url. **Returns**: *towhee.types.Image (a sub-class of numpy.ndarray)* ​ The decoded image data as numpy.ndarray. # More Resources - [Scalar Quantization and Product Quantization - Zilliz blog](https://zilliz.com/learn/scalar-quantization-and-product-quantization): A hands-on dive into scalar quantization (integer quantization) and product quantization with Python. - [How to Get the Right Vector Embeddings - Zilliz blog](https://zilliz.com/blog/how-to-get-the-right-vector-embeddings): A comprehensive introduction to vector embeddings and how to generate them with popular open-source models. - [What is a Convolutional Neural Network? An Engineer's Guide](https://zilliz.com/glossary/convolutional-neural-network): Convolutional Neural Network is a type of deep neural network that processes images, speeches, and videos. Let's find out more about CNN. - [The guide to clip-vit-base-patch32 | OpenAI](https://zilliz.com/ai-models/clip-vit-base-patch32): clip-vit-base-patch32: a CLIP multimodal model variant by OpenAI for image and text embedding. - [Using Vector Search to Better Understand Computer Vision Data - Zilliz blog](https://zilliz.com/blog/use-vector-search-to-better-understand-computer-vision-data): How Vector Search improves your understanding of Computer Vision Data - [Demystifying Color Histograms: A Guide to Image Processing and Analysis - Zilliz blog](https://zilliz.com/learn/demystifying-color-histograms): Mastering color histograms is indispensable for anyone involved in image processing and analysis. By understanding the nuances of color distributions and leveraging advanced techniques, practitioners can unlock the full potential of color histograms in various imaging projects and research endeavors. - [Understanding ImageNet: A Key Resource for Computer Vision and AI Research](https://zilliz.com/glossary/imagenet): The large-scale image database with over 14 million annotated images. Learn how this dataset supports advancements in computer vision. - [Enhancing Efficiency in Vector Searches with Binary Quantization and Milvus - Zilliz blog](https://zilliz.com/learn/enhancing-efficiency-in-vector-searches-with-binary-quantization-and-milvus): Binary quantization represents a transformative approach to managing and searching vector data within Milvus, offering significant enhancements in both performance and efficiency. By simplifying vector representations into binary codes, this method leverages the speed of bitwise operations, substantially accelerating search operations and reducing computational overhead. - [Image Embeddings for Enhanced Image Search - Zilliz blog](https://zilliz.com/learn/image-embeddings-for-enhanced-image-search): Image Embeddings are the core of modern computer vision algorithms. Understand their implementation and use cases and explore different image embedding models.