--- .gitignore
+++ .gitignore
... | ... | @@ -1,2 +1,5 @@ |
1 | 1 |
# this is image dataset that is about 9 GB |
2 |
-data/source/Oxford_raindrop_dataset(파일 끝에 줄바꿈 문자 없음) |
|
2 |
+data/source/Oxford_raindrop_dataset |
|
3 |
+data/source/Peking_raindrop_dataset |
|
4 |
+data/source/Peking_raindrop_dataset/clean |
|
5 |
+data/source/Peking_raindrop_dataset/dirty(파일 끝에 줄바꿈 문자 없음) |
--- binary mask map test.py
+++ binary mask map test.py
... | ... | @@ -12,41 +12,42 @@ |
12 | 12 |
|
13 | 13 |
return shifted |
14 | 14 |
|
15 |
-def binary_diff_mask(clean, dirty, thresold=0.3): |
|
15 |
+def binary_diff_mask(clean, dirty, threshold=0.3): |
|
16 | 16 |
# this parts corrects gamma, and always remember, sRGB values are not in linear scale with lights intensity, |
17 |
- clean = np.power(clean, 1/2.2) |
|
18 |
- dirty = np.power(dirty, 1/2.2) |
|
17 |
+ clean = np.power(clean, 2.2) |
|
18 |
+ dirty = np.power(dirty, 2.2) |
|
19 | 19 |
|
20 |
- # averaged_per_pixel = np.abs(dirty / shift_img(clean, 5, 0) - 1) |
|
20 |
+ averaged_per_pixel = np.abs(((dirty) / (clean+1)) - 1 ) |
|
21 | 21 |
# print(averaged_per_pixel) |
22 |
- diff = np.abs(clean - dirty) |
|
22 |
+ diff = (np.abs(dirty - clean) * 0.8 + (dirty / clean -1)) * 0.2 / 2 |
|
23 | 23 |
|
24 |
- bin_diff = (diff > thresold).astype(np.uint8) |
|
24 |
+ # bin_diff = (diff > threshold).astype(np.uint8) |
|
25 | 25 |
|
26 |
- return bin_diff |
|
26 |
+ return ((dirty / clean -1 ) > threshold ).astype(np.uint8) |
|
27 | 27 |
|
28 | 28 |
clean = glob.glob("data/source/Oxford_raindrop_dataset/clean/*.png") |
29 | 29 |
clean = sorted(clean) |
30 | 30 |
dirty = glob.glob("data/source/Oxford_raindrop_dataset/dirty/*.png") |
31 | 31 |
dirty = sorted(dirty) |
32 | 32 |
|
33 |
-clean_img = cv2.imread(clean[34]) |
|
34 |
-dirty_img = cv2.imread(dirty[34]) |
|
33 |
+clean_img = cv2.imread(clean[0]) |
|
34 |
+dirty_img = cv2.imread(dirty[0]) |
|
35 | 35 |
|
36 |
-binary_diff_mask_img = binary_diff_mask(dirty_img/255, clean_img/255, thresold=0.05) |
|
36 |
+# binary_diff_mask_img = binary_diff_mask(dirty_img/255, clean_img/255, threshold=0.05) |
|
37 | 37 |
|
38 |
-k = 20 |
|
38 |
+k = 10 |
|
39 | 39 |
|
40 | 40 |
def process(i, j): |
41 | 41 |
print(i) |
42 | 42 |
clean_img_copy = shift_img(clean_img, (i-k)/4, (j-k)/4) |
43 |
- binary_diff_mask_img = binary_diff_mask(dirty_img / 255, clean_img_copy / 255, threshold=0.3) |
|
44 |
- success = cv2.imwrite(f"test/test_img_x{(i-k)/4}-y{(j-k)/4}.png", binary_diff_mask_img*255) |
|
45 |
- if not success: |
|
46 |
- print(f"Failed to save image at test/test_img{(i - k) / 4}-{(j - k) / 4}.png") |
|
43 |
+ binary_diff_mask_img = binary_diff_mask(dirty_img / 255, clean_img_copy / 255, threshold=0.2) |
|
44 |
+ if not cv2.imwrite(f"test/test_img_x{(i-k)/4}-y{(j-k)/4}.png", binary_diff_mask_img*255): |
|
45 |
+ raise Exception("image is not saved") |
|
47 | 46 |
|
48 |
- |
|
47 |
+# this thing does not throw error when error happens and just silently executes.... what? |
|
49 | 48 |
with concurrent.futures.ProcessPoolExecutor() as executor: |
50 | 49 |
for i in range(k*2): |
51 | 50 |
for j in range(k*2): |
52 | 51 |
executor.submit(process, i, j) |
52 |
+cv2.imwrite(f"test/original.png", dirty_img) |
|
53 |
+cv2.imwrite(f"test/original_c.png", clean_img)(파일 끝에 줄바꿈 문자 없음) |
+++ data/source/Peking_raindrop_dataset/description.txt
... | ... | @@ -0,0 +1,1 @@ |
1 | +https://github.com/rui1996/DeRaindrop |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?