Mr-TalhaIlyas / EMPatches

Extract and Merge image patches for easy, fast and self-contained digital image processing and deep learning model training.
https://pypi.org/project/empatches/
45 stars 9 forks source link

Question about how merge patchs work #11

Open bisnow33 opened 1 year ago

bisnow33 commented 1 year ago

Hi, Thank for your nice work ! I have a question about how you compute the average in the merge_patchs function. I'm not sure to understand how you proceed when I look at your code. In those following lines you sum value of different patches rigth ? and why you divide value by 2 ? :

elif dims == 4:
                    if rgb:
                        empty_data[indice[0]:indice[1], indice[2]:indice[3], :] = np.where(empty_data[indice[0]:indice[1], indice[2]:indice[3], :] == 0,
                                                                                            data_patches[i], 
                                                                                            np.add(data_patches[i],empty_data[indice[0]:indice[1], indice[2]:indice[3], :])/2)

If I'm after the sum where do you divide by the number of by the number of occurrences ?

Best,

Tristan