imagematlabopencvvlfeat

Conversion of Image to Single and Square


I am performing a descriptor function on an image. In the documentation, the function requires me to input image I -

I is a gray-scale square image with odd side length of class SINGLE.

I already knew how to convert an image matrix to single using single(I), but I am not able to understand what is the meaning of a square image with odd side length, is it asking me to input a square image or is it related to matrix??


Solution

  • With the code below you can resize an image to a square image with and odd side length (in this case 333) and make it single:

    import cv2
    import numpy as np
    
    img = cv2.imread('image.jpg')
    size=333
    result = cv2.resize(img,(size, size), interpolation = cv2.INTER_CUBIC)
    single=np.single(result)