
I tried to use OpenCV as well but I was getting an Assertion Error i.e error: OpenCV(3.4.3) /io/opencv/modules/imgproc/src/resize.cpp:4044: error: (-215:Assertion failed) !ssize.empty() in function 'resize'įrom keras. from PIL import Image import numpy as np import pandas as pd import os import cv2 import keras from keras.models import Sequential from keras.layers import Conv2D,MaxPooling2D,Dense,Flatten,Dropout import matplotlib.pyplot as plt imageImage.open ('./content/cellimages/Parasitized/'+i) sizeimage image.resize ( (50, 50)) print ('image') plo. Why is the image coming out the way it is? and what can be done to fix it? If a possible solution is present in OpenCV that'd be welcome as well. However I found out that image opened was blurry as opposed to the original image.

The original library has been forked multiple times and some of these branches widened the functionality or improved image processing performance.

#Python pil image resize quality how to
Also explained is how to resize and crop Python images with Cloudinary through automation. qualityval 90 image.save (filename, 'JPEG', qualityqualityval) Take a look at the source for models.py from Photologue to see how they do it. This article describes how to resize images in bulk with the Pillow library, a popular fork of the Python Imaging Library (PIL) and, to maintain the quality and aspect ratio, in OpenCV, a robust library of programming functions for computer vision.

I was using PIL library to open an image and then convert it into array later on for DL operations. You can resize, apply Python image compression for JPEGs and other lossy formats, and perform other types of image manipulations with it. Use PIL's resize method manually: image image.resize ( (x, y), Image.ANTIALIAS) LANCZOS as of Pillow 2.7.
