I have image (JPG/JPEG) which looks like this:
As part of the tests, I decided to create an identical image while preserving the dimensions of the original image through the .resize
method of the OpenCV library. After the transformations, the image changes its original color.
image = numpy.asarray(bytearray(response.read()), dtype="uint8")
image = cv2.imdecode(image_file, cv2.IMREAD_COLOR)
image_height, image_width = image.shape[:2]
dimension = (image_width, image_height)
resized_image = cv2.resize(image, dimension, interpolation=cv2.INTER_LINEAR)
In a similar stackoverflow question, I found that OpenCV
uses BGR
. So I converted BGR
to RGB
with the code below. Unfortunately it returns me strange result.
image = numpy.asarray(bytearray(response.read()), dtype="uint8")
image = cv2.imdecode(image, cv2.IMREAD_COLOR)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
...