Reg:访问3d矩阵的元素 [英] Reg: Accessing elements of 3d matrix
问题描述
大家好,
实际上,我已经从其子标题中读取了一个图像的数据文件,将数据存储在缓冲区中。* imdata是指向数据缓冲区的指针。数据大小为100x100x81,没有。每个像素的字节数是4个字节,格式类型是浮点数。现在我必须阅读第三维中第40行的所有rowa和列。我的问题是如何通过这个指针imdata访问它。在此先感谢。
imsize_x = 100;
imsize_y = 100;
imsize_z = 81;
nobytesperpixel = 4;
我想得到z = 40的所有元素100x100。
Hi all,
Actually, I have read a data file of an image from its sub header stored the data in a buffer.*imdata is a pointer to the buffer for data. The data size is 100x100x81 and no. of bytes per pixel is 4 bytes and the format type is float. Now I have to read all the rowa and columns of 40th row in 3rd dimension. My problem is how to access it through this pointer imdata. Thanks in advance.
imsize_x=100;
imsize_y=100;
imsize_z=81;
nobytesperpixel=4;
I want to get all the elements 100x100 of z=40.
推荐答案
我有点困惑您的问题。
您是否拥有值z = 40并且您想要访问与此值相关的另一组数据?
I am a little confused by your question.
Is it that you have the value z=40 and you want to access another set of data that relates to this value?
您好willakawill,
对不起,如果我清楚了。我只是给你一个我的意思的例子。
例如:a [3] [ 3] [2]
a [] [] [1] = {2,3,4; 1,2,3; 4,5,6};
a [] [] [2] = {1,1,1; 2,2,2; 3,3, 3};
现在我想访问[] [] [2]的所有行和列;
这里我如前所述* imdata指向这个数据缓冲区的指针。现在我想使用imdata访问这些元素,例如:a [] [] [40]。
Hi willakawill,
Sorry if I anot clear.I am just giving you an example of what I meant.
For eg: a[3][3][2]
a[ ][ ][1]={2,3,4; 1,2,3;4,5,6};
a[ ][ ][2]={1,1,1;2,2,2;3,3,3};
Now I would like to access all the rows and columns of a[ ][ ][2];
Here I have pointer to this buffer of data as I have mentioned before *imdata.So now I want to access these elemnts for eg: a[ ][ ] [40] using imdata.
使用两个for循环,使用索引迭代矩阵的前两个维度,在读取数据时迭代40。这样的事情:
Using two for loops, iterate through the first two dimensions of the matrix, using the indexes and 40 when reading data. Something like this:
这篇关于Reg:访问3d矩阵的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!