質問編集履歴
6
コード
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,43 +52,43 @@
|
|
52
52
|
|
53
53
|
if __name__ == '__main__':
|
54
54
|
|
55
|
-
args = sys.argv
|
55
|
+
args = sys.argv
|
56
56
|
|
57
|
-
data_dir = args[1].replace('\', '/')
|
57
|
+
data_dir = args[1].replace('\', '/')
|
58
58
|
|
59
|
-
trimed_dir = data_dir + 'trimed'
|
59
|
+
trimed_dir = data_dir + 'trimed'
|
60
60
|
|
61
|
-
os.mkdir(trimed_dir)
|
61
|
+
os.mkdir(trimed_dir)
|
62
62
|
|
63
|
-
files = os.listdir(data_dir)
|
63
|
+
files = os.listdir(data_dir)
|
64
64
|
|
65
|
-
img_files = [
|
65
|
+
img_files = [
|
66
66
|
|
67
|
-
f for f in files if '.tif' in f or '.jpg' in f or '.png' in f]
|
67
|
+
f for f in files if '.tif' in f or '.jpg' in f or '.png' in f]
|
68
68
|
|
69
|
-
print(img_files)
|
69
|
+
print(img_files)
|
70
70
|
|
71
|
-
for img_file in img_files:
|
71
|
+
for img_file in img_files:
|
72
72
|
|
73
|
-
img_dir = data_dir + img_file
|
73
|
+
img_dir = data_dir + img_file
|
74
74
|
|
75
|
-
img = cv2.imread(img_dir)
|
75
|
+
img = cv2.imread(img_dir)
|
76
76
|
|
77
77
|
|
78
78
|
|
79
|
-
selected = cv2.selectROI(img)
|
79
|
+
selected = cv2.selectROI(img)
|
80
80
|
|
81
|
-
if sum(selected):
|
81
|
+
if sum(selected):
|
82
82
|
|
83
|
-
imCrop = img[int(selected[1]):int(selected[1]+selected[3]),
|
83
|
+
imCrop = img[int(selected[1]):int(selected[1]+selected[3]),
|
84
84
|
|
85
|
-
int(selected[0]):int(selected[0]+selected[2])]
|
85
|
+
int(selected[0]):int(selected[0]+selected[2])]
|
86
86
|
|
87
|
-
file_dir = data_dir + trimed_dir + '/' + img_file
|
87
|
+
file_dir = data_dir + trimed_dir + '/' + img_file
|
88
88
|
|
89
|
-
cv2.imwrite(file_dir, imCrop)
|
89
|
+
cv2.imwrite(file_dir, imCrop)
|
90
90
|
|
91
|
-
print('All images are saved')
|
91
|
+
print('All images are saved')
|
92
92
|
|
93
93
|
|
94
94
|
|
5
コード
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,9 +34,9 @@
|
|
34
34
|
|
35
35
|
```
|
36
36
|
|
37
|
-
python
|
38
37
|
|
38
|
+
|
39
|
-
```
|
39
|
+
```python
|
40
40
|
|
41
41
|
### 該当のソースコード
|
42
42
|
|
4
コード
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,11 +34,11 @@
|
|
34
34
|
|
35
35
|
```
|
36
36
|
|
37
|
+
python
|
37
38
|
|
39
|
+
```
|
38
40
|
|
39
41
|
### 該当のソースコード
|
40
|
-
|
41
|
-
python3.8.5を使っています。
|
42
42
|
|
43
43
|
|
44
44
|
|
3
コード
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,43 +52,43 @@
|
|
52
52
|
|
53
53
|
if __name__ == '__main__':
|
54
54
|
|
55
|
-
|
55
|
+
args = sys.argv
|
56
56
|
|
57
|
-
|
57
|
+
data_dir = args[1].replace('\', '/')
|
58
58
|
|
59
|
-
|
59
|
+
trimed_dir = data_dir + 'trimed'
|
60
60
|
|
61
|
-
|
61
|
+
os.mkdir(trimed_dir)
|
62
62
|
|
63
|
-
|
63
|
+
files = os.listdir(data_dir)
|
64
64
|
|
65
|
-
|
65
|
+
img_files = [
|
66
66
|
|
67
|
-
|
67
|
+
f for f in files if '.tif' in f or '.jpg' in f or '.png' in f]
|
68
68
|
|
69
|
-
|
69
|
+
print(img_files)
|
70
70
|
|
71
|
-
|
71
|
+
for img_file in img_files:
|
72
72
|
|
73
|
-
|
73
|
+
img_dir = data_dir + img_file
|
74
74
|
|
75
|
-
|
75
|
+
img = cv2.imread(img_dir)
|
76
76
|
|
77
77
|
|
78
78
|
|
79
|
-
|
79
|
+
selected = cv2.selectROI(img)
|
80
80
|
|
81
|
-
|
81
|
+
if sum(selected):
|
82
82
|
|
83
|
-
|
83
|
+
imCrop = img[int(selected[1]):int(selected[1]+selected[3]),
|
84
84
|
|
85
|
-
|
85
|
+
int(selected[0]):int(selected[0]+selected[2])]
|
86
86
|
|
87
|
-
|
87
|
+
file_dir = data_dir + trimed_dir + '/' + img_file
|
88
88
|
|
89
|
-
|
89
|
+
cv2.imwrite(file_dir, imCrop)
|
90
90
|
|
91
|
-
|
91
|
+
print('All images are saved')
|
92
92
|
|
93
93
|
|
94
94
|
|
2
インデント下げ
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,43 +52,43 @@
|
|
52
52
|
|
53
53
|
if __name__ == '__main__':
|
54
54
|
|
55
|
-
args = sys.argv
|
55
|
+
''''args = sys.argv
|
56
56
|
|
57
|
-
data_dir = args[1].replace('\', '/')
|
57
|
+
''''data_dir = args[1].replace('\', '/')
|
58
58
|
|
59
|
-
trimed_dir = data_dir + 'trimed'
|
59
|
+
''''trimed_dir = data_dir + 'trimed'
|
60
60
|
|
61
|
-
os.mkdir(trimed_dir)
|
61
|
+
''''os.mkdir(trimed_dir)
|
62
62
|
|
63
|
-
files = os.listdir(data_dir)
|
63
|
+
''''files = os.listdir(data_dir)
|
64
64
|
|
65
|
-
img_files = [
|
65
|
+
''''img_files = [
|
66
66
|
|
67
|
-
f for f in files if '.tif' in f or '.jpg' in f or '.png' in f]
|
67
|
+
''''''''f for f in files if '.tif' in f or '.jpg' in f or '.png' in f]
|
68
68
|
|
69
|
-
print(img_files)
|
69
|
+
''''''''print(img_files)
|
70
70
|
|
71
|
-
for img_file in img_files:
|
71
|
+
''''''''for img_file in img_files:
|
72
72
|
|
73
|
-
img_dir = data_dir + img_file
|
73
|
+
''''''''img_dir = data_dir + img_file
|
74
74
|
|
75
|
-
img = cv2.imread(img_dir)
|
75
|
+
''''''''img = cv2.imread(img_dir)
|
76
76
|
|
77
77
|
|
78
78
|
|
79
|
-
selected = cv2.selectROI(img)
|
79
|
+
''''''''selected = cv2.selectROI(img)
|
80
80
|
|
81
|
-
if sum(selected):
|
81
|
+
''''''''if sum(selected):
|
82
82
|
|
83
|
-
imCrop = img[int(selected[1]):int(selected[1]+selected[3]),
|
83
|
+
''''''''''''imCrop = img[int(selected[1]):int(selected[1]+selected[3]),
|
84
84
|
|
85
|
-
int(selected[0]):int(selected[0]+selected[2])]
|
85
|
+
''''''''''''''''int(selected[0]):int(selected[0]+selected[2])]
|
86
86
|
|
87
|
-
file_dir = data_dir + trimed_dir + '/' + img_file
|
87
|
+
''''''''''''file_dir = data_dir + trimed_dir + '/' + img_file
|
88
88
|
|
89
|
-
cv2.imwrite(file_dir, imCrop)
|
89
|
+
''''''''''''cv2.imwrite(file_dir, imCrop)
|
90
90
|
|
91
|
-
print('All images are saved')
|
91
|
+
''''''''''''print('All images are saved')
|
92
92
|
|
93
93
|
|
94
94
|
|
1
コードの字数下げ
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
python3.8.5を使っています。
|
42
42
|
|
43
|
-
|
43
|
+
|
44
44
|
|
45
45
|
import cv2
|
46
46
|
|
@@ -52,7 +52,7 @@
|
|
52
52
|
|
53
53
|
if __name__ == '__main__':
|
54
54
|
|
55
|
-
args = sys.argv
|
55
|
+
args = sys.argv
|
56
56
|
|
57
57
|
data_dir = args[1].replace('\', '/')
|
58
58
|
|