EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Matlab Tutorial Matlab Image Resize
 

Matlab Image Resize

Priya Pedamkar
Article byPriya Pedamkar

Updated June 17, 2023

Matlab Image Resize

 

 

Introduction to Matlab Image Resize

MATLAB is designed to store most of the images in the form of two-dimensional matrices. Each element corresponds to a distinct, discrete pixel in the matrices in any stored image. The Image Processing Toolbox software available in MATLAB supports several operations that can be performed on images. The function of resizing images is one of those functionalities. Resizing any 2D image in MATLAB can be performed using the resize () procedure, whereas imresize3() is used for resizing 3-D volumetric intensity images.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Syntax Description
ImgOut = imresize(Img,scale) This syntax is used to result in an image ImgOut which is a scaled-up version of the input image Img with respect to its size. The input image Img can be of type binary, grayscale, categorical image, or RGB.

Resizing an image using a GPU is optional for this syntax.

ImgOut= imresize(Img,[row_numcol_num]) This syntax results in an image ImgOut created with a number of rows and columns specified by the input argument vector.
[ImgOut,newmap] = imresize(Img,map,___) This syntax results in the resized form of the indexed image Img with the colormap map presented by ImgOut. By default, imresize results in an optimized colormapi.enewmap, along with the resized indexed image ImgOut. In order to result in the same colormap as that of the original colormap, the Colormap name-value pair argument needs to be used.

 

___ = imresize(___,method) This syntax results in a resized image with the interpolation method being specified.
___ = imresize(___,Name,Value) This syntax results in resized images being customized by means of name-value pair arguments to control different aspects of the resizing operation. Application of this syntax on a GPU is not supported.

Examples of Matlab Image Resize

There are different ways in which an image can be resized in a MATLAB program. They are:

1. Resizing using Magnification Value

The image can be magnified or shrunk by a specific factor mentioned within the imresize() command.

Code:

Img = imread('MyIMage.png');% Reading input image from workspaceimshow(Img) %Showing given image on the output windowtitle('Original Image')Out = imresize(Img,0.5);imshow(Out)title(' Resized Image') axis off

Output:

Matlab Image Resize - 1

2. Resizing using fixed dimension Value

The image can be magnified or shrink to definite dimensions, mentioned within the imresize() command.

Code:

Img = imread('MyCircuit.png');imshow(Img)Out = imresize(Img,[100 150]);imshow(Out)axis off

Output:

Matlab Image Resize - 2

3. Resizing using the specific interpolation method

The image can be magnified or shrink using a specific interpolation method mentioned within the imresize() command.

Code #1

Img = imread('MyIMage.png');imshow(Img)Out = imresize(Img,0.5, 'nearest'); %Applying the interpolation method ‘nearest-   %neighbor’imshow(Out)axis off

Output:

Matlab Image Resize - 3

Note: It brings fewer pixels to the output image. This can introduce artifacts such as aliasing that can get introduced in the process. The aliasing which occurs due to a reduction in size normally appears in stair-step patterns, mostly in the case of high-contrast images. In contrast, it can also appear in the form of more (ripple-effect) patterns in the resultant output image.

Code #2

Img = imresize(I,.75,'Antialiasing’, false);figure, imshow(Img)

Output:

Matlab Image Resize - 4

4. Resizing indexed images

An indexed image specified in the form of a numerical array can be magnified or shrink using a scaling factor mentioned within the imresize() command.

Code:

[M, map] = imread('trees.png');
[O, newmap] = imresize(M, map, 0.5);
figure
imshow(X,map)
figure
imshow(Y,newmap)

Output:

indexed

5. Resizing RGB Image to the Specified Size of Output Image

An RGB image specified can be magnified or shrink to a definite dimention, mentioned within the imresize() command.

Code:

RGB = imread('trees.png');
RGBOut = imresize(RGB, [64 NaN]);
figure
imshow(RGB,map)
figure
imshow(RGBOut,newmap)

Output:

Specified Size

Input Arguments and Attributes

Below is the table explaining arguments and attributes:

Attribute/Argument Description Probable Values
Scale It acts as Resizing factor by which the original image size gets changed. 0>val<1 or val>1
[numrowsnumcols] This vector decides the number of rows and columns in which the resultant image should be created. NaN or any positive integer
map This attribute is associated with an indexed image presenting a color map for the same. Values are in the range [0,1]
Method This attribute talks about the Interpolation method or kernel to be used in the resizing operation. Methods: nearest, bilinear, bicubic Kernel: box, triangle,cubic,lanczos2, lanczos3
Antialiasing The “antialiasing” attribute determines whether an antialiasing effect is applied to the output image when the input image undergoes shrinking or reduction in size. True/False
Colormap This output parameter returns a value of an optimized or original colormap with respect to the indexed image. Original/optimized
Dither The “color dithering” attribute is used to apply a form of noise to the image during the quantization process, which helps randomize and minimize quantization errors. True/False
Newmap This attribute is used for Optimized colormap. [0,1]

Additional Note

Below are the points explain additional information:

  • The operation of imresize() method is carried out either by CPU or GPU. There is a numerical difference between the results of imresize that occurs on the bottom and rightmost borders of the resultant image.
  • In the case of the resultant image not having size with an integer value, the imresize() function does not use the specified scaling factor. Imresize() uses ceil while calculating the size of the output image.
  • If the input image has more than two dimensions, imresize() supports resizing operations only to the first two dimensions.

Recommended Articles

This is a guide to Matlab Image Resize. Here we discuss an introduction to Matlab Image Resize, syntax with attributes, and examples to resize images. You can also go through our other related articles to learn more –

  1. Optimset Matlab
  2. MATLAB Indexing
  3. Linear Fit Matlab
  4. Find Function Matlab

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW