|
a |
|
b/bme1312/Untitled.ipynb |
|
|
1 |
{ |
|
|
2 |
"cells": [ |
|
|
3 |
{ |
|
|
4 |
"cell_type": "code", |
|
|
5 |
"execution_count": 1, |
|
|
6 |
"id": "97c42d59-343d-4e6a-97ef-6c65d5741cbb", |
|
|
7 |
"metadata": {}, |
|
|
8 |
"outputs": [], |
|
|
9 |
"source": [ |
|
|
10 |
"# BME-1301 Lab-2: Segmentation using U-Net" |
|
|
11 |
] |
|
|
12 |
}, |
|
|
13 |
{ |
|
|
14 |
"cell_type": "code", |
|
|
15 |
"execution_count": 12, |
|
|
16 |
"id": "ca2c07d8-7fcb-4a76-a700-1aedd0318a41", |
|
|
17 |
"metadata": {}, |
|
|
18 |
"outputs": [], |
|
|
19 |
"source": [ |
|
|
20 |
"import os\n", |
|
|
21 |
"from PIL import Image\n", |
|
|
22 |
"all_label_path = 'C:/Users/DELL/Desktop/homework/bme1301 transfer/ACDC-2D-All/ACDC-2D-one/val/GT/'\n", |
|
|
23 |
"all_label_list = os.listdir(all_label_path)\n", |
|
|
24 |
"all_label_path = [os.path.join(all_label_path,all_label_list[i]) for i in range(len(all_label_list))]\n", |
|
|
25 |
"#print(all_label_path)\n", |
|
|
26 |
"\n", |
|
|
27 |
"\n", |
|
|
28 |
"for path in all_label_path:\n", |
|
|
29 |
" img = Image.open(path)\n", |
|
|
30 |
" im=np.array(img)\n", |
|
|
31 |
" im[im<255]=0\n", |
|
|
32 |
" img = Image.fromarray(im)\n", |
|
|
33 |
" img.save(path)\n", |
|
|
34 |
" " |
|
|
35 |
] |
|
|
36 |
}, |
|
|
37 |
{ |
|
|
38 |
"cell_type": "code", |
|
|
39 |
"execution_count": null, |
|
|
40 |
"id": "81eed033-a9af-47de-b7ca-e6bac10071c4", |
|
|
41 |
"metadata": {}, |
|
|
42 |
"outputs": [], |
|
|
43 |
"source": [] |
|
|
44 |
} |
|
|
45 |
], |
|
|
46 |
"metadata": { |
|
|
47 |
"kernelspec": { |
|
|
48 |
"display_name": "Python 3 (ipykernel)", |
|
|
49 |
"language": "python", |
|
|
50 |
"name": "python3" |
|
|
51 |
}, |
|
|
52 |
"language_info": { |
|
|
53 |
"codemirror_mode": { |
|
|
54 |
"name": "ipython", |
|
|
55 |
"version": 3 |
|
|
56 |
}, |
|
|
57 |
"file_extension": ".py", |
|
|
58 |
"mimetype": "text/x-python", |
|
|
59 |
"name": "python", |
|
|
60 |
"nbconvert_exporter": "python", |
|
|
61 |
"pygments_lexer": "ipython3", |
|
|
62 |
"version": "3.9.13" |
|
|
63 |
} |
|
|
64 |
}, |
|
|
65 |
"nbformat": 4, |
|
|
66 |
"nbformat_minor": 5 |
|
|
67 |
} |