how to take images from list resize and scale pixel value between 0 to 1 using open CV

216 Views Asked by At

I have the following code that I thought would resize and scale the pixel value between 0 to 1, but when I run the code the output image that I am getting is not the same as the original one after resizing, kindly refer to the image for the output and code. your valuable feedbacks will b highly appreciated. thanks in advance

from PIL import Image
import matplotlib.pyplot as plt
from os import listdir
from os.path import isfile,join
import numpy
import numpy as np
import cv2
import os
import glob
import sys
import time

#read multiple images
mypath ="C:\\Users\\IIIT Dharwad\\Desktop\\images"
onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ]
images = numpy.empty(len(onlyfiles), dtype=object)
for n in range(0, len(onlyfiles)):
  images[n] = cv2.imread( join(mypath,onlyfiles[n]) )
  print("pixel values of",n)
  images[n].resize(254,254)
  print(images[n].shape)
  print(images[n]/255)
  plt.imshow(images[n])
  time.sleep(3)
0

There are 0 best solutions below