윤영준 윤영준 2023-07-12
data cleaning
@6e2a2791cb2ed2c3823c6bac85c198e6fb1101a6
.gitignore
--- .gitignore
+++ .gitignore
@@ -1,2 +1,5 @@
 # this is image dataset that is about 9 GB
-data/source/Oxford_raindrop_dataset
(파일 끝에 줄바꿈 문자 없음)
+data/source/Oxford_raindrop_dataset
+data/source/Peking_raindrop_dataset
+data/source/Peking_raindrop_dataset/clean
+data/source/Peking_raindrop_dataset/dirty
(파일 끝에 줄바꿈 문자 없음)
binary mask map test.py
--- binary mask map test.py
+++ binary mask map test.py
@@ -12,41 +12,42 @@
 
     return shifted
 
-def binary_diff_mask(clean, dirty, thresold=0.3):
+def binary_diff_mask(clean, dirty, threshold=0.3):
     # this parts corrects gamma, and always remember, sRGB values are not in linear scale with lights intensity,
-    clean = np.power(clean, 1/2.2)
-    dirty = np.power(dirty, 1/2.2)
+    clean = np.power(clean, 2.2)
+    dirty = np.power(dirty, 2.2)
 
-    # averaged_per_pixel = np.abs(dirty / shift_img(clean, 5, 0) - 1)
+    averaged_per_pixel = np.abs(((dirty) / (clean+1)) - 1 )
     # print(averaged_per_pixel)
-    diff = np.abs(clean - dirty)
+    diff = (np.abs(dirty - clean)  * 0.8 + (dirty / clean -1)) * 0.2 / 2
 
-    bin_diff = (diff > thresold).astype(np.uint8)
+    # bin_diff = (diff > threshold).astype(np.uint8)
 
-    return bin_diff
+    return ((dirty / clean -1 ) > threshold ).astype(np.uint8)
 
 clean = glob.glob("data/source/Oxford_raindrop_dataset/clean/*.png")
 clean = sorted(clean)
 dirty = glob.glob("data/source/Oxford_raindrop_dataset/dirty/*.png")
 dirty = sorted(dirty)
 
-clean_img = cv2.imread(clean[34])
-dirty_img = cv2.imread(dirty[34])
+clean_img = cv2.imread(clean[0])
+dirty_img = cv2.imread(dirty[0])
 
-binary_diff_mask_img = binary_diff_mask(dirty_img/255, clean_img/255, thresold=0.05)
+# binary_diff_mask_img = binary_diff_mask(dirty_img/255, clean_img/255, threshold=0.05)
 
-k = 20
+k = 10
 
 def process(i, j):
     print(i)
     clean_img_copy = shift_img(clean_img, (i-k)/4, (j-k)/4)
-    binary_diff_mask_img = binary_diff_mask(dirty_img / 255, clean_img_copy / 255, threshold=0.3)
-    success = cv2.imwrite(f"test/test_img_x{(i-k)/4}-y{(j-k)/4}.png", binary_diff_mask_img*255)
-    if not success:
-        print(f"Failed to save image at test/test_img{(i - k) / 4}-{(j - k) / 4}.png")
+    binary_diff_mask_img = binary_diff_mask(dirty_img / 255, clean_img_copy / 255, threshold=0.2)
+    if not cv2.imwrite(f"test/test_img_x{(i-k)/4}-y{(j-k)/4}.png", binary_diff_mask_img*255):
+        raise Exception("image is not saved")
 
-
+# this thing does not throw error when error happens and just silently executes.... what?
 with concurrent.futures.ProcessPoolExecutor() as executor:
     for i in range(k*2):
         for j in range(k*2):
             executor.submit(process, i, j)
+cv2.imwrite(f"test/original.png", dirty_img)
+cv2.imwrite(f"test/original_c.png", clean_img)
(파일 끝에 줄바꿈 문자 없음)
 
data/source/Peking_raindrop_dataset/description.txt (added)
+++ data/source/Peking_raindrop_dataset/description.txt
@@ -0,0 +1,1 @@
+https://github.com/rui1996/DeRaindrop
Add a comment
List