Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
94 views
in Technique[技术] by (71.8m points)

python - Keras: How does reprocessing scale images?

For loading image data from disk, Keras is providing the tf.keras.preprocessing.image_dataset_from_directory() method, which is documented on https://keras.io/api/preprocessing/image/. I would like to use this method to load data for generating a image classifier. https://machinelearningmastery.com/how-to-load-large-datasets-from-directories-for-deep-learning-with-keras/ contains some information on how to best organize the data.

The image_dataset_from_directory() takes a mandatory argument image_size=(..., ...) to give all images to the same size (which is required for further steps).
Where can I find details about how the pictures are scaled?
Would pictures with extreme ratios become distorted and negatively impact the classfier?

question from:https://stackoverflow.com/questions/65944097/keras-how-does-reprocessing-scale-images

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I was not able to find the specifics on how resize is done. However it probably uses one of the methods available in cv2 which are listed below but I do not know which one.

[optional] flag that takes one of the following methods. INTER_NEAREST – a nearest-neighbor interpolation INTER_LINEAR – a bilinear interpolation (used by default) INTER_AREA – resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method. INTER_CUBIC – a bicubic interpolation over 4×4 pixel neighborhood INTER_LANCZOS4 – a Lanczos interpolation over 8×8 pixel neighborhood

Of course when resized your images will become distorted. I do a lot of image classification and have not found this to be a problem. Beside that there appears to be no other choice but to have all the images be the same size.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...