C ++编程中的问题 [英] problem in c++ programing
问题描述
嗨
我正在处理一个图像处理项目.我可以理解matlab程序,但是C ++存在一些问题.
我找到了一个用于计算直方图的C ++程序,但是我不理解其中的某些指令,例如:
int index = x + y *(texture.Ptr()-> width);
和
curTextureHist [index] .r [i] = 0;
或
curTextureHist [index] .r [texture(y + j,x + i,2) ] ++;
...
您知道它们的意思吗?
在此程序中.
void 直方图(RgbImage& Texture,TextureHistogram * curTextureHist)
{
// 计算2 * REGION_R正方形内的直方图
for ( int y = REGION_R + TEXTURE_R; y < texture.Ptr()-> height-REGION_R-TEXTURE_R; ++ y)
{
for ( int x = REGION_R + TEXTURE_R; x >< texture.Ptr()-> width-REGION_R-TEXTURE_R; ++ x)
{
int index = x + y *(texture.Ptr()-> width);
// 清除直方图
for ( int i = 0 ; i < NUM_BINS; ++ i)
{
curTextureHist [index] .r [i] = 0 ;
curTextureHist [index] .g [i] = 0 ;
curTextureHist [index] .b [i] = 0 ;
}
// 计算直方图
for ( int j = -REGION_R; j >< = REGION_R; ++ j)
{
for ( int i = -REGION_R; i >< = REGION_R; ++ i)
{
curTextureHist [index] .r [texture(y + j,x + i, 2 )] ++;
curTextureHist [index] .g [texture(y + j,x + i, 1 )] ++ ;;
curTextureHist [index] .b [texture(y + j,x + i, 0 )] ++ ;;
}
}
}
}
}
报价:int index = x + y *(texture.Ptr()-> width);
将(一维)
index
设置为(二维)位置(x,y)
.那是i = x + y * width;
.
报价:curTextureHist [index] .r [i] = 0;
设置
index
中位于index
处的curTextureHinst
对象等于零.
报价:curTextureHist [index] .r [texture(y + j,x + i,2)] ++;
递增具有
curTextureHinst
对象的索引等于texture(y+j,x+i,2)
(其中texture
是函数)的r分量(r=r+1;
).
>
Hi
I am working on a image processing project.I can understand matlab program but i have some problem with C++.
I found a C++ program for calculating histogram.But i don''t understand some of instruction in it.for example:
int index = x+y*(texture.Ptr()->width);
and
curTextureHist[index].r[i] = 0;
or
curTextureHist[index].r[texture(y+j,x+i,2)]++;
...
do u know the mean of them.
in this program.
void Histogram(RgbImage& texture, TextureHistogram* curTextureHist)
{
// calculate histogram within a 2*REGION_R square
for(int y = REGION_R+TEXTURE_R; y < texture.Ptr()->height-REGION_R-TEXTURE_R; ++y)
{
for(int x = REGION_R+TEXTURE_R; x < texture.Ptr()->width-REGION_R-TEXTURE_R; ++x)
{
int index = x+y*(texture.Ptr()->width);
// clear histogram
for(int i = 0; i < NUM_BINS; ++i)
{
curTextureHist[index].r[i] = 0;
curTextureHist[index].g[i] = 0;
curTextureHist[index].b[i] = 0;
}
// calculate histogram
for(int j = -REGION_R; j <= REGION_R; ++j)
{
for(int i = -REGION_R; i <= REGION_R; ++i)
{
curTextureHist[index].r[texture(y+j,x+i,2)]++;
curTextureHist[index].g[texture(y+j,x+i,1)]++;
curTextureHist[index].b[texture(y+j,x+i,0)]++;
}
}
}
}
}
Quote:int index = x+y*(texture.Ptr()->width);
sets the (unidimensional)
index
to (bidimensional) position(x,y)
. That isi = x + y * width;
.
Quote:curTextureHist[index].r[i] = 0;
Sets the
r[i]
(red RGB component) of thecurTextureHinst
object atindex
equal to zero.
Quote:curTextureHist[index].r[texture(y+j,x+i,2)]++;
Increments the r component (
r=r+1;
), having index equal totexture(y+j,x+i,2)
,(wheretexture
is a function) of thecurTextureHinst
object.
这篇关于C ++编程中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!