**Prerequisite :** RGB image representation

MATLAB stores most images as two-dimensional matrices, in which each element of the matrix corresponds to a single discrete pixel in the displayed image. Some images, such as truecolor images, represent images using a three-dimensional array. In truecolor images, the first plane in the third dimension represents the red pixel intensities, the second plane represents the green pixel intensities, and the third plane represents the blue pixel intensities.

#### Image Resize using `imresize()`

:

Image resize changes the size of an image. There are two ways of using the imresize column. if the input image has more than two dimensions imresize only resizes the first two dimensions.

The method takes the input image`J = imresize(I, scale)`

:`I`

as input and a scaling factor and scales the input image with that factor. For eg. if we choose 0.5 as the scaling factor every two pixels in the original image is mapped to one pixel value in the output image for both the dimensions.The methods takes the number of rows and columns and fits the original input image to an output image having the specified number of rows and columns.`J = imresize(I, [numrows numcols])`

:

**Code #1: Read the image from file**

`% read image file ` `I = imread(` `'image.jpg'` `); ` ` ` `%display image size ` `size(I) ` ` ` `%display the image ` `figure, imshow(I); ` |

*chevron_right*

*filter_none*

**Output : **

ans = 371 660 3

**Code #2: Resize by scaling
**

`% compress the image and save ` `% in another variable ` `I1 = imresize(I, 0.5); ` ` ` `%display image size ` `size(I1) ` ` ` `%display the image ` `figure, imshow(I1); ` |

*chevron_right*

*filter_none*

**Output : **

ans = 186 330 3

**Code #3: Resize with specified rows and columns
**

`% resize by specifying rows ` `% and columns ` `I2 = imresize(I, [100, 200]); ` ` ` `%display image size ` `size(I2) ` ` ` `%display the image ` `figure, imshow(I2); ` |

*chevron_right*

*filter_none*

**Output : **

ans = 100 200 3

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

## Recommended Posts:

- Image Resizing using OpenCV | Python
- Node.js | Image Upload, Processing and Resizing using Sharp package
- MATLAB | RGB image to grayscale image conversion
- MATLAB | Converting a Grayscale Image to Binary Image using Thresholding
- Extract bit planes from an Image in Matlab
- Image Processing in MATLAB | Fundamental Operations
- MATLAB | RGB image representation
- MATLAB | Complement colors in a Binary image
- MATLAB | Complement colors in RGB Image
- MATLAB | Complement colors in a Grayscale Image
- MATLAB | Display histogram of a grayscale Image
- LSB based Image steganography using MATLAB
- Display the red, green and blue color planes of a color image in MATLAB
- Image Complement in Matlab
- Flip image across Secondary Diagonal in MATLAB
- Matlab | Edge Detection of an image without using in-built function
- Matlab | Erosion of an Image
- Matlab | Dilation of an Image
- Create Mirror Image using MATLAB
- How to vertically flip an Image using MATLAB

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.