# Bilinear interpolation problem 

**URL:** <https://forums.developer.nvidia.com/t/bilinear-interpolation-problem/32986>\
**Category:** CUDA Programming and Performance\
**Created:** [April 20, 2014, 4:08pm UTC](https://forums.developer.nvidia.com/t/bilinear-interpolation-problem/32986 "2014-04-20T16:08:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jn66677](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jn66677](https://forums.developer.nvidia.com/u/jn66677)\
**Post date:** [April 20, 2014, 4:08pm UTC](https://forums.developer.nvidia.com/t/bilinear-interpolation-problem/32986/1 "2014-04-20T16:08:18Z")

</div>

Hello all  
I have problem,I finish my program with c(in the cpu) because it’s slow  
so I want perform program in CUDA but i have no idea  
the image has been saved f  
Someone suggest something?  
my code :  
for (j=0; jHeight ; j++)  
{  
for (i=0 ; iWidth_3 ; i+=3)  
{  
if(GU[j][i/3]\>=0 && GU[j][i/3]Width-1 && GV[j][i/3]\>=0 && GV[j][i/3]Height-1)  
{  
ncol1 = f[i + 2 + 3 \* w \* j];  
ncol2 = f[i + 5 + 3 \* w \* j];  
ncol3 = f[i + 1202 + 3 \* w \* j];  
ncol4 = f[i + 1205 + 3 \* w \* j];  
colR = (byte)((1.0-GFU[j][i/3])_(1.0-GFV[j][i/3])_(double)ncol1+(GFU[j][i/3])_(1.0-GFV[j][i/3])_(double)ncol2  
+(1.0-GFU[j][i/3])_(GFV[j][i/3])_(double)ncol3+(GFU[j][i/3])_(GFV[j][i/3])_(double)ncol4);  
ncol1 = f[i + 1 + 3 \* w \* j];  
ncol2 = f[i + 4 + 3 \* w \* j];  
ncol3 = f[i + 1201 + 3 \* w \* j];  
ncol4 = f[i + 1204 + 3 \* w \* j];  
colG = (byte)((1.0-GFU[j][i/3])_(1.0-GFV[j][i/3])_(double)ncol1+(GFU[j][i/3])_(1.0-GFV[j][i/3])_(double)ncol2  
+(1.0-GFU[j][i/3])_(GFV[j][i/3])_(double)ncol3+(GFU[j][i/3])_(GFV[j][i/3])_(double)ncol4);  
ncol1 = f[i+ 3 \* w \* j];  
ncol2 = f[i+3 + 3 \* w \* j];  
ncol3 = f[i+1203 + 3 \* w \* j];  
ncol4 = f[i+1206 + 3 \* w \* j];  
colB = (byte)((1.0-GFU[j][i/3])_(1.0-GFV[j][i/3])_(double)ncol1+(GFU[j][i/3])_(1.0-GFV[j][i/3])_(double)ncol2  
+(1.0-GFU[j][i/3])_(GFV[j][i/3])_(double)ncol3+(GFU[j][i/3])_(GFV[j][i/3])\*(double)ncol4);

}  
}  
}

---

<div class="post-metadata">

**Author:** ![jn66677](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jn66677](https://forums.developer.nvidia.com/u/jn66677)\
**Post date:** [May 3, 2014, 12:29pm UTC](https://forums.developer.nvidia.com/t/bilinear-interpolation-problem/32986/2 "2014-05-03T12:29:09Z")

</div>

```
			for (i=0 ; i<360000 ; i+=3)
			{
				if(GU2[i/3]>=0 && GU2[i/3]<Dmp->Width-1 && GV2[i/3]>=0 && GV2[i/3]<Dmp->Height-1)
				{
					 Label42->Caption=f[3];
					 Label43->Caption=c[3];
					 ncol1 = f[(int)GU2[i/3]*3+(int)GV2[i/3]*1200+2];
					 ncol2 = f[(int)GU2[i/3]*3+(int)GV2[i/3]*1200+5];
					 ncol3 = f[(int)GU2[i/3]*3+(int)GV2[i/3]*1200+1202];
					 ncol4 = f[(int)GU2[i/3]*3+(int)GV2[i/3]*1200+1205];
					 colR = (byte)((1.0-GFU2[i/3])*(1.0-GFV2[i/3])*(double)ncol1+(GFU2[i/3])*(1.0-GFV2[i/3])*(double)ncol2
								 +(1.0-GFU2[i/3])*(GFV2[i/3])*(double)ncol3+(GFU2[i/3])*(GFV2[i/3])*(double)ncol4);
					ncol1 = f[(int)GU2[i/3]*3+(int)GV2[i/3]*1200+1];
					ncol2 = f[(int)GU2[i/3]*3+(int)GV2[i/3]*1200+4];
					ncol3 = f[(int)GU2[i/3]*3+(int)GV2[i/3]*1200+1201];
					ncol4 = f[(int)GU2[i/3]*3+(int)GV2[i/3]*1200+1204];
					colG = (byte)((1.0-GFU2[i/3])*(1.0-GFV2[i/3])*(double)ncol1+(GFU2[i/3])*(1.0-GFV2[i/3])*(double)ncol2
								 +(1.0-GFU2[i/3])*(GFV2[i/3])*(double)ncol3+(GFU2[i/3])*(GFV2[i/3])*(double)ncol4);
					ncol1 = f[(int)GU2[i/3]*3+(int)GV2[i/3]*1200];
					ncol2 = f[(int)GU2[i/3]*3+(int)GV2[i/3]*1200+3];
					ncol3 = f[(int)GU2[i/3]*3+(int)GV2[i/3]*1200+1200];
					ncol4 = f[(int)GU2[i/3]*3+(int)GV2[i/3]*1200+1203];
					colB = (byte)((1.0-GFU2[i/3])*(1.0-GFV2[i/3])*(double)ncol1+(GFU2[i/3])*(1.0-GFV2[i/3])*(double)ncol2
								 +(1.0-GFU2[i/3])*(GFV2[i/3])*(double)ncol3+(GFU2[i/3])*(GFV2[i/3])*(double)ncol4);

				}

```

---

<div class="post-metadata">

**Author:** ![JFSebastian](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jfsebastian/32/75602_2.png) [@JFSebastian](https://forums.developer.nvidia.com/u/JFSebastian)\
**Post date:** [May 3, 2014, 4:32pm UTC](https://forums.developer.nvidia.com/t/bilinear-interpolation-problem/32986/3 "2014-05-03T16:32:12Z")

</div>

Linear/bilinear/trilinear interpolations can be effectively performed in CUDA by using texture memory.

---

<div class="post-metadata">

**Author:** ![jn66677](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jn66677](https://forums.developer.nvidia.com/u/jn66677)\
**Post date:** [May 3, 2014, 4:45pm UTC](https://forums.developer.nvidia.com/t/bilinear-interpolation-problem/32986/4 "2014-05-03T16:45:58Z")

</div>

> [@JFSebastian](#):
>
> Linear/bilinear/trilinear interpolations can be effectively performed in CUDA by using texture memory.

Do you have any information i can learn?  
ex: website or books ,lesson?

---

<div class="post-metadata">

**Author:** ![vacaloca](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@vacaloca](https://forums.developer.nvidia.com/u/vacaloca)\
**Post date:** [May 4, 2014, 6:02pm UTC](https://forums.developer.nvidia.com/t/bilinear-interpolation-problem/32986/5 "2014-05-04T18:02:34Z")

</div>

> [@jn66677](#):
>
> Do you have any information i can learn?  
> ex: website or books ,lesson?

Seems like your Google is broken ;)

[http://www.mathworks.com/matlabcentral/fileexchange/23795-nvidia-cuda-based-bilinear–2d–interpolation](http://www.mathworks.com/matlabcentral/fileexchange/23795-nvidia-cuda-based-bilinear--2d--interpolation)

[http://mkaczanowski.com/bilinear-interpolation-with-nvidia-cuda-c/](http://mkaczanowski.com/bilinear-interpolation-with-nvidia-cuda-c/)

[http://www.orangeowlsolutions.com/archives/300](http://www.orangeowlsolutions.com/archives/300)  
[http://www.orangeowlsolutions.com/archives/206](http://www.orangeowlsolutions.com/archives/206)  
[http://cuda-programming.blogspot.com/2013/02/texture-memory-in-cuda-what-is-texture.html](http://cuda-programming.blogspot.com/2013/02/texture-memory-in-cuda-what-is-texture.html)  
[http://cuda-programming.blogspot.com/2013/04/texture-references-object-in-cuda.html](http://cuda-programming.blogspot.com/2013/04/texture-references-object-in-cuda.html)
