当前位置:编程学习 > Matlab >>

求自适应双边滤波matlab程序,各位大侠有的话,请发我份吧!急用!Email:ju_li_an@126.com

感激涕零啊!
答案:[cpp] view plaincopyprint?
1.	UCHAR3 BBColor(int posX , int posY) 
2.	{ 
3.	int centerItemIndex = posY * picWidth4 + posX * 3 , neighbourItemIndex; 
4.	int weightIndex; 
5.	double gsAccumWeight = 0; 
6.	double accumColor = 0; 
7.	
8.	// 计算各个采样点处的Gaussian权重,包括closeness,similarity 
9.	for(int i = -number ; i <= number ; ++i) 
10.	{ 
11.	for(int j = -number ; j <= number ; ++j) 
12.	{ 
13.	weightIndex = (i + number) * (number * 2 + 1) + (j + number); 
14.	neighbourItemIndex = min(noiseImageHeight - 1 , max(0 , posY + j * radius)) * picWidth4 + 
15.	min(noiseImageWidth - 1 , max(0 , posX + i * radius)) * 3; 
16.	
17.	pCSWeight[weightIndex] = LookupGSWeightTable(pSrcDataBuffer[neighbourItemIndex] , pSrcDataBuffer[centerItemIndex]); 
18.	pCSWeight[weightIndex] = pGSWeight[weightIndex] * pGCWeight[weightIndex]; 
19.	gsAccumWeight += pCSWeight[weightIndex]; 
20.	} 
21.	} 
22.	
23.	// 单位化权重因子 
24.	gsAccumWeight = 1 / gsAccumWeight; 
25.	for(int i = -number ; i <= number ; ++i) 
26.	{ 
27.	for(int j = -number ; j <= number ; ++j) 
28.	{ 
29.	weightIndex = (i + number) * (number * 2 + 1) + (j + number); 
30.	pCSWeight[weightIndex] *= gsAccumWeight; 
31.	} 
32.	} 
33.	
34.	// 计算最终的颜色并返回 
35.	for(int i = -number ; i <= number ; ++i) 
36.	{ 
37.	for(int j = -number ; j <= number ; ++j) 
38.	{ 
39.	weightIndex = (i + number) * (number * 2 + 1) + (j + number); 
40.	neighbourItemIndex = min(noiseImageHeight - 1 , max(0 , posY + j * radius)) * picWidth4 + 
41.	min(noiseImageWidth - 1 , max(0 , posX + i * radius)) * 3; 
42.	accumColor += pSrcDataBuffer[neighbourItemIndex + 0] * pCSWeight[weightIndex]; 
43.	} 
44.	} 
45.	
46.	return UCHAR3(accumColor , accumColor , accumColor); 
47.	} 

已发至邮箱,查收吧。。。。

上一个:求高手解释下下面一段程序,Matlab,顺便说下用的是什么方法切割的,很急!!!
下一个:matlab中程序st_ = [500 20 0.2]的数值具体是什么意思?知道的请具体说一下,谢谢

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,