I would like to recognize if a cell is infected by malaria or not (https://www.kaggle.com/iarunava/cell-images-for-detecting-malaria). But the pictures have different size, so I want to resize every image to the same size to be able to use my first layer (that has a static size)
How can I resize an image in Julia? Or can I just use flux to be able to compute image of different dimension?
You can do this with the packages Images
and ImageMagick
(you need to install both), and then:
using Images
download("https://juliaimages.org/latest/assets/logo.png","test.png");
img = Images.load("test.png");
size(img) # outputs (128, 128)
img2 = imresize(img,(50,50));
Images.save("test2.png",img2);
The file test2.png
has the size 50x50. More info about imsize
is available at:
https://juliaimages.org/latest/function_reference.html#Spatial-transformations-and-resizing-1
You would do this operation before hand (i.e. outside of Flux.jl) because otherwise the interpolation would need to be done at every time you compute the gradient.
The package Interpolations
would also allow you to resize the images. You would then interpolate the red, green, blue channels individually.
For the particular images of the kaggle challenge, padding the data with black pixels to a common size would also be an option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With