ProbeFilter not producing the correct result

I have created a 3D volumetric mesh and saved it as a vtkUnstrcturedGrid (i.e. as a .vtk file). This mesh consists of a box with an ellipsoid where the ellipsoid is inside of this box. This mesh has two scalars where the minimum value is 1 and the maximum is set to 2.
Then I attempted to convert it into a 3D image volume(i.e. as .mha file) using vtkProbeFilter as below.
For that, I have set a vtkImageData object as the InpuData in the probe filter and this unstructured grid as the sourceData. But unfortunately, I’m not able to produce the correct output and the output file is always empty and only contains the header.
Please help me on this matter. Thank you very much for your time and consideration.

vtkSmartPointer<vtkUnstructuredGridReader> reader =
        vtkSmartPointer<vtkUnstructuredGridReader>::New();
reader->SetFileName(ref_volumetric_mesh_path.c_str());
reader->ReadAllVectorsOn();
reader->ReadAllScalarsOn();
reader->Update();

vtkSmartPointer<vtkUnstructuredGrid> source = reader->GetOutput();

vtkSmartPointer<vtkImageData> input =
	vtkSmartPointer<vtkImageData>::New();

//input->SetDimensions(60, 60, 100);
input->SetDimensions(512, 512, 360);
input->SetSpacing(0.5, 0.5, 0.5);
input->SetOrigin(0.0, 0.0, 0.0);

input->AllocateScalars(VTK_DOUBLE, 2);

// Interpolate PointData from the mesh to the points of the Image
vtkSmartPointer<vtkProbeFilter> filter = vtkSmartPointer<vtkProbeFilter>::New();
filter->SetInputData(input);
filter->SetSourceData(source);
filter->Update();

vtkSmartPointer<vtkMetaImageWriter> writer = vtkSmartPointer<vtkMetaImageWriter>::New();
writer->SetFileName(ref_volumetric_mesh_voxelized_path.c_str());
writer->SetInputData(filter->GetOutput());
writer->Write();

I’m looking for a solution to this. Please some one let me know any steps that I have missed here ?

vtkProbeFilter requires a source input that specifies the points onto which you want to sample data. You haven’t provided that. Moreover, if you want a vtkImageData output, vtkProbeFilter is the wrong one to use.

Use vtkResampleToImage instead. There, the source “input” is implied to be a regular grid consistent with a vtkImageData. You just specify the bounds of the output image and the number of voxels in each dimension rather that input a vtkImageData to resample onto.