def test_apply_multiple_filters_nochunk_sum_to_total_uneven(self): img_list = [] lables_list = [] Total_entries = 101 i = 0 for i in range(Total_entries): img_list.append( Image.open("Unit_tests/Tiny_test_img/00002_00000.ppm")) lables_list.append("yeet") filters = { "snow": premade_single_filter("snow"), "rain": premade_single_filter("rain") } imgs = apply_multiple_filters((img_list, lables_list), mode="linear", KeepOriginal=False, filters=filters, chungus=0) noises = [item[1] for item in imgs] snow = sum([1 if "snow" == x else 0 for x in noises]) rain = sum([1 if "rain" == x else 0 for x in noises]) result = snow + rain self.assertEqual(Total_entries, result)
def add_noise(imgs, noise_filter, image_size, chungus, keep_original): pil_imgs = convert_between_pill_numpy( imgs[0] * 255, mode='numpy->pil') #converts numpy_img list to pill imges in a list lables = [lable for lable in imgs[1]] #extracts the lables for the images image_tuples = apply_multiple_filters( (pil_imgs, lables), filters=noise_filter, mode='linear', chungus=chungus, KeepOriginal=keep_original ) #applies the diffrent noises to the images in a linear distribution, based on the number of filters inputet RGB_img = [ changeImageSize(image_size[0], image_size[1], im[0].convert('RGB')) for im in image_tuples ] #TODO find out what this line is used for other that its length. potentialy a useless computation #numpy_imgs = convert_between_pill_numpy(RGB_img,mode='pil->numpy') for i in range(len(RGB_img)): image_tuples[i] = ( image_tuples[i][0], image_tuples[i][2], image_tuples[i][1] ) #rearranges the img tuple and overwrites the old tuple return image_tuples
def add_noise(chungus, imgs: list, noise_filter: dict) -> list: #*DONE return apply_multiple_filters(imgs, filters=noise_filter, mode='rand', chungus=chungus, KeepOriginal=True)