質問編集履歴
1
追記しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,20 +5,27 @@
|
|
5
5
|
|
6
6
|
書き出したものを毎回読み込むと処理が遅くなるのではないかと思っており、書き出さずに動かせる何かいい方法をご存じであれば教えていただけると助かります。よろしくお願いいたします。
|
7
7
|
|
8
|
+
###追記
|
9
|
+
参考にさせていただいたサイトより、訂正したところチャンネルが異なるとエラーが出てしまいました。解決方法があればお教えいただきたいです。
|
8
10
|
|
9
11
|
|
12
|
+
|
10
13
|
### 発生している問題・エラーメッセージ
|
11
14
|
|
12
15
|
```python
|
13
16
|
error Traceback (most recent call last)
|
14
|
-
<ipython-input-
|
17
|
+
<ipython-input-12-ae6612370064> in <module>
|
18
|
+
23
|
15
19
|
24 #contrast
|
20
|
+
---> 25 lab = cv2.cvtColor(img2, cv2.COLOR_BGR2LAB)
|
21
|
+
26 lab_planes = cv2.split(img2)
|
16
|
-
|
22
|
+
27 clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
|
17
|
-
---> 26 cl1 = clahe.apply(img2)
|
18
|
-
27 cv2.imwrite("back-cl.jpg",cl1)
|
19
|
-
28
|
20
23
|
|
21
|
-
error: OpenCV(4.4.0)
|
24
|
+
error: OpenCV(4.4.0) c:\users\appveyor\appdata\local\temp\1\pip-req-build-71670poj\opencv\modules\imgproc\src\color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function '__cdecl cv::impl::`anonymous-namespace'::CvtHelper<struct cv::impl::`anonymous namespace'::Set<3,4,-1>,struct cv::impl::A0x2b0558ac::Set<3,-1,-1>,struct cv::impl::A0x2b0558ac::Set<0,5,-1>,2>::CvtHelper(const class cv::_InputArray &,const class cv::_OutputArray &,int)'
|
25
|
+
> Invalid number of channels in input image:
|
26
|
+
> 'VScn::contains(scn)'
|
27
|
+
> where
|
28
|
+
> 'scn' is 1
|
22
29
|
```
|
23
30
|
|
24
31
|
### 該当のソースコード
|
@@ -28,8 +35,16 @@
|
|
28
35
|
import cv2
|
29
36
|
import math
|
30
37
|
import numpy as np
|
38
|
+
import openpyxl as excel
|
31
39
|
|
40
|
+
#backgroundimagecreation
|
41
|
+
#img read
|
42
|
+
oimg = cv2.imread('back.jpg',0)
|
32
|
-
|
43
|
+
height = oimg.shape[0]
|
44
|
+
width = oimg.shape[1]
|
45
|
+
resize_img = cv2.resize(oimg,(int(width*0.5),int(height*0.5)))
|
46
|
+
|
47
|
+
#ganma
|
33
48
|
img_blur = cv2.GaussianBlur(resize_img,(499,499),0)
|
34
49
|
height = img_blur.shape[0]
|
35
50
|
width = img_blur.shape[1]
|
@@ -41,7 +56,11 @@
|
|
41
56
|
cv2.imwrite('back-ga.jpg',img2)
|
42
57
|
|
43
58
|
#contrast
|
59
|
+
lab = cv2.cvtColor(img2, cv2.COLOR_BGR2LAB)
|
60
|
+
lab_planes = cv2.split(img2)
|
44
61
|
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
|
45
|
-
|
62
|
+
lab_planes[0] = clahe.apply(lab_planes[0])
|
63
|
+
lab = cv2.merge(lab_planes)
|
64
|
+
cl1 = cv2.cvtColor(lab, cv2.COLOR_LAB2BGR)
|
46
65
|
cv2.imwrite("back-cl.jpg",cl1)
|
47
66
|
```
|