Write a program to convert a pgm (see following) into a vtk file with 3D bar charts and an overlaying (semi transparent) gray scale image map. The bars (or rectangle solids) are to average the values of a 10x10 set of inputs with the hight representing that average.
If you prefer, you can read in a ppm (color) file and convert it to a gray scale image by averaging the three values (RGB) for each pixel. Note, is a sloppy, inaccurate way to do this. See the book for the correct conversion formula.
You also need to write a vtk program to read in these vtk format files and display them.
part of a pgm (ascii) file --------------------------------------------------- P2 # CREATOR: XV Version 3.10 Rev: 12/16/94 480 270 255 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 109 ... BNF for a pgm (ascii) file. pgm-p2-file :: P2* b 255 :: # :: ( )^( )
This is the man page for pgm file format. And this is the man page for ppm file format.
To set the color of a vtk object:
pickActor->GetProperty()->SetColor(1,0,0);
To set the transparency/opacity:
pickActor->GetProperty()->SetOpacity(0.7);
An example of a vtk file is cube.vtk from the vtk book. A start on the vtk program you need to write is pjReadVTK.cc. This program can read a vtk type file and display it. A copy of this can be found on the sod cluster in examples/cc.
If you need to process a binary file in c++, the following example could help. It creates a binary copy of the input file.
//binary file copy #include#include voild main() { ifsteam fin("hello.exe",ios::binary); ofstream fout("thecopy.exe",ios::binary); for(usigned char c = fin.get();fin.good();fin.get(ch)) fout << ch; fin.close(); fout.close(); }