I am always used to C ++ programming. The sequence of access to three-dimensional image data is as follows: column, row, and layer. The symbols are X, Y, Z, I, J, and K.
This is also true for three-dimensional medical images.
For (INT z = 0; Z <nslice; Z ++)
For (INT y = 0; y <nheight, y ++)
For (INT x = 0; x <nwidth, X ++)
{
// Volume (z * nheight * nwidht + y * nwidht + x)
........
}
Of course, for common BMP images collected by CCD, two-dimensional, 768*576 (row * column), in order to cycle large layers, column loops are also available first.
For (int w = 0; W <nwidth; W ++)
For (INT h = 0; H <nheiht, H ++)
{...
Pimage (H * nwidht + W)
}
In any case, C ++ stores data first.
But in MATLAB, it is the opposite ....
[H, w] = size (image ),
The first parameter is the row and the second parameter is the column. This applies to many cases (line,
Column. Remember not to reverse it.
I = zeros (H, W ),
It also produces H rows and W columns ....
The image matrix reads I (I, j), which is also the number of column J in row I.
>
I = rand (2, 4)
I =
0.8147 0.1270 0.6324 0.2785
0.9058 0.9134 0.0975 0.5469
> [H, w] = size (I)
H =
2
W =
4
In short, Matlab storage is first column storage.