How to Change Image Size in Julia
Resizing Images
To resize images, you can use the imresize
function from the Images
package. The function name is the same as in Matlab.
imresize(X, ratio=a)
: Returns the image of array X scaled by a factor of a. Unlike Matlab, you must explicitly writeratio=a
.imresize(X, m, n)
: Returns the image of array X resized to m rows and n columns. Below are example codes and their results.
using Images
X=load("example\_{i}mage2.jpg")
Y1=imresize(X, ratio=0.5)
Y2=imresize(X,500,500)
Y3=imresize(X,1500,1500)
Y4=imresize(X,700,1000)
Y5=imresize(X,1000,1300)
Y6=imresize(X,300,300)
save("X.png",colorview(RGB,X))
save("Y1=imresize(0.5).png",colorview(RGB,Y1))
save("Y2=imresize(500,500).png",colorview(RGB,Y2))
save("Y3=imresize(1500,1500).png",colorview(RGB,Y3))
save("Y4=imresize(700,1000).png",colorview(RGB,Y4))
save("Y5=imresize(1000,1300).png",colorview(RGB,Y5))
save("Y6=imresize(300,300).png",colorview(RGB,Y6))
See Also
Environment
- OS: Windows10
- Version: 1.5.3 (2020-11-09)