質問編集履歴
1
Pythonコードを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -129,3 +129,107 @@
|
|
129
129
|
|
130
130
|
|
131
131
|
```
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
```Python
|
136
|
+
|
137
|
+
# -*- coding: utf-8 -*-
|
138
|
+
|
139
|
+
"""Tone-curve-Postarization.ipynb
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
Automatically generated by Colaboratory.
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
Original file is located at
|
148
|
+
|
149
|
+
https://colab.research.google.com/drive/1jU2JgQ2kJhRBwaTt3S6VyRILmUFueHIc
|
150
|
+
|
151
|
+
"""
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
!wget http://www.centerportgardenclub.org/wp-content/gallery/photos/2014-marisa-comple-IMG_5867.jpeg img.jpg
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
mv 2014-marisa-comple-IMG_5867.jpeg img.jpg
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
ls
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
# %matplotlib inline
|
168
|
+
|
169
|
+
import cv2
|
170
|
+
|
171
|
+
import matplotlib.pyplot as plt
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
src_img = cv2.imread("img.jpg", 0);
|
176
|
+
|
177
|
+
plt.imshow( src_img)
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
max_ = 256
|
182
|
+
|
183
|
+
step_ = 4
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
lut = [0] * max_
|
188
|
+
|
189
|
+
for i in range(max_):
|
190
|
+
|
191
|
+
lut[i] = (i / (max_ / step_)) * (max_ / step_)
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
dst_img = []
|
196
|
+
|
197
|
+
for i in range(480):
|
198
|
+
|
199
|
+
temp = []
|
200
|
+
|
201
|
+
for j in range(480):
|
202
|
+
|
203
|
+
temp.append(0)
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
dst_img.append(temp)
|
208
|
+
|
209
|
+
dst_img[1][5]
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
for y in range(src_img.shape[0]):
|
214
|
+
|
215
|
+
for x in range(src_img.shape[1]):
|
216
|
+
|
217
|
+
dst_img[y][x] = lut[src_img[y][x]];
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
dst_img[170][239]
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
src_img.shape
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
plt.imshow(dst_img)
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
```
|