EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login
Home Data Science Data Science Tutorials Matlab Tutorial Matlab Image Resize
Secondary Sidebar
Matlab Tutorial
  • Functions
    • MATLAB Functions
    • MATLAB user defined function
    • Calling Functions in MATLAB
    • Transfer Functions in MATLAB
    • Anonymous Functions in MATLAB
    • Inline Functions in MATLAB
    • Bessel Functions in MATLAB
    • Mean Function in MATLAB
    • Find Function MATLAB
    • Filter Function in MATLAB
    • IIR Filter MATLAB
    • Piecewise Function in MATLAB
    • Sum Function in MATLAB
    • Simulink MATLAB Function
    • MATLAB Create Function
    • MATLAB Inverse Function
    • MATLAB Count
    • Step Function MATLAB
    • MATLAB limit
    • Fminsearch in MATLAB
    • Covariance in MATLAB
    • Summation in MATLAB
    • Linear Fit MATLAB
    • MATLAB?linear regression
    • MATLAB Derivative
    • MATLAB Derivative of Function
    • MATLAB Comet()
    • Fzero MATLAB
    • xlabel MATLAB
    • Matplotlib Legend
    • Matplotlib Subplots
    • Plot graph MATLAB
    • MATLAB Format
    • MATLAB plot title
    • Multiple Plots in MATLAB
    • MATLAB Indexing
    • Ceil MATLAB
    • Curve Fitting MATLAB
    • MATLAB trapz()
    • MATLAB Normalize
    • MATLAB diff
    • MATLAB sym()
    • MATLAB Syms
    • Absolute Value MATLAB
    • MATLAB Exponential
    • Kalman Filter MATLAB
    • Low Pass Filter MATLAB
    • Bandpass Filter MATLAB
    • MATLAB Unique
    • Trapezoidal Rule MATLAB
    • MATLAB Root Finding
    • MATLAB stem()
    • MATLAB loglog()
    • MATLAB Autocorrelation
    • MATLAB Sort
    • Simplify MATLAB
    • Cumsum MATLAB
    • Eval Function MATLAB
    • Polyval MATLAB
    • MATLAB Colon
    • MATLAB Eigenvalues
    • MATLAB fit
    • Delta Function MATLAB
    • MATLAB Remainder
    • Differentiation in MATLAB
    • Permute MATLAB
    • isempty MATLAB
    • MATLAB text()
    • MATLAB Display Text
    • Varargin in MATLAB
    • MATLAB gca
    • MATLAB fill()
    • MATLAB pcolor()
    • MATLAB min
    • MATLAB xcorr
    • MATLAB? color codes
    • Semilogy MATLAB
    • MATLAB? eye
    • feval MATLAB
    • num2str in MATLAB
    • MATLAB Images
    • MATLAB Image? Segmentation
    • Imagesc MATLAB
    • MATLAB Image Processing
    • MATLAB Image Resize
    • MATLAB Flag
    • MATLAB fopen
    • Strcmp MATLAB
    • MATLAB fwrite
    • MATLAB fft()
    • MATLAB zeros()
    • MATLAB textread
    • Arctan MATLAB
    • MATLAB Scripts
    • Butterworth filter MATLAB
    • MATLAB Findpeaks
    • MATLAB find Index
    • MATLAB Cell
    • MATLAB Unit Step Function
    • MATLAB Backslash
    • MATLAB Mod
    • Size Function in MATLAB
    • Secant MATLAB
  • Basic
    • MATLAB Area Under Curve
    • MATLAB not equal
    • MATLAB max
    • MATLAB exist
    • MATLAB Table
    • MATLAB regression
    • MATLAB Lists
    • MATLAB quantile
    • MATLAB Round
    • MATLAB readtable
    • MATLAB disp
    • MATLAB Standard Deviation
    • MATLAB quadprog
    • MATLAB Transpose
    • Introduction to MATLAB
    • Advantages of MATLAB
    • MATLAB Features
    • Taylor Series MATLAB
    • MATLAB Z Transform
    • fsolve in MATLAB
    • MATLAB QR
    • Career in MATLAB
    • Uses Of MATLAB
    • MATLAB Free
    • How to Install MATLAB
    • How to Use MATLAB?
    • MATLAB Version
    • MATLAB Compiler
    • MATLAB Commands
    • MATLAB Block Comment
    • MATLAB? sprintf
    • MATLAB fprintf
    • Data Types in MATLAB
    • MATLAB Integral
    • MATLAB Double Integral
    • MATLAB boolean
    • MATLAB vpa
    • MATLAB Object
    • MATLAB Annotation
    • MATLAB Variables
    • MATLAB Global Variables
    • MATLAB Operators
    • MATLAB Logical Operators
    • MATLAB nan
    • MATLAB Patch
    • MATLAB AND Operator
    • MATLAB OR Operator
    • Vectors in MATLAB
    • What is Simulink in MATLAB
    • MATLAB Interpolation
    • MATLAB Imread
    • fscanf MATLAB
    • Euler Method MATLAB
    • Root Locus MATLAB
    • MATLAB return
    • Bode Plot MATLAB
    • Nargin MATLAB
    • MATLAB Matrix Inverse
    • MATLAB String to Number
    • MATLAB string
    • MATLAB ColorBar
    • MATLAB Surfc
    • MATLAB Concatenate
    • NUMEL MATLAB
    • MATLAB? File Extension
    • MATLAB File
    • MATLAB Smooth
    • MATLAB ones
    • Exponential in MATLAB
    • MATLAB ksdensity
    • MATLAB log
    • MATLAB Append
    • MATLAB hold on
    • MATLAB Magnitude of Vector
    • Heatmap in MATLAB
    • MATLAB xticks
    • MATLAB randn
  • Control Statements
    • IF-Else Statement in MATLAB
    • If Statement in MATLAB
    • Loops in MATLAB
    • For Loop in MATLAB
    • While Loop in MATLAB
    • do while loop in MATLAB
    • Nested Loop in MATLAB
    • Switch Statement in MATLAB
    • Break in MATLAB
  • Matrix
    • Matrix in MATLAB
    • 3D Matrix in MATLAB
    • Transpose Matrix MATLAB
    • Sparse Matrix in MATLAB
    • Matrix Multiplication in MATLAB
    • Identity Matrix in MATLAB
    • MATLAB?writematrix
  • Advanced
    • MATLAB Class
    • Arrays in MATLAB
    • Matlab find value in array
    • MATLAB Grader
    • Power Spectral Density MATLAB
    • Matlab Textscan
    • String Array in MATLAB
    • MATLAB Random Numbers
    • Matlab Dot
    • MATLAB 2D Array
    • MATLAB? zero padding
    • MATLAB sort matrix
    • MATLAB Plot Function
    • 2D Plots in MATLAB
    • 3D Plots in MATLAB
    • MATLAB Fread
    • Spectrogram MATLAB
    • MATLAB Average
    • MATLAB exponent
    • MATLAB not enough input arguments
    • MATLAB comment
    • MATLAB zpk
    • Scatter Plots in MATLAB
    • MATLAB 3d scatter plot
    • Bar Graph in MATLAB
    • Bar Plot MATLAB
    • Log Plot MATLAB
    • Polar Plot in MATLAB
    • Surface Plot in MATLAB
    • MATLAB Plot Circle
    • Boxplot in MATLAB
    • MATLAB Plot Multiple Lines
    • Linspace MATLAB
    • Histogram in MATLAB
    • Plot Vector MATLAB
    • MATLAB Legend
    • MATLAB Plot Legend
    • MATLAB ezplots
    • Column Vector MATLAB
    • MATLAB Plot Marker
    • MATLAB LineWidth
    • MATLAB Line Style
    • Contour plot in MATLAB
    • MATLAB Sine Wave
    • Reshape in MATLAB
    • Natural Log in MATLAB
    • Random Number Generator in MATLAB
    • Complex Numbers in MATLAB
    • MATLAB Figure
    • Heatmap in MATLAB
    • MATLAB Technical Computing
    • Colors in MATLAB
    • Colormap in MATLAB
    • MATLAB Plot Colors
    • MATLAB fplot()
    • MATLAB Stacked Bar
    • MATLAB sphere()
    • MATLAB cylinder()
    • MATLAB mesh()
    • Pie Chart in MATLAB
    • MATLAB Gradient
    • Grid on MATLAB
    • Repmat in MATLAB
    • dlmread in MATLAB
    • Meshgrid in MATLAB
    • MATLAB Struct
    • MATLAB Cross Product
    • MATLAB colorbar Label
    • MATLAB Save Variable
    • MATLAB Saveas
    • MATLAB Cell Array
    • Polynomial in MATLAB
    • ismember MATLAB
    • Heaviside MATLAB
    • MATLAB rref
    • MATLAB polyfit()
    • MATLAB xlim
    • MATLAB Variance
    • Optimset MATLAB
    • Quiver MATLAB
    • Newton Raphson MATLAB
    • Mat2cell MATLAB
    • Magnitude MATLAB
    • format long MATLAB
    • Dot Product MATLAB
    • Jacobian MATLAB
    • What is Matlab?
    • Convolution MATLAB
    • Moving Average MATLAB
    • Fourier Series MATLAB
    • Gaussian Fit MATLAB
    • Bisection Method MATLAB
    • Laplace Transform MATLAB
    • Fourier Transform MATLAB
    • Signal Processing MATLAB
    • MATLAB Forms
    • Complex Conjugate MATLAB
    • MATLAB Write to File
    • uigetfile MATLAB
    • MATLAB Toolbox
    • MATLAB Errorbar
    • MATLAB Index Exceeds Matrix Dimensions
    • Nyquist MATLAB
    • Impulse Response MATLAB
    • xlsread MATLAB
    • MATLAB xlswrite
    • Matplotlib Scatter
    • MATLAB Import Data
    • MATLAB Export Data
    • MATLAB Read CSV
  • Programs
    • Square Root in MATLAB
    • Square Wave MATLAB
    • Squeeze MATLAB
    • Factorial in MATLAB
    • Cell to String MATLAB
  • Interview Questions
    • MATLAB Interview Questions

Matlab Image Resize

By Priya PedamkarPriya Pedamkar

Matlab Image Resize

Introduction to Matlab Image Resize

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

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

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

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

ImgOut= imresize(Img,[row_numcol_num]) This syntax is used to result an image ImgOut created with number of rows and columns specified by the input argument vector
[ImgOut,newmap] = imresize(Img,map,___) This syntax is used to result resized form of the indexed image Img with 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 the same colormap as that of the original colormap, the Colormap name-value pair argument needs to be used.

Application of this syntaxon a GPU is not supported.

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

Examples to 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 shrink by a specific factor mention 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 usingfixed 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: During the resizing operation to shrink the image, the size of an image gets reduced resulting in loss of some of the original pixels. 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 as a result of a reduction in size normally appears in stair-step patterns mostly in case of high-contrast images whereas it can also appear in the form of more (ripple-effect) patterns in the resultant output image.

By default, imresize() has an antialiasing feature turned on in order to limit the impact of aliasing for the output image for all interpolation types except for the method ‘nearest- neighbor’. The antialiasing can be turned off by specifying the ‘Antialiasing’ parameter having value as False.

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 are the table explain 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 indexed image presenting color map for the same. Values are in the range [0,1]
Method This attribute talks about Interpolation method or kernel to be used in the resizing operation. Methods: nearest, bilinear, bicubic Kernel: box, triangle,cubic,lanczos2, lanczos3
Antialiasing The attribute decides on enabling an antialiasing effect on the output image when the input image is subjected to be shrink. True/False
Colormap This output parameter returns a value of an optimized or original colormap with respect to the indexed image. Original/optimized
Dither This attribute is used to perform color dithering. In this process, a form of noise is applied to the image in order to randomize quantization error as well as to prevent large-scale patterns. True/False
Newmap This attribute is used for Optimized colormap. [0,1]

Additional Note

Below are the points explain additional information:

  • The function imresize()has been introduced in version 5.4 (R2007a). In earlier versions of the Image Processing Toolbox™, a different algorithm is being used by default. If the same results are expected to be produced by the previous version programming, instead of the function imresize(), the function imresize_old() needs to be adapted.
  • 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. But this can be barely noticed by the naked eyes.
  • In 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, then imresize() supports performing resizing operation 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, 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
Popular Course in this category
MATLAB Training (3 Courses, 1 Project)
  3 Online Courses |  1 Hands-on Project |  8+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

R Programming Training (13 Courses, 20+ Projects)4.9
All in One Data Science Bundle (360+ Courses, 50+ projects)4.8
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - 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

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*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?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more