体绘制之用Summed-Area table判断体数据块是不是透明手机壳ps绘制教程

【GPU编程】体绘制之用Summed-Area table判断体数据块是不是透明
【GPU编程】体绘制之用Summed-Area table判断体数据块是不是透明
发布时间: 9:01:41
编辑:www.fx114.net
本篇文章主要介绍了"【GPU编程】体绘制之用Summed-Area table判断体数据块是不是透明",主要涉及到【GPU编程】体绘制之用Summed-Area table判断体数据块是不是透明方面的内容,对于【GPU编程】体绘制之用Summed-Area table判断体数据块是不是透明感兴趣的同学可以参考一下。
【GPU编程】体绘制之用Summed-Area table判断体数据块是不是透明【GPU编程】体绘制之用Summed-Area table判断体数据块是否透明在体绘制(Volume Rendering)中,经常用到的一种加速技术是透明区域块跳跃技术(Empty Space Skipping)。透明区域块,顾名思义,就是这个块中各个体素对应的α(不透明度值或者叫阻光度值,依据传输函数映射而来)等于零。由于等于零的体素对于最终的绘制结果并没有绘制作用,因此跳过这些体素,不对其进行采样与合成计算可以起到加速的作用。
为了实现透明区域跳跃技术,首先需要将3D体数据划分为等大小的块(brick),块大小一般为16*16*16或者是32*32*32比较合适,太大的话,容易造成透明块数量太小,块划分太小的话会增加计算量。然后我们在体绘制的时候,很重要的一个步骤是需要判断块是否透明。下面就介绍一种高效的寻找透明块的方法。最常用的方法就是最小值-最大值编码和建立summed-area
Summed-Area table是依据体素对应的阻光度值如下计算的:
S(0) = α(0)
S(k) = S(k - 1) + α(k)
k的取值范围是[0,MaxScalarValue]即整个体数据的灰度范围比如[0,4095],MaxScalarValue是体数据中最大的灰度值。
我们在划分块的时候,需要记录每个块中体素的最大值Imax和最小值Imin。这样,位于范围[Imin,Imax]之间的阻光度值之和可以如下查表计算得出:
如果S(Imax) - S(Imin)等于零,那么可以判断块是透明的,可以跳过。
这个时候,我们需要注意的是,针对传输函数两种分类方法Pre-Classification和Post-Classification(参考:体绘制传输函数-分类(Volume Rendering Transfer function:Pre- VS
Post-Classification)),是有所区别的。对于后者,前面提到的min-max编码方法得出的结果要更加准确一些。因为是先对标量数据值进行插值,再进行传输函数映射,所以在最小值和最大值之间的所有值都有可能出现。但是如果采用的是Pre-Classification,当应用于较大的数据区域时,这个编码方法显得粒度太大,会丢失很多信息。
看下图,它显示了上述的min-max编码方法无法满足要求的情形:
上图显示,如果采用的是Pre-Classification,那么min-max编码的粒度问题。如果非透明对于的标量值的范围是130到150,那么一句此方法将会得出两个块均是非透明的。但事实是块1是透明的而块2是非透明的。
为了解决Pre-Classification这一问题,我们采用一个更加完善的数据结构,比如量化二值直方图,其一般编码方法为:
在这个式子中,B是某一个块中所有标量值的集合。值为1意味着该灰度值至少在块中的某一个网格点上面出现过,否则就是通过插值得到的。
这个编码方法比较有效,但是通常在内存使用方面不高效。
除此之外,我们可以对灰度值区间进行量化:
如果灰度值x取值范围是[0,4095],那么i取值范围就是[0,31]。上式取值为1的意义是:存在某个网格点,其对应的灰度值位于区间[128*i,128*(i+1)]内。在预处理阶段,每个块被解析并编码。
同样的编码方式可以应用在传输函数的阻光度上:
x和i的意义同上面的式子。在灰度区间[128*i,128*(i+1)]内,存在传输函数映射之后阻光度不为零的值。每当传输函数发生变化,需要重新编码。
这样,我们就可以依据下式判断一个块是否透明:
式子(5)的含义是式子(3)和(4)不同时满足:在某个灰度区间段内,要么没有网格点在此范围内,要么在传输函数映射之后没有阻光度值不等于0.这就满足了块为透明的要求。
注意,上述方法仅适用于Pre-Classification的方法。
参考资料:
《Memory efficient acceleration structures and techniques for cpu based volume raycasting of large data》
《Advanced Illumination Techniques for GPU-based Volume Rendering-SIGGRAPH 2009 Course Notes》
本文标题:
本页链接:3DsMax导出插件编写(四)——导出骨骼动画的帧信息
查看: 5048|
摘要: 接下来讲一下怎样导出骨骼动画。 首先我们要收集蒙皮信息。常规方法我们已经介绍过怎样获取蒙皮信息了,这里只介绍一些IGame的方法: IGameSkin* bool meshSkin = int mods = iObj-GetNumModifiers();
接下来讲一下怎样导出骨骼动画。 首先我们要收集蒙皮信息。常规方法我们已经介绍过怎样获取蒙皮信息了,这里只介绍一些IGame的方法: IGameSkin* bool meshSkin = int mods = iObj-&GetNumModifiers(); if(mods&0) {
for(i = 0;i&i++)
IGameModifier * im = iObj-&GetIGameModifier(i);
if(im-&IsSkin())
skin = (IGameSkin*)
meshSkin =
}我们用上面的方法先判断一下节点身上有多少个修改器,然后逐个遍历一下,假如有蒙皮的信息,就把修改器存下来。Igame的一个方便地方,就是它的通用,这里的IsSkin已经包含了3dsmax的两种蒙皮方式了,所以美术可以使用自己喜欢的蒙皮修改器来做蒙皮了。 int vertSum = iMesh-&GetNumberOfVerts(); for(i = 0;i&vertSi++) {
if(meshSkin)
int type = skin-&GetVertexType(i);
if(type==IGameSkin::IGAME_RIGID)
SkinInfo subSkinI
INode* bNode = skin-&GetBone(i,0);
//subSkinInfo 是我记录信息的类,里面可以保存骨骼名称和权重
subSkinInfo.boneName = bNode-&GetName();
subSkinInfo.weight = 1;
vInfo.skinInfo.push_back(subSkinInfo);
else //blended
for(j=0;j&skin-&GetNumberOfBones(i);j++)
SkinInfo subSkinI
INode* bNode = skin-&GetBone(i,j);
float weight = skin-&GetWeight(i,j);
subSkinInfo.boneName = bNode-&GetName();
subSkinInfo.weight =
vInfo.skinInfo.push_back(subSkinInfo);
objList.vert.push_back(vInfo); }
好了,蒙皮信息已经记录完了,那么下面就来开始导出动画: 在之前我们已经介绍过怎样去获取场景里面所有骨骼的节点,这里就不重复。接下来我们先要获取一下当前场景的动画长度,然后遍历动画的长度,遍历所有获取到的骨骼,然后获取它们在每一帧的信息,下面是用IGame,其实用常规方法也是一样的做法,只是使用的函数不一样而已:void GetAllFrame(Interface *itf){ Interval ARange = itf-&GetAnimRange(); TimeValue tAniTime = ARange.End()-ARange.Start(); TimeValue tTime = ARange.Start(); int gpf = GetTicksPerFrame(); frameCount = tAniTime/
for(i =0;i&frameCi++) {
BoneFrame tempF
tempFrame.frameIndex =
for(j = 0;j&bones.size();j++)
BoneKey bK
GMatrix gm = bones[j].node-&GetWorldTM(i*gpf);
Point3 pos = gm.Translation();
Point3 rota = gm.Rotation().Vector();
bKey.x = pos.x;
bKey.y = pos.y;
bKey.z = pos.z;
bKey.rx = rota.x;
bKey.ry = rota.y;
bKey.rz = rota.z;
tempFrame.keys.push_back(bKey);
frames.push_back(tempFrame); }}说明:上面我们记录了很多信息,其实只是一个示范,具体需要什么信息,可以根据个人的需要来定。比如上面我获取的是GetWorldTM世界坐标的矩阵,这是方便后期计算,却不利于文件的容量,我们可以改成GetLocalTM获取相对的坐标,这样做,保存的文件容量可以减少到原来的三分之一以下。然后我们可以选择保存整个矩阵GMatrix&,也可以选择保存单独的位移旋转的数据。最后,我们甚至可以连单独的位移旋转数据都不用每一帧保存,只需要记录它相对于第一帧时候的增量来保存。经过层层的优化,你的保存动画的文件就可以很小很小了。比如我的一个跑步的动画,如果是直接获取世界坐标然后保存矩阵,文件的大小大概在90几k左右。但如果最后各种优化,最终的文件大小只有9k。 当然了,在我们减少了文件容量的同时,我们是相应的增大了文件应用时候解析的难度和计算量的,这个优劣就自己去衡量了。
好了,到这里,阿赵我的3dsMax模型插件导出的介绍就结束了,接下来,就是你自己来写导出插件,然后自己解析模型的过程了。相信自己导出的数据,自己再解析起来,将会是非常非常简单的事情了。
上一篇:下一篇:
Powered byFrom Wikipedia, the free encyclopedia
A summed area table is a
for quickly and efficiently generating the sum of values in a rectangular subset of a grid. In the
domain, it is also known as an integral image. It was introduced to
in 1984 by
for use with . In
it was popularized by Lewis and then given the name "integral image" and prominently used within the
in 2001. Historically, this principle is very well known in the study of multi-dimensional probability distribution functions, namely in computing 2D (or ND) probabilities (area under the probability distribution) from the respective .
As the name suggests, the value at any point (x, y) in the summed area table is just the sum of all the pixels above and to the left of (x, y), inclusive:
{\displaystyle I_{\sum }(x,y)=\sum _{\begin{smallmatrix}x'\leq x\\y'\leq y\end{smallmatrix}}i(x',y')}
Moreover, the summed area table can be computed efficiently in a single pass over the image, using the fact that the value in the summed area table at (x, y) is just:
{\displaystyle I(x,y)=i(x,y)+I(x-1,y)+I(x,y-1)-I(x-1,y-1)\,}
A description of computing a sum in the Summed Area Table data structure/algorithm
Once the summed area table has been computed, the task of evaluating the intensities over any rectangular area requires only four array references. This allows for a constant calculation time that is independent of the size of the rectangular area. That is, using the notation in the figure at right, having A=(x0, y0), B=(x1, y0), C=(x0, y1) and D=(x1, y1), the sum of i(x,y) over the rectangle spanned by A, B,C and D is:
{\displaystyle \sum _{\begin{smallmatrix}x_{0}&x\leq x_{1}\\y_{0}&y\leq y_{1}\end{smallmatrix}}i(x,y)=I(D)+I(A)-I(B)-I(C)}
This method is naturally extended to continuous domains.
The method can be also extended to high-dimensional images. If the corners of the rectangle are
{\displaystyle x^{p}}
{\displaystyle p}
{\displaystyle \{0,1\}^{d}}
, then the sum of image values contained in the rectangle are computed with the formula
{\displaystyle \sum _{p\in \{0,1\}^{d}}(-1)^{d-\|p\|_{1}}I(x^{p})\,}
{\displaystyle I(x)}
is the integral image at
{\displaystyle x}
{\displaystyle d}
the image dimension. The notation
{\displaystyle x^{p}}
correspond in the example to
{\displaystyle d=2}
{\displaystyle A=x^{(0,0)}}
{\displaystyle B=x^{(1,0)}}
{\displaystyle C=x^{(1,1)}}
{\displaystyle D=x^{(0,1)}}
. In , for example, the images have dimension
{\displaystyle d=3}
{\displaystyle d=4}
, when using
or voxels with a time-stamp.
This method has been extended to high-order integral image as in the work of Phan et al. who provided two, three, or four integral images for quickly and efficiently calculating the standard deviation (variance), skewness, and kurtosis of local block in the image. This is detailed below:
To compute
of a block, we need two integral images:
{\displaystyle I(x,y)=\sum _{\begin{smallmatrix}x'\leq x\\y'\leq y\end{smallmatrix}}i(x',y')}
{\displaystyle I^{2}(x,y)=\sum _{\begin{smallmatrix}x'\leq x\\y'\leq y\end{smallmatrix}}i^{2}(x',y')}
The variance is given by:
{\displaystyle \operatorname {Var} (X)={\frac {1}{n}}\sum _{i=1}^{n}(x_{i}-\mu )^{2}.}
{\displaystyle S_{1}}
{\displaystyle S_{2}}
denote the summations of block
{\displaystyle ABCD}
{\displaystyle I}
{\displaystyle I^{2}}
, respectively.
{\displaystyle S_{1}}
{\displaystyle S_{2}}
are computed quickly by integral image. Now, we manipulate the variance equation as:
{\displaystyle \operatorname {Var} (X)={\frac {1}{n}}\sum _{i=1}^{n}(x_{i}^{2}-2\cdot \mu \cdot x_{i}+\mu ^{2})={\frac {1}{n}}(\sum _{i=1}^{n}(x_{i})^{2}-2\cdot \sum _{i=1}^{n}(\mu \cdot x_{i})+\sum _{i=1}^{n}(\mu ^{2}))={\frac {1}{n}}(\sum _{i=1}^{n}(x_{i})^{2}-2\cdot \sum _{i=1}^{n}(\mu \cdot x_{i})+n\cdot (\mu ^{2}))}
{\displaystyle ={\frac {1}{n}}(\sum _{i=1}^{n}(x_{i})^{2}-2\cdot \mu \cdot \sum _{i=1}^{n}(x_{i})+n\cdot (\mu ^{2}))={\frac {1}{n}}(S_{2}-2\cdot S_{1}/n\cdot S_{1}+n\cdot ((S_{1}/n)^{2}))={\frac {1}{n}}(S_{2}-(S_{1})^{2}/n)}
{\displaystyle \mu =S_{1}/n}
{\displaystyle S_{2}=\sum _{i=1}^{n}(x_{i}^{2})}
Similar to the estimation of the mean (
{\displaystyle \mu }
) and variance (
{\displaystyle Var}
), which requires the integral images of the first and second power of the image respectively (i.e.
{\displaystyle I,I^{2}}
); manipulations similar to the ones mentioned above can be made to the third and fourth powers of the images (i.e.
{\displaystyle I^{3}(x,y),I^{4}(x,y)}
.) for obtaining the skewness and kurtosis. But one important implementation detail that must be kept in mind for the above methods, as mentioned by F Shafait et al. is that of integer overflow occurring for the higher order integral images in case 32-bit integers are used.
Lewis, J.P. (1995). Fast template matching. Proc. Vision Interface. pp. 120–123.
Finkelstein, A neeratsharma (2010). . Wolfram Demonstration Project.
Crow, Franklin (1984).
(PDF). SIGGRAPH '84: Proceedings of the 11th annual conference on Computer graphics and interactive techniques. pp. 207–212.
Viola, P Jones, Michael (2002).
(PDF). International Journal of Computer Vision.
Tapia, Ernesto (January 2011). "A note on the computation of high-dimensional integral images". Pattern Recognition Letters. 32 (2). :.
Phan, T Sohoni, S Larson, Eric C.; Chandler, Damon M. (22 April 2012).
(PDF). 2012 IEEE Southwest Symposium on Image Analysis and Interpretation: 83. :.
Shafait, F Keysers, D M. Breuel, Thomas (January 2008).
(PDF). Electronic Imaging. :.
Lecture videos编程语言排名榜 Python 或成黑马 - 编程当前位置:& &&&编程语言排名榜 Python 或成黑马编程语言排名榜 Python 或成黑马&&网友分享于:&&浏览:8次编程语言排行榜 Python 或成黑马
TIOBE 世界编程语言排行榜在一定程度上体现了编程语言在当前的流行趋势。这个排行榜每个月更新一次,排行榜的数据取样来源于互联网上富有经验的程序员、商业应用、著名的搜索引擎(诸如谷歌、 MSN 、雅虎)的关键字排名、 Alexa 上的排名等。本月结果已出,Python上升显著。
AD:&51CTO云计算架构师峰会 抢票进行中!
TIOBE 世界编程语言排行榜在一定程度上体现了编程语言在当前的流行趋势。这个排行榜每个月更新一次,排行榜的数据取样来源于互联网上富有经验的程序员、商业应用、著名的搜索引擎(诸如谷歌、 MSN 、雅虎)的关键字排名、 Alexa 上的排名等。本月结果已出,Python上升显著。
Delta in Position
Programming Language
+0.48%
(Visual) Basic
+0.21%
C++
+2.23%
+1.01%
JavaScript
+0.32%
+1.51%
+0.11%
PowerShell
+0.44%
+0.00%
Lisp/Scheme
ActionScript
Programming Language
FoxPro/xBase
RPG (OS/400)
Transact-SQL
Bourne shell
Objective-C
CL (OS/400)
12345678910
12345678910
12345678910 上一篇:下一篇:文章评论相关解决方案 12345678910 Copyright & &&版权所有From Wikipedia, the free encyclopedia
(Redirected from )
A summed area table is a
for quickly and efficiently generating the sum of values in a rectangular subset of a grid. In the
domain, it is also known as an integral image. It was introduced to
in 1984 by
for use with . In
it was popularized by Lewis and then given the name "integral image" and prominently used within the
in 2001. Historically, this principle is very well known in the study of multi-dimensional probability distribution functions, namely in computing 2D (or ND) probabilities (area under the probability distribution) from the respective .
As the name suggests, the value at any point (x, y) in the summed area table is just the sum of all the pixels above and to the left of (x, y), inclusive:
{\displaystyle I_{\sum }(x,y)=\sum _{\begin{smallmatrix}x'\leq x\\y'\leq y\end{smallmatrix}}i(x',y')}
Moreover, the summed area table can be computed efficiently in a single pass over the image, using the fact that the value in the summed area table at (x, y) is just:
{\displaystyle I(x,y)=i(x,y)+I(x-1,y)+I(x,y-1)-I(x-1,y-1)\,}
A description of computing a sum in the Summed Area Table data structure/algorithm
Once the summed area table has been computed, the task of evaluating the intensities over any rectangular area requires only four array references. This allows for a constant calculation time that is independent of the size of the rectangular area. That is, using the notation in the figure at right, having A=(x0, y0), B=(x1, y0), C=(x0, y1) and D=(x1, y1), the sum of i(x,y) over the rectangle spanned by A, B,C and D is:
{\displaystyle \sum _{\begin{smallmatrix}x_{0}&x\leq x_{1}\\y_{0}&y\leq y_{1}\end{smallmatrix}}i(x,y)=I(D)+I(A)-I(B)-I(C)}
This method is naturally extended to continuous domains.
The method can be also extended to high-dimensional images. If the corners of the rectangle are
{\displaystyle x^{p}}
{\displaystyle p}
{\displaystyle \{0,1\}^{d}}
, then the sum of image values contained in the rectangle are computed with the formula
{\displaystyle \sum _{p\in \{0,1\}^{d}}(-1)^{d-\|p\|_{1}}I(x^{p})\,}
{\displaystyle I(x)}
is the integral image at
{\displaystyle x}
{\displaystyle d}
the image dimension. The notation
{\displaystyle x^{p}}
correspond in the example to
{\displaystyle d=2}
{\displaystyle A=x^{(0,0)}}
{\displaystyle B=x^{(1,0)}}
{\displaystyle C=x^{(1,1)}}
{\displaystyle D=x^{(0,1)}}
. In , for example, the images have dimension
{\displaystyle d=3}
{\displaystyle d=4}
, when using
or voxels with a time-stamp.
This method has been extended to high-order integral image as in the work of Phan et al. who provided two, three, or four integral images for quickly and efficiently calculating the standard deviation (variance), skewness, and kurtosis of local block in the image. This is detailed below:
To compute
of a block, we need two integral images:
{\displaystyle I(x,y)=\sum _{\begin{smallmatrix}x'\leq x\\y'\leq y\end{smallmatrix}}i(x',y')}
{\displaystyle I^{2}(x,y)=\sum _{\begin{smallmatrix}x'\leq x\\y'\leq y\end{smallmatrix}}i^{2}(x',y')}
The variance is given by:
{\displaystyle \operatorname {Var} (X)={\frac {1}{n}}\sum _{i=1}^{n}(x_{i}-\mu )^{2}.}
{\displaystyle S_{1}}
{\displaystyle S_{2}}
denote the summations of block
{\displaystyle ABCD}
{\displaystyle I}
{\displaystyle I^{2}}
, respectively.
{\displaystyle S_{1}}
{\displaystyle S_{2}}
are computed quickly by integral image. Now, we manipulate the variance equation as:
{\displaystyle \operatorname {Var} (X)={\frac {1}{n}}\sum _{i=1}^{n}(x_{i}^{2}-2\cdot \mu \cdot x_{i}+\mu ^{2})={\frac {1}{n}}(\sum _{i=1}^{n}(x_{i})^{2}-2\cdot \sum _{i=1}^{n}(\mu \cdot x_{i})+\sum _{i=1}^{n}(\mu ^{2}))={\frac {1}{n}}(\sum _{i=1}^{n}(x_{i})^{2}-2\cdot \sum _{i=1}^{n}(\mu \cdot x_{i})+n\cdot (\mu ^{2}))}
{\displaystyle ={\frac {1}{n}}(\sum _{i=1}^{n}(x_{i})^{2}-2\cdot \mu \cdot \sum _{i=1}^{n}(x_{i})+n\cdot (\mu ^{2}))={\frac {1}{n}}(S_{2}-2\cdot S_{1}/n\cdot S_{1}+n\cdot ((S_{1}/n)^{2}))={\frac {1}{n}}(S_{2}-(S_{1})^{2}/n)}
{\displaystyle \mu =S_{1}/n}
{\displaystyle S_{2}=\sum _{i=1}^{n}(x_{i}^{2})}
Similar to the estimation of the mean (
{\displaystyle \mu }
) and variance (
{\displaystyle Var}
), which requires the integral images of the first and second power of the image respectively (i.e.
{\displaystyle I,I^{2}}
); manipulations similar to the ones mentioned above can be made to the third and fourth powers of the images (i.e.
{\displaystyle I^{3}(x,y),I^{4}(x,y)}
.) for obtaining the skewness and kurtosis. But one important implementation detail that must be kept in mind for the above methods, as mentioned by F Shafait et al. is that of integer overflow occurring for the higher order integral images in case 32-bit integers are used.
Lewis, J.P. (1995). Fast template matching. Proc. Vision Interface. pp. 120–123.
Finkelstein, A neeratsharma (2010). . Wolfram Demonstration Project.
Crow, Franklin (1984).
(PDF). SIGGRAPH '84: Proceedings of the 11th annual conference on Computer graphics and interactive techniques. pp. 207–212.
Viola, P Jones, Michael (2002).
(PDF). International Journal of Computer Vision.
Tapia, Ernesto (January 2011). "A note on the computation of high-dimensional integral images". Pattern Recognition Letters. 32 (2). :.
Phan, T Sohoni, S Larson, Eric C.; Chandler, Damon M. (22 April 2012).
(PDF). 2012 IEEE Southwest Symposium on Image Analysis and Interpretation: 83. :.
Shafait, F Keysers, D M. Breuel, Thomas (January 2008).
(PDF). Electronic Imaging. :.
Lecture videos}

我要回帖

更多关于 canvas 绘制透明区域 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信