How can i set and get pixel image with array in arrayfire

99 views
Skip to first unread message

Cong Dao

unread,
Oct 3, 2016, 9:31:27 PM10/3/16
to ArrayFire Users
Hi, I'm beginner. I want to know how can i set and get pixel image with array in arrayfire.

Example:

array image = loadImage("image.tif",true);

//How can i know number of rows,cols in image array, or number of elements in arrays.
//i want to get value pixel at (0,0) of image, If image is color image, how can i get red,green,blue value.
//How about set value pixel at(0,0).

Someone can help me? Thank you so much.

Pradeep Garigipati

unread,
Oct 5, 2016, 1:15:58 AM10/5/16
to Cong Dao, ArrayFire Users
Hello Cong Dao,

ArrayFire uses column major format to store multidimensional array data. As you have already found out, you can load an image file using loadImage function. Once you do that, the image data is stored on the GPU memory and only the meta-data such as dimensions of array and nature of array( if it's vector, complex, sparse etc.).

Since the image data is stored in column major format, you ca retrieve original image width and height by doing "array.dims(1)" and "array.dims(0)". But, often you don't need to worry about this because of most image processing operations aren't effected by the way the image data is stored.

Accessing individual pixel values from array(uses GPU memory for CUDA/OpenCL memory) is strongly not recommended as it heavy in cost in terms of performance. If you can elaborate more on what you intend to do with the individual pixel values, we can probably suggest an alternative that processes the pixels on the GPU itself.

Regards,
Pradeep.

--
You received this message because you are subscribed to the Google Groups "ArrayFire Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arrayfire-use...@googlegroups.com.
To post to this group, send email to arrayfi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/arrayfire-users/32e4e9de-ae74-4cac-81e7-d4de1208588b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages