Help to understand Matlab code

1 Ansicht (letzte 30 Tage)
Matlab Student
Matlab Student am 23 Okt. 2018
Kommentiert: jonas am 23 Okt. 2018
Hello Matlab Experts,
I am trying to understand this Matlab code, I am stuck at few lines:
% get resolution and number of band
[m n ~]=size(im);
if length(size(im))==3
b=size(im,3);
else
b=1;
end
[m n ~] = size(im) I know size(im) should return the height and width of an image, but what does ~ mean? I have reviewed size documentation but did not find the answer: https://www.mathworks.com/help/matlab/ref/size.html
Also, I need assistance to understand these two lines as well. As per Matlab documentation, szdim = size(A,dim) returns the length of dimension dim. Does this mean size(im,3) return the depth of image pixels?
if length(size(im))==3
b=size(im,3);
Thanks in advance,

Akzeptierte Antwort

jonas
jonas am 23 Okt. 2018
Bearbeitet: jonas am 23 Okt. 2018
[m n ~] = size(im)
~ basically means "omit this output", and is totally useless in this context. It is useful in other cases, for example if you're only interested in the second output.
[~,out] = func(...)
"Does this mean size(im,3) return the depth of image pixels?"
yes
  2 Kommentare
Matlab Student
Matlab Student am 23 Okt. 2018
Thanks Jonas.
What about length(size(im))? Does length(size(im)) equals to 2 if im is a two dimensional array, and equals to 3 if im is an image with Height Width and Depth?
jonas
jonas am 23 Okt. 2018
My pleasure! Yep, thats correct.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by