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

digital image processing

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

Best 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.
Related Question