[M, N, ~] = size(im) why we use

 Accepted Answer

They just want to know the number of rows and columns and don't care how many higher dimensions there are.
For images that may possibly be gray scale or color, I do this:
[rows, columns, numberOfColorChannels] = size(yourImage)
Note how I used more descriptive variable names that your code did. For grayscale, numberOfColorChannels = 1. For RGB, numberOfColorChannels = 3.

More Answers (1)

Walter Roberson
Walter Roberson on 22 Sep 2018

0 votes

Read the documentation about size() again, paying attention to the definition of the output when you the number of output is less than the number of dimensions of the data.

2 Comments

zakir khan
zakir khan on 22 Sep 2018
Edited: Walter Roberson on 22 Sep 2018
~ asking about this sign for
example n is number of row and m is show number of column what dose this sing [M, N, ~] mean here

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!