Generate STL file

I am even close to finish line.
I wrote this:

	vtkSmartPointer<vtkTriangleFilter> triangle = vtkSmartPointer<vtkTriangleFilter>::New();
	triangle->SetInputConnection(geometryfilter->GetOutputPort());
	triangle->Update();
	vtkSmartPointer<vtkPolyDataNormals> normals = vtkSmartPointer<vtkPolyDataNormals>::New();
	normals->SetInputConnection(triangle->GetOutputPort());
	normals->Update();

	vtkSmartPointer<vtkSTLWriter> writer = vtkSmartPointer<vtkSTLWriter>::New();
	writer->SetInputConnection(normals->GetOutputPort());
	writer->SetFileName(sSTL);
	writer->SetFileTypeToBinary();
	writer->Write();

and from this I got:

Now, I need just one thing: to filter the outline (contour) of the image, that is all. How can I achieve this ?

In my trials, I have tried to use vtkMarchingSquares, I don’t know if is a good idea:

	vtkSmartPointer<vtkMarchingSquares> contour = vtkSmartPointer<vtkMarchingSquares>::New();
	contour->SetInputConnection(reader->GetOutputPort());
	contour->GenerateValues(1, 0, 100);
	contour->Update();

at contour->Update I got a crash:

Program:

HEAP CORRUPTION DETECTED: after Normal block (#32114) at 0x000002AAF694F070.
CRT detected that the application wrote to memory after end of heap buffer.

I cannot coupling vtkJPEGReader to a vtkMarchingSquares directly ? But how then ?

What I intend to do is what I found here: http://vtk.1045678.n5.nabble.com/2D-Surface-Plot-how-to-get-quot-outlines-quot-td1236435.html#a1236436