Saturday, 23 July 2022

Improving extraction of points of interest for image preprocessing

I'm currently developing a task for image classification. The images are hand drawn, in black and white, and relative simple shapes (a house, circle, etc.)

For that, I'm using a SIFT approach:

def getData(folder, min_num_descr = 20):
    lista_imagenes = []
    for x in os.listdir(folder):
        path_local = folder + "/" + x
        for j in os.listdir(path_local):
            imagen = cv2.imread(path_local + "/" + j)
            lista_imagenes.append(imagen)
    
    lista_total_kp = []
    lista_total_desc = []
    lista_total_imagen = []

    for i  in range(len(lista_imagenes)):
        sift = cv2.xfeatures2d.SIFT_create()
        kp_1 = sift.detect(lista_imagenes[i], None)
        kp_1, dec_1 = sift.compute(lista_imagenes[i],kp_1)
        lista_total_kp.append(kp_1)
        lista_total_desc.append(dec_1)
        lista_total_imagen.append(i)
    
    lista_desc_numpy = np.array(lista_total_desc)
    lista_desc_real = []
    for i in range(0,len(lista_total_desc)):
        try:
            if lista_total_desc[i].shape[0] >= min_num_descr:
                lista_desc_real.append(lista_total_desc[i][:min_num_descr])
        except:
            continue
            
    return np.array(lista_desc_real)

This is giving me a dataset (I added the targets in the last column)

df_splitted = pd.read_csv("https://raw.githubusercontent.com/norhther/datasets/main/drawn_images.csv").iloc[:,1:]

The problem is that after a StandardScaler and several models with fine tunning (SVM, AdaBoost, RF...) I'm having some bad scores. I also added class weight to estables and evolutivos because the dataset is imbalanced, and also those classes are most important.

My question is how to improve the image preprocessing, maybe using another technique and not the points of interest with SIFT.



from Improving extraction of points of interest for image preprocessing

No comments:

Post a Comment