![]() |
VOOZH | about |
In digital image processing (DIP), image scaling refers to the resizing of a digital image. If we are increasing the size of an image then it means that we are scaling it up and if we are decreasing or making the image the smaller, then it means we are scaling it down. Here, we are scaling an image using R Programming language.
Image in use:
In this section, we will be scaling our image using R programming language. We can do it using two methods.
We will install OpenImageR package which has various functions for image preprocessing, filtering and image recognition.
The image to be resized is imported to the environment and the required resizing is done using image_scale() function. It is a helper function to draw scale for image. We will pass the image and the value as arguments in the function.
Syntax:
image_scale(img,"size")
The only difference in scaling up or down comes from the size value passed to image_scale() function. To scale up down pass a value smaller than 100 and to up scale a value greater than 100.
Example:
Output :
👁 Imagemagick is a package in R programming language that provides modern and simple toolkit for image processing. We will install magick package in our R environment.
The process completely similar to the above method the difference the package. Here, image_scale() function can also be used to resize image here too and can be deal with height and width at the same time.
Syntax:
image_scale( image_scale (image, "width"), "height")
Example:
Output:
👁 Image