OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.
1663 Discussions

Help with Image processing in OpenCL

nikey1
Beginner
172 Views
Hi,
I am pretty much new to OpenCL.
I wantto read a jpeg image file into the kernel, do some processing, get the results back to the host and output the image file into some other location. I am facing somedifficulties doing this.

When using the clCreateImage2D,I need to specify the size of the image manually. Is there a way that I can get the size of the image from some routines and pass them tothis function.?

AlsoI need to understandwhatthe "host ptr" arguement(last but second arguement) exactly meansthat theclCreateImage2D routinetakes. Isit like we can specify thelocation of the image directly ?
0 Kudos
2 Replies
Raghupathi_M_Intel
172 Views
The first part of your question is not really OpenCL related. There are many libraries available that let you read/write jpeg files that give you a way to get the image dimensions.

The host_ptr argument that clCreateImage2D() requires is the address in the host memory that points tothe image data.

Also, note that on CPU images are very slow. It is recommended to use buffers. You are fine on GPU.

Thanks,
Raghu
nikey1
Beginner
172 Views
Thanks Raghupati.
I found that I can directly use the C++ library routines to get the image dimensions and not depend on opencl for that. So now can I do this..
I will convert the jpeg image into some array and convert that to a float array. Can I create a buffer and put this float array into the buffer. Then do some processing on the GPU kernel.
I hope this should be fine. can the clEnqueueWriteBuffer() be used for this purpose?
Reply