<!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>
<font color="#cc0000">Debug Assertion Failed!<br>
Program: ...<br>
File: C:\Program Files\Microsoft Visual Studio 8\VC\include\vector<br>
Line: 756<br>
<br>
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>
<font color="#cc0000">itkTestMain.exe - Application Error<br>
The exception unknown software exception (0xc000000d) occurred in
the application at location 0x78138a8a.</font><br>
<br>
My system is as such:<br>
Platform: Windows XP SP2<br>
Computer: Intel Pentium 3.00 GHz, dual core<br>
Compiler: Microsoft Visual Studio 2005 (v8.050727.363 ie. SP1 Beta)<br>
CMake: 2.4.2<br>
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><CODE:
itkTestMain.cxx></b></font><br>
/*=========================================================================<br>
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>
// Set input variables<br>
const char* InputImageFilename = "cthead1.png";<br>
const char* OutputImageFilename = "cthead1_SOBEL.mhd";<br>
<br>
// Declare types<br>
const unsigned int Dimension = 2;<br>
typedef float PixelType;<br>
typedef itk::Image< PixelType, Dimension > ImageType;<br>
typedef itk::ImageFileReader< ImageType > ReaderType;<br>
typedef itk::ImageFileWriter< ImageType > WriterType;<br>
typedef itk::SobelEdgeDetectionImageFilter< ImageType, ImageType
> SobelFilterType;<br>
<br>
try<br>
{<br>
// Read input image<br>
ReaderType::Pointer reader = ReaderType::New();<br>
reader->SetFileName( InputImageFilename );<br>
reader->Update();<br>
<br>
// Apply Sobel Filter<br>
SobelFilterType::Pointer filter = SobelFilterType::New();<br>
filter->SetInput( reader->GetOutput() );<br>
filter->Update();<br>
<br>
// Write output image<br>
WriterType::Pointer writer = WriterType::New();<br>
writer->SetFileName( OutputImageFilename );<br>
writer->SetInput( filter->GetOutput() );<br>
writer->Update();<br>
}<br>
catch (itk::ExceptionObject & err)<br>
{ <br>
std::cout << "ExceptionObject caught !" <<
std::endl; <br>
std::cout << err << std::endl; <br>
return EXIT_FAILURE;<br>
}<br>
<br>
//Return<br>
return EXIT_SUCCESS;<br>
}<br>
<font color="#000099"><b></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>></b></font><br>
<br>
</font></small><font face="Courier New, Courier, monospace"><small><font
color="#000099"><big><b><small><CODE: CMakeLists.txt></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>
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>
LOADPACKAGE(${Package})<br>
ENDFOREACH(Package)<br>
<br>
#Construct VXL/VNL includes<br>
SET(VXL_INCLUDE_DIRS<br>
${ITK_SOURCE_DIR}/Utilities/vxl<br>
${ITK_SOURCE_DIR}/Utilities/vxl/core<br>
${ITK_SOURCE_DIR}/Utilities/vxl/core/vnl<br>
${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>
itkvnl<br>
itkvnl_algo <br>
itknetlib)<br>
<br>
SET(ITK_LIBRARIES<br>
ITKIO <br>
ITKCommon<br>
ITKNumerics <br>
ITKBasicFilters<br>
${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>
#SUBDIRS(Testing)<br>
ENDIF(BUILD_TESTING)<br>
</small><small><font color="#000099"><b></ CODE</b></font><font
color="#000099"><big><b><small>: CMakeLists.txt</small></b></big></font></small><small><font
color="#000099"><b>></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 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>
#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 _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 21 error C2248: 'std::deque<_Ty>::_Myoff' : cannot
access <br>
protected member declared in class 'std::deque<_Ty>'
C:\Program <br>
Files\Microsoft Visual Studio 8\VC\include\deque 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"><luis.ibanez@kitware.com></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 itkConfigure.h.in, <br>
they will only appear in the file <br>
<br>
itkConfigure.h <br>
<br>
that CMake generates in the Binary directory where you are <br>
building ITK (and the install directory,... if you 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>
#ifndef _HAS_ITERATOR_DEBUGGING <br>
#error ITERATOR_DEBUGING_NOT_DEFINED <br>
#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>
Thanks <br>
<br>
<br>
Luis <br>
<br>
<br>
<br>
--------------------- <br>
Matei Stroila wrote: <br>
> I added <br>
> <br>
> # cmakedefine _HAS_ITERATOR_DEBUGGING=0 <br>
> <br>
> to Insight/itkConfigure.h.in, line 49 <br>
> <br>
> but I don't see it in the CMake configuration editor, neither in
the <br>
> Properties Window of the ITK projects. It does not look like they
are <br>
> using it. <br>
> <br>
> Also, for people intersted in using VS 2005, this define is also
necessary: <br>
> _SECURE_SCL=0 <br>
> <br>
> <br>
> Matei <br>
> <br>
> On 12/27/06, Luis Ibanez <a class="moz-txt-link-rfc2396E"
href="mailto:luis.ibanez@kitware.com"><luis.ibanez@kitware.com></a>
wrote: <br>
> <br>
>> <br>
>> Hi Matei, Karthik <br>
>> <br>
>> <br>
>> Thanks for tracking this issue. <br>
>> <br>
>> <br>
>> Just for the record: <br>
>> <br>
>> a better place for adding definitions is the file: <br>
>> <br>
>> <br>
>> Insight/itkConfigure.h.in <br>
>> <br>
>> <br>
>> Where you could add the line 49: <br>
>> <br>
>> <br>
>> cmakedefine _HAS_ITERATOR_DEBUGGING=0 <br>
>> <br>
>> <br>
>> The advantage of adding the definition here instead of the <br>
>> CMakeLists.txt file is that in the itkConfigure.h file, the <br>
>> definition is actually passed also to the projects that use <br>
>> ITK, while the definitions in CMakeLists.txt are used only <br>
>> while building ITK. <br>
>> <br>
>> <br>
>> <br>
>> Regards, <br>
>> <br>
>> <br>
>> <br>
>> Luis <br>
>> <br>
>> <br>
>> ---------------------- <br>
>> Matei Stroila wrote: <br>
>> > Thank you very much. <br>
>> > <br>
>> > I added -D_HAS_ITERATOR_DEBUGGING=0 in
Insight\CMakeLists.txt : <br>
>> > <br>
>> > IF(WIN32) <br>
>> > IF(NOT BORLAND) <br>
>> > IF(NOT CYGWIN) <br>
>> > IF(NOT MINGW) <br>
>> > ADD_DEFINITIONS( <br>
>> > -D_HAS_ITERATOR_DEBUGGING=0 <br>
>> > ) <br>
>> > ENDIF(NOT MINGW) <br>
>> > ENDIF(NOT CYGWIN) <br>
>> > ENDIF(NOT BORLAND) <br>
>> > ENDIF(WIN32) <br>
>> > <br>
>> > <br>
>> > Recompiled and my program runs fine in debug. <br>
>> > <br>
>> >> Please log this issue as an entry in the bug tracker.
<br>
>> >> <br>
>> > <br>
>> > Sure, I will do it now. <br>
>> > <br>
>> > Thanks, <br>
>> > <br>
>> > Matei <br>
>> > <br>
>> <br>
> <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>