<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<small><font face="Helvetica, Arial, sans-serif">Hi all,<br>
<br>
I sent this email a few weeks ago, but as yet I have no reply. Has
anyone else experienced this problem?<br>
<br>
I recently tried to use itkSobelEdgeDetectionImageFilter (source code
is at the end of this email).<br>
<br>
In <b>Debug </b>mode the following error is thrown:<br>
&nbsp;&nbsp;&nbsp; <font color="#cc0000">Debug Assertion Failed!<br>
&nbsp;&nbsp;&nbsp; Program: ...<br>
&nbsp;&nbsp;&nbsp; File: C:\Program Files\Microsoft Visual Studio 8\VC\include\vector<br>
&nbsp;&nbsp;&nbsp; Line: 756<br>
<br>
&nbsp;&nbsp;&nbsp; Expression: vector subscript out of range</font><br>
<br>
I think this error is related to:
<a class="moz-txt-link-freetext"
 href="http://public.kitware.com/pipermail/insight-users/2007-January/020483.html">http://public.kitware.com/pipermail/insight-users/2007-January/020483.html</a>.<br>
<br>
In <b>Release </b>mode the following error is thrown:<br>
&nbsp;&nbsp;&nbsp; <font color="#cc0000">itkTestMain.exe - Application Error<br>
&nbsp;&nbsp;&nbsp; The exception unknown software exception (0xc000000d) occurred in
the application at location 0x78138a8a.</font><br>
<br>
My system is as such:<br>
&nbsp;&nbsp;&nbsp; Platform: Windows XP SP2<br>
&nbsp;&nbsp;&nbsp; Computer: Intel Pentium 3.00 GHz, dual core<br>
&nbsp;&nbsp;&nbsp; Compiler: Microsoft Visual Studio 2005 (v8.050727.363 ie. SP1 Beta)<br>
&nbsp;&nbsp;&nbsp; CMake: 2.4.2<br>
&nbsp;&nbsp;&nbsp; ITK: 2.8.1 (compiled in both Debug and Release modes)<br>
<br>
I have had no problems compiling and running applications using
numerous other filters on this system. Any ideas as to the cause of the
error with the Sobel Edge Detection filter (source code below)? Am I
missing something so obvious that I can't see it? I can not debug the
issue because of the vector subscript error described above. I have not
tried the fix proposed in the insight-users post above because this
seems to be for Debug mode only, and my error appears in Release mode
also. (FYI: the cthead1.png image is in the same directory as the
produced executable.)<br>
<br>
Thanks for your help.<br>
<br>
Dan<br>
<br>
<br>
<font face="Courier New, Courier, monospace"><font color="#000099"><b>&lt;CODE:
itkTestMain.cxx&gt;</b></font><br>
/*=========================================================================<br>
&nbsp; itkTestMain.cxx<br>
=========================================================================*/<br>
#include "itkImage.h"<br>
#include "itkImageFileReader.h"<br>
#include "itkImageFileWriter.h"<br>
#include "itkSobelEdgeDetectionImageFilter.h"<br>
<br>
int main()<br>
{<br>
&nbsp;&nbsp;&nbsp; // Set input variables<br>
&nbsp;&nbsp;&nbsp; const char* InputImageFilename = "cthead1.png";<br>
&nbsp;&nbsp;&nbsp; const char* OutputImageFilename = "cthead1_SOBEL.mhd";<br>
<br>
&nbsp;&nbsp;&nbsp; // Declare types<br>
&nbsp;&nbsp;&nbsp; const unsigned int Dimension = 2;<br>
&nbsp;&nbsp;&nbsp; typedef float PixelType;<br>
&nbsp;&nbsp;&nbsp; typedef itk::Image&lt; PixelType, Dimension &gt; ImageType;<br>
&nbsp;&nbsp;&nbsp; typedef itk::ImageFileReader&lt; ImageType &gt; ReaderType;<br>
&nbsp;&nbsp;&nbsp; typedef itk::ImageFileWriter&lt; ImageType &gt; WriterType;<br>
&nbsp;&nbsp;&nbsp; typedef itk::SobelEdgeDetectionImageFilter&lt; ImageType, ImageType
&gt; SobelFilterType;<br>
<br>
&nbsp;&nbsp;&nbsp; try<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Read input image<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ReaderType::Pointer reader = ReaderType::New();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reader-&gt;SetFileName( InputImageFilename );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reader-&gt;Update();<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Apply Sobel Filter<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SobelFilterType::Pointer filter = SobelFilterType::New();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; filter-&gt;SetInput( reader-&gt;GetOutput() );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; filter-&gt;Update();<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Write output image<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WriterType::Pointer writer = WriterType::New();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writer-&gt;SetFileName( OutputImageFilename );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; writer-&gt;SetInput( filter-&gt;GetOutput() );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; writer-&gt;Update();<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; catch (itk::ExceptionObject &amp; err)<br>
&nbsp;&nbsp;&nbsp; { <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; "ExceptionObject caught !" &lt;&lt;
std::endl; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; err &lt;&lt; std::endl; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp; //Return<br>
&nbsp;&nbsp;&nbsp; return EXIT_SUCCESS;<br>
}<br>
<font color="#000099"><b>&lt;/CODE</b></font></font></font><font
 color="#000099"><big><font face="Courier New, Courier, monospace"><b><small>:
itkTestMain.cxx</small></b></font></big></font></small><small><font
 face="Helvetica, Arial, sans-serif"><font color="#000099"
 face="Courier New, Courier, monospace"><b>&gt;</b></font><br>
<br>
</font></small><font face="Courier New, Courier, monospace"><small><font
 color="#000099"><big><b><small>&lt;CODE: CMakeLists.txt&gt;</small></b></big></font></small><br>
<small>#Set the project<br>
PROJECT(TestMain)<br>
<br>
#Include some macros from another file...<br>
INCLUDE(${CMAKE_SOURCE_DIR}/IJMacros.txt)<br>
<br>
#Setup required paths<br>
SET(IMAGES_PATH ${CMAKE_SOURCE_DIR}/Images)<br>
SET(SOURCE_PATH ${CMAKE_SOURCE_DIR}/Source)<br>
<br>
SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin CACHE PATH "Single
output directory for building all libraries." FORCE)<br>
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin CACHE PATH "Single
output directory for building all executables." FORCE)<br>
SET(TESTING_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/Testing/Temporary)<br>
<br>
#The following lines are required to use Dart<br>
ENABLE_TESTING()<br>
INCLUDE(Dart)<br>
FIND_PROGRAM(IMAGE_COMPARE ImageCompare)<br>
<br>
#Declare any external dependencies that your project may have here.<br>
#examples include: ITK, VTK, JPEG, PNG, OpenGL, ZLIB, Perl, Java<br>
#If you're not sure what name to use, look in the Modules directory of
your<br>
#cmake install and check that a file named Find(Package).cmake exists<br>
SET(Required_Packages<br>
&nbsp;&nbsp;&nbsp; ITK<br>
)<br>
<br>
#this foreach loads all of the packages that you specified as required.<br>
#It shouldn't need to be modified.<br>
FOREACH(Package ${Required_Packages})<br>
&nbsp; LOADPACKAGE(${Package})<br>
ENDFOREACH(Package)<br>
<br>
#Construct VXL/VNL includes<br>
SET(VXL_INCLUDE_DIRS<br>
&nbsp;&nbsp;&nbsp; ${ITK_SOURCE_DIR}/Utilities/vxl<br>
&nbsp;&nbsp;&nbsp; ${ITK_SOURCE_DIR}/Utilities/vxl/core<br>
&nbsp;&nbsp;&nbsp; ${ITK_SOURCE_DIR}/Utilities/vxl/core/vnl<br>
&nbsp;&nbsp;&nbsp; ${ITK_SOURCE_DIR}/Utilities/vxl/vcl)<br>
<br>
#Set any libraries that your project depends on.<br>
#examples: ITKCommon, VTKRendering, etc<br>
SET(VXL_NUMERICS_LIBRARIES <br>
&nbsp;&nbsp;&nbsp; itkvnl<br>
&nbsp;&nbsp;&nbsp; itkvnl_algo <br>
&nbsp;&nbsp;&nbsp; itknetlib)<br>
<br>
SET(ITK_LIBRARIES<br>
&nbsp;&nbsp;&nbsp; ITKIO <br>
&nbsp;&nbsp;&nbsp; ITKCommon<br>
&nbsp;&nbsp;&nbsp; ITKNumerics <br>
&nbsp;&nbsp;&nbsp; ITKBasicFilters<br>
&nbsp;&nbsp;&nbsp; ${VXL_NUMERICS_LIBRARIES}<br>
)<br>
<br>
#Add Source<br>
SUBDIRS(Source)<br>
<br>
#Add Testing<br>
OPTION(BUILD_TESTING "Build the Testing directory." OFF)<br>
IF(BUILD_TESTING)<br>
&nbsp; #SUBDIRS(Testing)<br>
ENDIF(BUILD_TESTING)<br>
</small><small><font color="#000099"><b>&lt;/ CODE</b></font><font
 color="#000099"><big><b><small>: CMakeLists.txt</small></b></big></font></small><small><font
 color="#000099"><b>&gt;</b></font></small></font><br>
<small><font face="Helvetica, Arial, sans-serif"><br>
<br>
Matei Stroila wrote:</font></small>
<blockquote
 cite="midf0e05b070701020903n3d9a498en18777784e188c886@mail.gmail.com"
 type="cite"><small><font face="Helvetica, Arial, sans-serif">First of
all, Happy New Year! <br>
  <br>
Thanks all for this wonderful software library! It is an exemplary <br>
model of open source software that helps progress go on. <br>
  <br>
Now, going back to the VS 2005 settings: <br>
  <br>
Luis, <br>
  <br>
I added <br>
  <br>
#cmakedefine _SECURE_SCL=0 <br>
#cmakedefine _HAS_ITERATOR_DEBUGGING=0 <br>
  <br>
in itkConfigure.h.in. <br>
  <br>
The&nbsp; itkConfigure.h in the build dir becomes: <br>
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  <br>
/* <br>
* here is where system computed values get stored these values should
only <br>
* change when the target compile platform changes <br>
*/ <br>
  <br>
/* what byte order */ <br>
/* #undef CMAKE_WORDS_BIGENDIAN */ <br>
#ifdef CMAKE_WORDS_BIGENDIAN <br>
&nbsp;#define ITK_WORDS_BIGENDIAN <br>
#endif <br>
  <br>
/* what threading system are we using */ <br>
/* #undef CMAKE_USE_PTHREADS */ <br>
#ifdef CMAKE_USE_PTHREADS <br>
#define ITK_USE_PTHREADS <br>
#endif <br>
  <br>
/* #undef CMAKE_USE_SPROC */ <br>
#ifdef CMAKE_USE_SPROC <br>
#define ITK_USE_SPROC <br>
#endif <br>
  <br>
/* #undef CMAKE_HP_PTHREADS */ <br>
#ifdef CMAKE_HP_PTHREADS <br>
#define ITK_HP_PTHREADS <br>
#endif <br>
  <br>
#define CMAKE_USE_WIN32_THREADS <br>
#ifdef CMAKE_USE_WIN32_THREADS <br>
#define ITK_USE_WIN32_THREADS <br>
#endif <br>
  <br>
/* #undef ITK_BUILD_SHARED_LIBS */ <br>
#ifdef ITK_BUILD_SHARED_LIBS <br>
#define ITKDLL <br>
#else <br>
#define ITKSTATIC <br>
#endif <br>
  <br>
/* #undef CMAKE_NO_STD_NAMESPACE */ <br>
/* #undef CMAKE_NO_ANSI_STREAM_HEADERS */ <br>
/* #undef CMAKE_NO_ANSI_STRING_STREAM */ <br>
/* #undef CMAKE_NO_ANSI_FOR_SCOPE */ <br>
#define ITK_CPP_FUNCTION <br>
/* #undef ITK_USE_CONCEPT_CHECKING */ <br>
/* #undef ITK_EXPLICIT_INSTANTIATION */ <br>
/* #undef USE_FFTWF */ <br>
/* #undef USE_FFTWD */ <br>
/* #undef _SECURE_SCL=0 */ <br>
/* #undef _HAS_ITERATOR_DEBUGGING=0 */ <br>
  <br>
#define ITK_VERSION_MAJOR 3 <br>
#define ITK_VERSION_MINOR 1 <br>
#define ITK_VERSION_PATCH 0 <br>
#define ITK_VERSION_STRING "3.1" <br>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  <br>
  <br>
The&nbsp; _SECURE_SCL and _HAS_ITERATOR_DEBUGGING do not get defined, <br>
neither in the ITK library nor in projects depending on it. <br>
  <br>
On the other hand, if I add: <br>
  <br>
#define _SECURE_SCL 0 <br>
#define _HAS_ITERATOR_DEBUGGING 0 <br>
  <br>
in the itkConfigure.h.in, then they appear as is in itkConfigure.h but <br>
I get compile errors in <br>
C:\Program Files\Microsoft Visual Studio 8\VC\include\deque: <br>
  <br>
Error&nbsp;&nbsp;&nbsp; 21&nbsp;&nbsp;&nbsp; error C2248: 'std::deque&lt;_Ty&gt;::_Myoff' : cannot
access <br>
protected member declared in class 'std::deque&lt;_Ty&gt;'&nbsp;&nbsp;&nbsp;
C:\Program <br>
Files\Microsoft Visual Studio 8\VC\include\deque&nbsp;&nbsp;&nbsp; 132 <br>
  <br>
So, for now I will keep the definitions in CMakeLists.txt since that
works well. <br>
  <br>
Matei <br>
  <br>
  <br>
On 12/31/06, Luis Ibanez <a class="moz-txt-link-rfc2396E"
 href="mailto:luis.ibanez@kitware.com">&lt;luis.ibanez@kitware.com&gt;</a>
wrote: <br>
  </font></small>
  <blockquote type="cite"><small> <font
 face="Helvetica, Arial, sans-serif"><br>
Hi Matei, <br>
    <br>
When adding cmakedefine statements to&nbsp; itkConfigure.h.in, <br>
they will only appear in the file <br>
    <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; itkConfigure.h <br>
    <br>
that CMake generates in the Binary directory where you are <br>
building ITK (and the install directory,... if you&nbsp; are <br>
installing ITK after building it). <br>
    <br>
    <br>
The symbol does not appear in the CMake configuration editor, and <br>
it does not appear in the properties of Visual Studio IDE. This <br>
is normal. It is actually part of the advantages of defining the <br>
symbol in the itkConfigure.h.in file. <br>
    <br>
    <br>
Since itkConfigure.h is included by almost all ITK files, the symbol <br>
will be used all through your build. <br>
    <br>
    <br>
For a simple verification you can try adding in your <br>
code something like: <br>
    <br>
    <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #ifndef _HAS_ITERATOR_DEBUGGING <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #error ITERATOR_DEBUGING_NOT_DEFINED <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endif <br>
    <br>
    <br>
    <br>
Please let us know if you find an indication that the symbol does <br>
not get defined correctly. <br>
    <br>
    <br>
&nbsp;&nbsp; Thanks <br>
    <br>
    <br>
&nbsp;&nbsp;&nbsp;&nbsp; Luis <br>
    <br>
    <br>
    <br>
--------------------- <br>
Matei Stroila wrote: <br>
&gt; I added <br>
&gt; <br>
&gt; # cmakedefine&nbsp; _HAS_ITERATOR_DEBUGGING=0 <br>
&gt; <br>
&gt; to&nbsp;&nbsp; Insight/itkConfigure.h.in, line 49 <br>
&gt; <br>
&gt; but I don't see it&nbsp; in the CMake configuration editor, neither in
the <br>
&gt; Properties Window of the ITK projects. It does not look like they
are <br>
&gt; using it. <br>
&gt; <br>
&gt; Also, for people intersted in using VS 2005, this define is also
necessary: <br>
&gt; _SECURE_SCL=0 <br>
&gt; <br>
&gt; <br>
&gt; Matei <br>
&gt; <br>
&gt; On 12/27/06, Luis Ibanez <a class="moz-txt-link-rfc2396E"
 href="mailto:luis.ibanez@kitware.com">&lt;luis.ibanez@kitware.com&gt;</a>
wrote: <br>
&gt; <br>
&gt;&gt; <br>
&gt;&gt; Hi Matei, Karthik <br>
&gt;&gt; <br>
&gt;&gt; <br>
&gt;&gt; Thanks for tracking this issue. <br>
&gt;&gt; <br>
&gt;&gt; <br>
&gt;&gt; Just for the record: <br>
&gt;&gt; <br>
&gt;&gt; a better place for adding definitions is the file: <br>
&gt;&gt; <br>
&gt;&gt; <br>
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Insight/itkConfigure.h.in <br>
&gt;&gt; <br>
&gt;&gt; <br>
&gt;&gt; Where you could add the line 49: <br>
&gt;&gt; <br>
&gt;&gt; <br>
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cmakedefine&nbsp; _HAS_ITERATOR_DEBUGGING=0 <br>
&gt;&gt; <br>
&gt;&gt; <br>
&gt;&gt; The advantage of adding the definition here instead of the <br>
&gt;&gt; CMakeLists.txt file is that in the itkConfigure.h file, the <br>
&gt;&gt; definition is actually passed also to the projects that use <br>
&gt;&gt; ITK, while the definitions in CMakeLists.txt are used only <br>
&gt;&gt; while building ITK. <br>
&gt;&gt; <br>
&gt;&gt; <br>
&gt;&gt; <br>
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Regards, <br>
&gt;&gt; <br>
&gt;&gt; <br>
&gt;&gt; <br>
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Luis <br>
&gt;&gt; <br>
&gt;&gt; <br>
&gt;&gt; ---------------------- <br>
&gt;&gt; Matei Stroila wrote: <br>
&gt;&gt; &gt; Thank you very much. <br>
&gt;&gt; &gt; <br>
&gt;&gt; &gt; I added&nbsp;&nbsp; -D_HAS_ITERATOR_DEBUGGING=0&nbsp; in&nbsp;
Insight\CMakeLists.txt : <br>
&gt;&gt; &gt; <br>
&gt;&gt; &gt; IF(WIN32) <br>
&gt;&gt; &gt;&nbsp; IF(NOT BORLAND) <br>
&gt;&gt; &gt;&nbsp;&nbsp;&nbsp; IF(NOT CYGWIN) <br>
&gt;&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IF(NOT MINGW) <br>
&gt;&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ADD_DEFINITIONS( <br>
&gt;&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -D_HAS_ITERATOR_DEBUGGING=0 <br>
&gt;&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) <br>
&gt;&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ENDIF(NOT MINGW) <br>
&gt;&gt; &gt;&nbsp;&nbsp;&nbsp; ENDIF(NOT CYGWIN) <br>
&gt;&gt; &gt;&nbsp; ENDIF(NOT BORLAND) <br>
&gt;&gt; &gt; ENDIF(WIN32) <br>
&gt;&gt; &gt; <br>
&gt;&gt; &gt; <br>
&gt;&gt; &gt; Recompiled and my program runs fine in debug. <br>
&gt;&gt; &gt; <br>
&gt;&gt; &gt;&gt; Please log this issue as an entry in the bug tracker.
    <br>
&gt;&gt; &gt;&gt; <br>
&gt;&gt; &gt; <br>
&gt;&gt; &gt; Sure, I will do it now. <br>
&gt;&gt; &gt; <br>
&gt;&gt; &gt; Thanks, <br>
&gt;&gt; &gt; <br>
&gt;&gt; &gt; Matei <br>
&gt;&gt; &gt; <br>
&gt;&gt; <br>
&gt; <br>
    <br>
    </font> </small></blockquote>
  <font face="Helvetica, Arial, sans-serif"><small>_______________________________________________
  <br>
Insight-users mailing list <br>
  <a class="moz-txt-link-abbreviated"
 href="mailto:Insight-users@itk.org">Insight-users@itk.org</a> <br>
  <a class="moz-txt-link-freetext"
 href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a>
  </small><br>
  </font></blockquote>
</body>
</html>