Jenaro Calviño Jenaro Calviño - 1 year ago 116
C Question

OpenCL - C - Mirror of a matrix

I'm making a project where I need to mirror an image vertically. The image is read by a function and then set into an array pixel by pixel, to move through this array I am using

array[idy*w + idx]
(w being the width of the matrix or image in my case) now, since this will run concurrently I only need to find the opposite pixel so that I can assign it.

I mean something like this:

array[idy*w + idx] = array[opposite pixel];
array[opposite pixel] = array[idy*w + idx];

The problem is I can't find the proper way to do it.

Any answer would be highly appreciated.

I have tried doing the following but it doesn't work
array[idy*w + (w - (idx + 1))]

Answer Source

This is what worked for me in the end:

outputImage[idy*w + idx] = inputImage[idy*w + (w - idx - 1)];  
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download