# Error: (-215:Assertion failed) src.type() == (((0) & ((1 \<\< 3) - 1)) + (((1)-1) \<\< 3)) in function 'cv::adaptiveThreshold'

**URL:** <https://forum.opencv.org/t/error-215-assertion-failed-src-type-0-1-3-1-1-1-3-in-function-cv-adaptivethreshold/3671>\
**Category:** Python\
**Tags:** imgproc\
**Created:** [June 3, 2021, 9:12pm UTC](https://forum.opencv.org/t/error-215-assertion-failed-src-type-0-1-3-1-1-1-3-in-function-cv-adaptivethreshold/3671 "2021-06-03T21:12:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Surya\_Prakash\_Mishra](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/surya_prakash_mishra/32/2285_2.png) [@Surya\_Prakash\_Mishra](https://forum.opencv.org/u/Surya_Prakash_Mishra)\
**Post date:** [June 3, 2021, 9:12pm UTC](https://forum.opencv.org/t/error-215-assertion-failed-src-type-0-1-3-1-1-1-3-in-function-cv-adaptivethreshold/3671/1 "2021-06-03T21:12:55Z")

</div>

```auto
img_array = cv2.imread('/metal/data/Columnar/Al1_1.jpg')
img = cv2.resize(img_array,(IMG_SIZE,IMG_SIZE))
img = np.asarray(img_array, dtype='float32')
bw = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
th3 = cv2.adaptiveThreshold(bw,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,11,2)

```

The said error is raised on the last line of code. Can someone please help me out? I am using opencv version 4.5.2.52

The whole error is:  
**error: OpenCV(3.4.2) C:\Miniconda3\conda-bld\opencv-suite\_1534379934306\work\modules\imgproc\src\thresh.cpp:1524: error: (-215:Assertion failed) src.type() == (((0) & ((1 \<\< 3) - 1)) + (((1)-1) \<\< 3)) in function 'cv::adaptiveThreshold’**

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [June 3, 2021, 10:32pm UTC](https://forum.opencv.org/t/error-215-assertion-failed-src-type-0-1-3-1-1-1-3-in-function-cv-adaptivethreshold/3671/2 "2021-06-03T22:32:26Z")

</div>

that’s an unfortunate expansion of the assertion.

it basically says it wants a [single-channel CV\_8U type matrix](https://docs.opencv.org/master/d1/d1b/group __core__ hal__interface.html#gab2ebca36079fd923483abee99d7ff40d), and you gave it something else (float32, which is CV\_32F)
