[M, N, ~] = size(im) why we use
3 views (last 30 days)
Show older comments
zakir khan
on 22 Sep 2018
Answered: Image Analyst
on 22 Sep 2018
[M, N, ~] = size(im) why we use
0 Comments
Accepted Answer
Image Analyst
on 22 Sep 2018
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.
For a thorough explanation see Steve's blog: https://blogs.mathworks.com/steve/2011/03/22/too-much-information-about-the-size-function/
0 Comments
More Answers (1)
Walter Roberson
on 22 Sep 2018
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
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!