Hi!
I’d like to make a Fine Matching algorithm in CUDAFY.
I have a GeForce 210 graphic card with a compute capability of 1.2
So, I copy the large and the small image into the device memory. After it I would like to find the small picture in the large picture.
For example: small picture: 5050, large picture 150150
for the first step I have to get the large picture (0,0) koordinate and the small picture (0,0).
I select an area in the large picture which is 50*50, and I compare the two same sized picture.
than i step to the second pixel at the large picture, which is (1,0), and i make the same algorithm, than (2,0), (3,0)…
The images are in 24bit format (RGB without Alpha).
I need that how many same pixels are at the the large picture (x,y). I try to save it in my histogram. For example: athe koordinate (10,10) we had 2465 same pixel /the maximum is 2500, because 50*50 pixel have the small picture/
My Launch looks like that:
int width = inputLarge.Width - inputSmall.Width; /*(large picture width-small picture width)(pixel)*/;
int height = inputLarge.Height - inputSmall.Height; /*(large picture height-small picture height)(pixel)*/;
dim3 gridDim = new dim3(width, height * inputSmall.Height);
dim3 blockDim = new dim3(inputSmall.Width);
gpu.Launch(gridDim, blockDim, "gpuFineMatchLinear", device_small, device_large, device_histogram, width, height, treshold, inputLarge.Width, inputSmall.Width, inputSmall.Height);
[Cudafy]
public static void gpuFineMatch(GThread thread, byte[] small, byte[] large, int[] histogram,
int width,
int height,
int treshold, int largeWidth, int smallWidth, int smallHeight)
{
//--> position of histogram and large picture
int hx = thread.blockIdx.x / smallHeight;
int hy = thread.blockIdx.y;
//--> position of small picture
int kx = thread.threadIdx.x;
int ky = thread.blockIdx.x % smallHeight;
//--> Offsetek
int histoOFF = hy * width + hx;
int largePicOFF = (hy * 3 * largeWidth) + hx * 3;
int smallPicOFF = (ky * 3 * smallWidth) + kx * 3;
int same = 0;
int ertek = (int)small[smallPicOFF ] - large[largePic];
same += (ertek < treshold && ertek > -treshold) ? 1 : 0;
ertek = (int)small[smallPicOFF + 1] - large[largePic+ 1];
same += (ertek < treshold && ertek > -treshold) ? 1 : 0;
ertek = (int)small[smallPicOFF + 2] - large[largePic+ 2];
same += (ertek < treshold && ertek > -treshold) ? 1 : 0;
if (same == 3) thread.atomicAdd(ref histogram[histoOFF], 1);
}
I hope you can answer me.
I have a solution for it, but it needs a lot of CPU, because I make a Clone() picture at every pixel from the large image, and than I use the GPU. So it is very slow.
Sorry for my bad english, i write to you from Hungary.
Thank you!
Zollie