size() for images

K
Konner · Oct 30, 2020 · 1.9K views
Question
readImage1=imread(image_file1); m = size(readImage1); what does mean by the second line of the code ?
Expert Answer
Profile picture of Neeta Dsouza
Neeta Dsouza PhD Expert
Answered Aug 24, 2026
" d = size(X) returns the sizes of each dimension of array X in a vector, d, with ndims(X) elements."
You can also very easily try that line in order to find out what it does: load an image and try size and see what it outputs, like this:
 
>> X = imread('parula_0.webp');
>> V = size(X)
V =
   420   560     3

This tells us that my image (an array of numbers), is 420 pixels high and 560 pixels across, and contains 3 pages, one for each of R, G and B. It is worth noting that the syntax

[A,B] = size(X);

 

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!