I have an image here (DMM_a01_s01_e01_sdepth.PNG, it is basically a human depth map or something, I don't really know the details :( ):
It's very small (54x102) so here is a visualization:
But when I tried to resize it to 20x20 using this piece of code that I've made:
from scipy import misc
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np
import math
import cv2
im = misc.imread('DMM_a01_s01_e01_sdepth.PNG')
def rgb2gray(rgb):
return np.dot(rgb[...,:3], [0.299, 0.587, 0.114])
if len(im.shape) ==3:
im = rgb2gray(im) # Convert RGB to grayscale
# Show image
plt.imshow(im, cmap = cm.Greys_r)
plt.show()
# Resize image
boxSize = 20
newImage= misc.imresize(im, (boxSize,boxSize), interp="bicubic")
plt.imshow(newImage, cmap = cm.Greys_r)
plt.show()
, the resized image is no longer the same as the orignal one:
How do I resize and still keep the structure of the image? Please help me, thank you very much :)