mitkExp was often crashing with a segmentation fault. The crash
usually/always occurs when I segment at the boundary of the image.
Using gdb I found the position of the seg fault to be in the function
iil4mitkPicImage::display(*), picimage.cpp, line 553.
I think this is because current-line/current+line/current+1/current-1 is
not always valid.
After correcting the code to the following, the application is much more
stable:
int ii = 0, nn = _pic->n[0]*_pic->n[1];
for (current = (mitkIpInt1_t*)_pic->data; current<end; current++, ii++) {
if (*current != 0) { if (ii >= line && *(current-line) == 0) { glVertex3f( x, y, 0.0 ); glVertex3f( x+1.0, y, 0.0 ); } if (ii <= nn-line && *(current+line) == 0) { glVertex3f( x, y+1.0, 0.0 ); glVertex3f( x+1.0, y+1.0, 0.0 ); } if (ii > 1 && *(current-1) == 0) { glVertex3f( x, y, 0.0 ); glVertex3f( x, y+1.0, 0.0 ); } if (ii < nn-1 && *(current+1) == 0) { ... }