# About SHRT\_MAX in function 'cv::remap'

**URL:** <https://forum.opencv.org/t/about-shrt-max-in-function-cv-remap/2884>\
**Category:** Python\
**Tags:** imgproc\
**Created:** [April 21, 2021, 1:49am UTC](https://forum.opencv.org/t/about-shrt-max-in-function-cv-remap/2884 "2021-04-21T01:49:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![huitikho](https://avatars.discourse-cdn.com/v4/letter/h/d2c977/32.png) [@huitikho](https://forum.opencv.org/u/huitikho)\
**Post date:** [April 21, 2021, 1:49am UTC](https://forum.opencv.org/t/about-shrt-max-in-function-cv-remap/2884/1 "2021-04-21T01:49:34Z")

</div>

Dear All,

```
   When I run the python program with the cv2.wrapPerspective function, the following error occurs :  

 File "<ipython-input-1-3f9916624c9a>", line 1, in <module>
    runfile('C:/Users/Hui Tik Ho/ChanZhan/Multimodal MR Image Analysis/Veterinary/veterinary_registration.py', wdir='C:/Users/Hui Tik Ho/ChanZhan/Multimodal MR Image Analysis/Veterinary')

  File "C:\Users\Public\Anaconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "C:\Users\Public\Anaconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/Hui Tik Ho/ChanZhan/Multimodal MR Image Analysis/Veterinary/veterinary_registration.py", line 107, in <module>
    affined_l_mask = cv2.warpPerspective(l_mask[:, :], H, (r_img.shape[1], r_img.shape[0]))

error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-52oirelq\opencv\modules\imgproc\src\imgwarp.cpp:1724: error: (-215:Assertion failed) dst.cols < SHRT_MAX && dst.rows < SHRT_MAX && src.cols < SHRT_MAX && src.rows < SHRT_MAX in function 'cv::remap'

```

How can we solve the above problem ???

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [April 21, 2021, 7:05am UTC](https://forum.opencv.org/t/about-shrt-max-in-function-cv-remap/2884/2 "2021-04-21T07:05:53Z")

</div>

remapping uses (short) integer arithmetics for performance reasons,

so your image cannot be larger than 0x7fff

---

<div class="post-metadata">

**Author:** ![huitikho](https://avatars.discourse-cdn.com/v4/letter/h/d2c977/32.png) [@huitikho](https://forum.opencv.org/u/huitikho)\
**Post date:** [April 21, 2021, 7:31am UTC](https://forum.opencv.org/t/about-shrt-max-in-function-cv-remap/2884/5 "2021-04-21T07:31:18Z")

</div>

Thanks ! And may I ask can the parameter SHRT\_MAX be changed in the case. I am using Python under Anaconda environment ???

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [April 21, 2021, 7:38am UTC](https://forum.opencv.org/t/about-shrt-max-in-function-cv-remap/2884/6 "2021-04-21T07:38:05Z")

</div>

no, you can’t change it (also remember, it’s a c++ library, not python)

you have to use smaller images, that’s it.
