Change in morphologyEx kernel specifier from opencv-2.4.9 (Bug #4243)


Added by David Slate almost 10 years ago. Updated almost 10 years ago.


Status:Done Start date:2015-03-18
Priority:Normal Due date:
Assignee:David Slate % Done:

0%

Category:imgproc, video
Target version:3.0
Affected version:branch 'master' (3.0-dev) Operating System:Linux
Difficulty: HW Platform:x64
Pull request:

Description

I have a c++ program that calls morphologyEx with the kernel Mat(), which in opencv-2.4.9 seems to be interpreted as a request to use a default kernel. But in opencv-3.0.0-beta, the same calls generate:

Assertion failed (anchor.inside(Rect(0, 0, ksize.width, ksize.height))) in normalizeAnchor, file /home/dave/maclearn/vision/opencv-3.0.0-beta/modules/imgproc/src/filterengine.hpp, line 363

Replacing Mat() with an explicit kernel specification like getStructuringElement( MORPH_RECT, ...) seems to work ok.

Should Mat() still work as a default kernel specifier for morphologyEx in opencv-3.0, and, if not, should its use generate Assertion failures?


History

Updated by Ilya Lavrenov almost 10 years ago

Hi David,
Could you provide a minimalistic compilable sample to demonstrate the problem?

  • Assignee set to David Slate
  • Category set to imgproc, video
  • Target version set to 3.0

Updated by Ilya Lavrenov almost 10 years ago

  • Status changed from New to Incomplete

Updated by David Slate almost 10 years ago

Here is a log illustrating the differences in behavior of morphologyEx between opencv-2.4.8 and opencv-3.0.0-beta:

Script started on Wed Mar 25 12:43:06 2015
dave@lyta4: ~/vision/opencv/morph-bugdave@lyta4:~/vision/opencv/morph-bug$ ./morph-bug.sh
+ echo morph-bug.c++:
morph-bug.c++:
+ echo

+ cat morph-bug.c++
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/operations.hpp>
#include <iostream>
#include <sys/utsname.h>
using namespace std;
using namespace cv;

int main( int argc, char *argv[]) {
    struct utsname SysInfo;
    uname( &SysInfo);
    cout << "System Name: " << SysInfo.sysname << endl;
    cout << "Host Name: " << SysInfo.nodename << endl;
    cout << "Release(Kernel) Version: " << SysInfo.release << endl;
    cout << "Kernel Build Timestamp: " << SysInfo.version << endl;
    cout << "Machine Arch: " << SysInfo.machine << endl;
    cout << "Domain Name: " << SysInfo.domainname << endl;
    cout << getBuildInformation() << endl;
    cout << flush;
    Mat Image = Mat( 15, 14, CV_8U, 0.0);
    for (int R = 0; R < Image.rows; ++R) {
        for (int C = 0; C < Image.cols; ++C)
            Image.at<uchar>(R, C) = R * C;
    }
    cout << "Rows: " << to_string( Image.rows) << "  Cols: " << to_string( Image.cols) << endl;
    cout << "Image:\n" << Image << endl << flush;
    Mat ImageOut;
    Mat Struct = getStructuringElement( MORPH_RECT, Size( 5, 5));
    morphologyEx( Image, ImageOut, MORPH_OPEN, Struct, Point( -1, -1), 2);
    cout << "Rows: " << to_string( ImageOut.rows) << "  Cols: " << to_string( ImageOut.cols) << endl;
    cout << "ImageOut:\n" << ImageOut << endl << flush;
    morphologyEx( Image, ImageOut, MORPH_OPEN, Mat(), Point( -1, -1), 2);
    cout << "Rows: " << to_string( ImageOut.rows) << "  Cols: " << to_string( ImageOut.cols) << endl;
    cout << "ImageOut:\n" << ImageOut << endl << flush;
    return 0;
}
+ echo

+ echo With opencv-2.4.8:
With opencv-2.4.8:
+ echo

+ c++ -std=c++11 -g morph-bug.c++ -o morph-bug -lopencv_core -lopencv_imgproc
+ ./morph-bug
System Name: Linux
Host Name: lyta4
Release(Kernel) Version: 3.13.0-46-generic
Kernel Build Timestamp: #76-Ubuntu SMP Thu Feb 26 18:52:13 UTC 2015
Machine Arch: x86_64
Domain Name: (none)

General configuration for OpenCV 2.4.8 =====================================
  Version control:               unknown

  Platform:
    Host:                        Linux 3.2.0-58-generic x86_64
    CMake:                       2.8.12.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/x86_64-linux-gnu-g++  (ver 4.8.2)
    C++ flags (Release):         -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security  -DNDEBUG
    C++ flags (Debug):           -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/x86_64-linux-gnu-gcc
    C flags (Release):           -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security  -DNDEBUG
    C flags (Debug):             -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now
    Linker flags (Debug):        -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now
    Precompiled headers:         YES

  OpenCV modules:
    To be built:                 core flann imgproc highgui features2d calib3d ml objdetect video contrib legacy photo gpu java ocl python stitching superres ts videostab
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 androidcamera dynamicuda

  GUI: 
    QT:                          NO
    GTK+ 2.x:                    YES (ver 2.24.22)
    GThread :                    YES (ver 2.39.90)
    GtkGlExt:                    YES (ver 1.2.0)
    OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libSM.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libXext.so)

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.50)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.3)
    JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
    OpenEXR:                     /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 1.6.1)

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  YES (ver 2.2.1)
    FFMPEG:                      YES
      codec:                     YES (ver 54.35.0)
      format:                    YES (ver 54.20.3)
      util:                      YES (ver 52.3.0)
      swscale:                   YES (ver 2.1.1)
      gentoo-style:              YES
    GStreamer:                   NO
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    Using libv4l (ver 1.0.1)
    XIMEA:                       NO
    Xine:                        NO

  Other third-party libraries:
    Use IPP:                     NO
    Use Eigen:                   YES (ver 3.2.0)
    Use TBB:                     YES (ver 4.2 interface 7000)
    Use OpenMP:                  NO
    Use GCD                      NO
    Use Concurrency              NO
    Use C=:                      NO
    Use Cuda:                    NO
    Use OpenCL:                  YES

  OpenCL:
    Version:                     dynamic
    Use AMD FFT:                 NO
    Use AMD BLAS:                NO

  Python:
    Interpreter:                 /usr/bin/python2 (ver 2.7.6)
    Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.6)
    numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.8.0.dev-95f7a46)
    packages path:               lib/python2.7/dist-packages

  Java:
    ant:                         /usr/bin/ant (ver 1.9.3)
    JNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include
    Java tests:                  NO

  Documentation:
    Build Documentation:         YES
    Sphinx:                      /usr/bin/sphinx-build (ver 1.2.1)
    PdfLaTeX compiler:           /usr/bin/pdflatex

  Tests and samples:
    Tests:                       NO
    Performance tests:           YES
    C/C++ Examples:              YES

  Install path:                  /usr

  cvconfig.h is in:              /build/buildd/opencv-2.4.8+dfsg1/obj-x86_64-linux-gnu
-----------------------------------------------------------------

Rows: 15  Cols: 14
Image:
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13;
  0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26;
  0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39;
  0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52;
  0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65;
  0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78;
  0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91;
  0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104;
  0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117;
  0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130;
  0, 11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143;
  0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156;
  0, 13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169;
  0, 14, 28, 42, 56, 70, 84, 98, 112, 126, 140, 154, 168, 182]
Rows: 15  Cols: 14
ImageOut:
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9;
  0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 18, 18, 18, 18;
  0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 27, 27, 27, 27;
  0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 36, 36, 36, 36;
  0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 45, 45, 45, 45;
  0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 54, 54, 54, 54;
  0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 63, 63, 63, 63;
  0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 72, 72, 72, 72;
  0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 81, 81, 81, 81;
  0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 90, 90, 90, 90;
  0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 90, 90, 90, 90;
  0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 90, 90, 90, 90;
  0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 90, 90, 90, 90;
  0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 90, 90, 90, 90]
Rows: 15  Cols: 14
ImageOut:
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0;
  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 11;
  0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 22, 22;
  0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 33, 33;
  0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 44, 44;
  0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 55, 55;
  0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 66, 66;
  0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 77, 77;
  0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 88, 88;
  0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 99, 99;
  0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 110, 110;
  0, 11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 121, 121;
  0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 132, 132;
  0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 132, 132;
  0, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 132, 132]
+ echo

+ echo With opencv-3.0.0-beta:
With opencv-3.0.0-beta:
+ echo

+ c++ -std=c++11 -g -I/usr/local/include/opencv-3.0.0-beta morph-bug.c++ -o morph-bug -L/usr/local/lib -lopencv_core -lopencv_imgproc
+ ./morph-bug
System Name: Linux
Host Name: lyta4
Release(Kernel) Version: 3.13.0-46-generic
Kernel Build Timestamp: #76-Ubuntu SMP Thu Feb 26 18:52:13 UTC 2015
Machine Arch: x86_64
Domain Name: (none)

General configuration for OpenCV 3.0.0-beta =====================================
  Version control:               unknown

  Platform:
    Host:                        Linux 3.13.0-46-generic x86_64
    CMake:                       2.8.12.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/c++  (ver 4.8.2)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      
    Linker flags (Debug):        
    Precompiled headers:         YES

  OpenCV modules:
    To be built:                 core flann imgproc imgcodecs videoio highgui ml features2d calib3d objdetect photo video java shape stitching superres ts videostab
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 androidcamera cuda cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaoptflow cudastereo cudawarping cudev python2 python3 viz

  GUI: 
    QT 5.x:                      YES (ver 5.2.1)
    QT OpenGL support:           YES (Qt5::OpenGL 5.2.1)
    OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libSM.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libXext.so)
    VTK support:                 NO

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.8)
    JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
    WEBP:                        build (ver 0.3.1)
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.50)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.3)
    JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)
    GDAL:                        NO

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  YES (ver 2.2.1)
    FFMPEG:                      YES
      codec:                     YES (ver 54.35.0)
      format:                    YES (ver 54.20.4)
      util:                      YES (ver 52.3.0)
      swscale:                   YES (ver 2.1.1)
      gentoo-style:              YES
    GStreamer:                   NO
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    OpenNI2:                     NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    Using libv4l (ver 1.0.1)
    XIMEA:                       NO
    Xine:                        NO

  Other third-party libraries:
    Use IPP:                     NO
    Use IPP Async:               NO
    Use Eigen:                   YES (ver 3.2.0)
    Use TBB:                     YES (ver 4.2 interface 7000)
    Use OpenMP:                  NO
    Use GCD                      NO
    Use Concurrency              NO
    Use C=:                      NO
    Use Cuda:                    NO
    Use OpenCL:                  YES

  OpenCL:
    Version:                     dynamic
    Include path:                /home/dave/maclearn/vision/opencv-3.0.0-beta/3rdparty/include/opencl/1.2
    Use AMDFFT:                  NO
    Use AMDBLAS:                 NO

  Python 2:
    Interpreter:                 /usr/bin/python2.7 (ver 2.7.6)

  Python 3:
    Interpreter:                 /usr/bin/python3.4 (ver 3.4)

  Python (for build):            /usr/bin/python2.7

  Java:
    ant:                         /usr/bin/ant (ver 1.9.3)
    JNI:                         /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include
    Java wrappers:               YES
    Java tests:                  YES

  Matlab:
    mex:                         NO

  Documentation:
    Build Documentation:         YES
    Sphinx:                      /usr/bin/sphinx-build (ver 1.2.2)
    PdfLaTeX compiler:           /usr/bin/pdflatex
    PlantUML:                    NO
    Doxygen:                     YES (/usr/bin/doxygen)

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              YES

  Install path:                  /usr/local

  cvconfig.h is in:              /home/dave/maclearn/vision/opencv-3.0.0-beta/build
-----------------------------------------------------------------

Rows: 15  Cols: 14
Image:
[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13;
   0,   2,   4,   6,   8,  10,  12,  14,  16,  18,  20,  22,  24,  26;
   0,   3,   6,   9,  12,  15,  18,  21,  24,  27,  30,  33,  36,  39;
   0,   4,   8,  12,  16,  20,  24,  28,  32,  36,  40,  44,  48,  52;
   0,   5,  10,  15,  20,  25,  30,  35,  40,  45,  50,  55,  60,  65;
   0,   6,  12,  18,  24,  30,  36,  42,  48,  54,  60,  66,  72,  78;
   0,   7,  14,  21,  28,  35,  42,  49,  56,  63,  70,  77,  84,  91;
   0,   8,  16,  24,  32,  40,  48,  56,  64,  72,  80,  88,  96, 104;
   0,   9,  18,  27,  36,  45,  54,  63,  72,  81,  90,  99, 108, 117;
   0,  10,  20,  30,  40,  50,  60,  70,  80,  90, 100, 110, 120, 130;
   0,  11,  22,  33,  44,  55,  66,  77,  88,  99, 110, 121, 132, 143;
   0,  12,  24,  36,  48,  60,  72,  84,  96, 108, 120, 132, 144, 156;
   0,  13,  26,  39,  52,  65,  78,  91, 104, 117, 130, 143, 156, 169;
   0,  14,  28,  42,  56,  70,  84,  98, 112, 126, 140, 154, 168, 182]
Rows: 15  Cols: 14
ImageOut:
[  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0;
   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,   9,   9,   9,   9;
   0,   2,   4,   6,   8,  10,  12,  14,  16,  18,  18,  18,  18,  18;
   0,   3,   6,   9,  12,  15,  18,  21,  24,  27,  27,  27,  27,  27;
   0,   4,   8,  12,  16,  20,  24,  28,  32,  36,  36,  36,  36,  36;
   0,   5,  10,  15,  20,  25,  30,  35,  40,  45,  45,  45,  45,  45;
   0,   6,  12,  18,  24,  30,  36,  42,  48,  54,  54,  54,  54,  54;
   0,   7,  14,  21,  28,  35,  42,  49,  56,  63,  63,  63,  63,  63;
   0,   8,  16,  24,  32,  40,  48,  56,  64,  72,  72,  72,  72,  72;
   0,   9,  18,  27,  36,  45,  54,  63,  72,  81,  81,  81,  81,  81;
   0,  10,  20,  30,  40,  50,  60,  70,  80,  90,  90,  90,  90,  90;
   0,  10,  20,  30,  40,  50,  60,  70,  80,  90,  90,  90,  90,  90;
   0,  10,  20,  30,  40,  50,  60,  70,  80,  90,  90,  90,  90,  90;
   0,  10,  20,  30,  40,  50,  60,  70,  80,  90,  90,  90,  90,  90;
   0,  10,  20,  30,  40,  50,  60,  70,  80,  90,  90,  90,  90,  90]
OpenCV Error: Assertion failed (anchor.inside(Rect(0, 0, ksize.width, ksize.height))) in normalizeAnchor, file /home/dave/maclearn/vision/opencv-3.0.0-beta/modules/imgproc/src/filterengine.hpp, line 363
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/dave/maclearn/vision/opencv-3.0.0-beta/modules/imgproc/src/filterengine.hpp:363: error: (-215) anchor.inside(Rect(0, 0, ksize.width, ksize.height)) in function normalizeAnchor

Aborted (core dumped)
dave@lyta4: ~/vision/opencv/morph-bugdave@lyta4:~/vision/opencv/morph-bug$ exit
exit

Script done on Wed Mar 25 12:43:14 2015

Updated by Nisarg Thakkar almost 10 years ago

I have submitted a pull request : https://github.com/Itseez/opencv/pull/3932
Please review it.

Updated by David Slate almost 10 years ago

I applied Nisarg Thakkar's suggested mod in https://github.com/Itseez/opencv/pull/3932, rebuilt opencv-3.0.0-beta, and reran my test program, which now produces output compatible with that from opencv-2.4.8. So the fix seems to work for me. However, I am not sufficiently familiar with the opencv source code to verify the correctness or completeness of this mod. I'll leave that to the developers.

Updated by Alex Rothberg almost 10 years ago

I am running 2.4.9 and I occasionally see:

OpenCV Error: Assertion failed (anchor.inside(Rect(0, 0, ksize.width, ksize.height))) in normalizeAnchor, file /build/buildd/opencv-2.4.8+dfsg1/obj-x86_64-linux-gnu/modules/imgproc/precomp.hpp, line 88

Updated by Vadim Pisarevsky almost 10 years ago

ok, at least in 3.0pre the bug has been solved by the patch by Nisarg Thakkar

  • Status changed from Incomplete to Done

Also available in: Atom PDF