採用された回答

Image Analyst
Image Analyst 2013 年 7 月 5 日

10 投票

That's a dimension that has a length of 1. For example, if you had a 3D image that is 400 rows by 1 column by 200 slices, the second dimension (columns) would be a singleton since it's one. You'd have only one image plane running in the y-z direction (rows-slices). You can get back to a 2D image by using squeeze() to remove the singleton dimension.

4 件のコメント

Minions
Minions 2020 年 11 月 16 日
is there any example of this?
Image Analyst
Image Analyst 2020 年 11 月 16 日
Try this:
% Create a 3-D matrix with 2 rows, 4 columns, and 3 slices:
M3d = randi(9, 2, 4, 3)
% Extract slice 2. No singleton dimension since we're extracting the last index.
slice2 = M3d(:, :, 2) % Size is 2x4
whos slice2
% Extract slice that is essentially pulling the matrix
% that represents column 2 from the rectangular block.
% There will be a singleton dimension since we're NOT extracting the last index.
slice3 = M3d(:, 2, :) % Size is 2x1x3
whos slice3
% Run squeeze on slice 3 to get a 2x3 matrix, which is what you really wanted.
slice3a = squeeze(slice3)
whos slice3a
You get:
M3d(:,:,1) =
2 4 6 9
1 7 5 1
M3d(:,:,2) =
5 5 6 4
2 6 2 3
M3d(:,:,3) =
6 7 6 4
6 2 7 4
slice2 =
5 5 6 4
2 6 2 3
Name Size Bytes Class Attributes
slice2 2x4 64 double
slice3(:,:,1) =
4
7
slice3(:,:,2) =
5
6
slice3(:,:,3) =
7
2
Name Size Bytes Class Attributes
slice3 2x1x3 48 double
slice3a =
4 5 7
7 6 2
Name Size Bytes Class Attributes
slice3a 2x3 48 double
Swati Sarangi
Swati Sarangi 2020 年 11 月 20 日
@Image Analyst
I've a doubt here, M3d = randi(9, 2, 4, 3)
What does '9' indicate in the above command?
Image Analyst
Image Analyst 2020 年 11 月 20 日
That is the max value that the random numbers in the 2-by-4-by-3 three-D matrix can take on. Did you look up randi in the help documentation? It describes it there.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by