Exemplo n.º 1
0
def getImageFeatures(imagePath, modelType):
    if not isinstance(modelType, ModelType):
        raise ValueError("Invalid modelType")

    if modelType == ModelType.SIFT:
        return SIFT(getGrayScaleImage(imagePath)).getFeatures()
    if modelType == ModelType.CM:
        return ColorMoments(getYUVImage(imagePath), 100, 100).getFeatures()
    if modelType == ModelType.HOG:
        return HOG(cv2.imread(imagePath, cv2.IMREAD_COLOR), 9, 8,
                   2).getFeatures()
    if modelType == ModelType.LBP:
        return LBP(getGrayScaleImage(imagePath),
                   blockSize=100,
                   numPoints=24,
                   radius=3).getFeatures()
Exemplo n.º 2
0
def getDataMatrixForSIFT(imagePaths, dataMatrix):
    imagesCount = len(imagePaths)
    for index, imagePath in enumerate(imagePaths):
        if not os.path.exists(imagePath): continue
        print("Data matrix creation | Processed {} out of {} images".format(
            index, imagesCount - 1))
        dataMatrix.append(
            getClusters(SIFT(
                getGrayScaleImage(imagePath)).getFeatures()).flatten())
    return dataMatrix
Exemplo n.º 3
0
def getDataMatrixForLBPForLDA(imagePaths, dataMatrix):
    imagesCount = len(imagePaths)
    for index, imagePath in enumerate(imagePaths):
        if not os.path.exists(imagePath): continue
        print("Data matrix creation | Processed {} out of {} images".format(
            index, imagesCount - 1))
        lbp = LBP(getGrayScaleImage(imagePath),
                  blockSize=100,
                  numPoints=24,
                  radius=3)
        features = lbp.getFeatureWithDim()
        dataMatrix.append(features)
    return dataMatrix