[vtkusers] How to normalize gray level images by intensity?

Wenlong scc.wwl at gmail.com
Tue May 8 12:38:52 EDT 2012


Dear all,

I have a set of gray level human face images. I'd like to normalize them to
0-255 by intensity.

Here is what I do.

vtkBMPReader* imageReader = vtkImageReader::New();
vtkBMPWriter* imageWriter = vtkImageWriter::New();
vtkImageCast* imageCast = vtkImageCast::New();
vtkImageShiftScale* imageScale = vtkImageScale::New();
vtkImageNormalize* imageNormalize = vtkImageNormalize::New();

imageReader->SetFileName("C:\\Users\\Wenlong\\Desktop\\image.bmp");
imageReader->Update();

imageNormalize->SetInput(imageReader->GetOutput());
imageNormalize->Update();

imageScale->SetInput(imageNormalize->GetOutput());
imageScale->SetScale(255);
imageScale->Update();

imageCast->SetInput(imageScale->GetOutput());
imageCast->SetOutputScalarTypeToUnsignedChar();
imageCast->Update();

imageWriter->SetFileName("C:\\Users\\Wenlong\\Desktop\\NormalizedImage.bmp");
imageWriter->SetInput(imageCast->GetOutput());
imageWriter->Update();
imageWriter->Write();
/////////////////////////////////////////////////////////////////

However, the result image has the same black background as the input image.
And it has a grey face that has the same shape as the face in the input
image. But I cannot tell the eyes, nose and mouth etc.

Is this because I set the scale wrong? Please help if you have any idea.

Many thanks in advance. I look forward to hearing from you.

Best wishes
Wenlong

--
View this message in context: http://vtk.1045678.n5.nabble.com/How-to-normalize-gray-level-images-by-intensity-tp5695349.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list