MATLAB: How to read an image into matlab and calculate the horizontal number of pixels and the vertical number of pixels

horizontal pixels

I need to read a color image into a .m file and calculate the number of horizontal & vertical pixels of the image and display the results. I can read the image with A = imread(filename); and show the image(A); but I can't figure out how to calculate the horizontal and vertical pixels. The total number of pixels is the vertical multiplied by the horizontal.

Best Answer

Try this:
[rows, columns, numberOfColorChannels] = size(yourImage);
That should give you everything you need.