Coordinate error when outputting VTK model

You have saved your mesh to file in RAS coordinate system. This is highly unusual, as DICOM standard uses LPS and all files storing DICOM-derived data is expected to use LPS coordinate system (unless another coordinate system is explicitly specified in the file).

The solution is to add an RAS->LPS transformation (diag([-1,-1,1,1]) matrix) in your polydata transform.

Note that it is not appropriate to use vtkMarchingCubes on a label image. You either need to apply low-pass filter (e.g., Gaussian image smoothing) on the image before passing it to contour filter, or you need to apply low-pass filter (e.g., windowed sinc polydata smoothing) on the contour filter output. Also, using the classic marching cubes algorithm is not the best solution anymore. Flying edges or surface nets provide results at higher quality and/or faster.