size() for images

77 ビュー (過去 30 日間)
Arya k
Arya k 2015 年 12 月 13 日
編集済み: DGM 2024 年 1 月 19 日
readImage1=imread(image_file1);
m = size(readImage1);
what does mean by the second line of the code ?
  1 件のコメント
Gopolang
Gopolang 2023 年 5 月 13 日
the dimensions of the image

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

採用された回答

Stephen23
Stephen23 2015 年 12 月 13 日
編集済み: Stephen23 2020 年 10 月 29 日
The size documentation tells us:
" d = size(X) returns the sizes of each dimension of array X in a vector, d, with ndims(X) elements."
You can also very easily try that line in order to find out what it does: load an image and try size and see what it outputs, like this:
>> X = imread('parula_0.png');
>> V = size(X)
V =
420 560 3
This tells us that my image (an array of numbers), is 420 pixels high and 560 pixels across, and contains 3 pages, one for each of R, G and B. It is worth noting that the syntax
[A,B] = size(X);
does NOT return the rows and columns of a 3D (e.g. image) array. Read the size documentation to know why.
  3 件のコメント
Stephen23
Stephen23 2020 年 10 月 29 日
編集済み: Stephen23 2020 年 10 月 29 日
"What do you mean by 3 pages? I dont understand what the third dimension is"
The MATLAB documentation
defines names for the first three dimensions of an array:
  1. row
  2. column
  3. page
These are the first three dimensions of any array:
X(row,column,page,...)
RGB images are most commonly represented using RxCx3 arrays, where the third dimension encodes the three color channels red, green, and blue:
Note that all arrays implicitly have infinite trailing singleton dimensions:
DGM
DGM 2024 年 1 月 19 日
編集済み: DGM 2024 年 1 月 19 日

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by