Thursday, April 27, 2006

Region growing segmentation


Region growing segmentation seems like a relatively easier thing to use to segment the pulmonary venous drainages. I will be trying to implement a Seeded Region Growing segmentation to start extracting the drainage patterns. However, I anticipate that Region-growing might not work perfectly with veins. The problem with region growing is that it seems to explode and find its way out somehow out of the region which we are interested in. To get a jist of how difficult segmentation might get, have a look at the MRI image above. I wish everyday that MRI image acquisition was clearer.
In near future, I will also be looking at other image segmentation techniques used in medical imaging. There is a good piece of literature out there that explores out all the different techniques that have popularly been used in segmenting medical images. Here's the paper.

Wednesday, April 19, 2006

VTK Error

I have been stuck for about a couple of weeks trying to get rid of this error
vtkVolumeRayCastMapper Cannot volume render data of type short, only unsigned char
or unsigned short.
that I have been getting when I was trying to MIP render a GIPL image. I was finally able to resolve the issue, with Prof. Daniel's help. I have looked around the web for a solution, and all of the solutions that I have looked at didnt help. Infact, people working with ITK (Insight ITK) commonly face this problem when they are trying to render an ITK image.

The solution is simple, only if you knew the vtk classes inside out. Anyone would have guessed what needs to be done here: we simply need to make sure that the scalar values we have in our vtk data set (vtkStructuredPoints for e.g.) are non-negative values. Well, if you have negative values, you want to make sure that you can scale them back to the set of positive real numbers. The way you do this is by first determining the minimum and maximum of your scalar values and then setting the minimum to be 0. So if -5 is the minimum, you set it to zero and add all the other scalars by 5. Once you have non-negative values, all you now have to do is pass the vtk data through a small pipeline. A pipeline is an important concept which I learned about today. Most VTK textbooks have this explained well. What it really is that the output of a filter becomes the input of another filter, and this is done by using common vtk functions such SetInput and GetOutput. Going back to our discussion, once we have non-negative values, we need to cast and make sure that we can safely cast. If you have scaled your scalars properly, it should be a safe cast.

vtkImageCast *vtkImageCast = vtkImageCast::New();
vtkImageCast->SetInput(vtkImage);
vtkImageCast->SetOutputScalarTypeToUnsignedShort();
....... // somewhere down the line ...
volumeMapper->SetInput(vtkImageCast->GetOutput());

As you can see, a new vtkImageCast object casts the vtkStructuredPoints vtkImage object's scalar values to unsigned short and then the GetOutput function is called to feed the output to the renderer.


Saturday, April 15, 2006

Moving homes and other stuff

I have been spending most parts of this entire week either at Glu or trying to move out to my new apartment. Looking for a place to stay in London is harder than solving an optimization problem with defined constraints. My interview at Google is very soon and I am very excited aboout it. It is one thing that I noted about Google that is atleast different from Microsoft, Google's hires a lot of "academically" bright students, and I mean students from the good schools with the good grades. I have been reading a couple of profiles and quite a handful of them even have PhDs. I think Microsoft puts much more emphasis on programming quality and ability than any other thing.

I have been working on my MRA visualization. Somewhere in VTK i am having problems trying to render an ITK image. Apparently some common VTK rendering functions (such as ray-casting, MIP) can only render volumes with voxel scalar values that are of type unsigned short/char. The ITK images which I have are of type signed ints. It does not make sense to me why VTK designers would want the format to be unsigned short/char. unsigned makes sense, but why short and not an int?

At the same time, I am also working on a coursework which was due ages ago. Here is a rendering of the skull using Back-to-front (BTF) compositing. The rendering is very basic since I have only used a single threshold and no lighting model. I have also limited the colors B/W as I wanted to get an X-ray like image. The original volume is from a CT scan though. So here you go, your CT to X-ray converter.


Friday, April 07, 2006

ITK + VTK Compiled

After a long haul, VTK and ITK finally compiled. The problem was with having VTK not installed properly on my machine. The thing with open source software is that the installers (if any) are not that great. Sometimes, as it did with me, it installed a version of VTK that was not fully compatible to run on my OS. The best thing to always do is to download the source and compile it using your compiler. That's what I did with VTK, when I realized that it was not working with ITK. There were also problems with Project (ITK), and things needed to be updated. I also had to install FLTK in order to install rview. rview apparently doesn't work without FLTK. There are also other little things that I should be careful about: for e.g. turn the Advanced options on when CMake-ing, and make sure you have put the GL/gl.h and glut32.lib files under your compilers lib folders (such as vc7/lib). However, as a piece of advice, the best thing to do is to read the errors carefully when compiling ITK and to stay calm when errors > 100 show up (after which vc .net stops compiling further :(( )


Wednesday, April 05, 2006

A thing called CygWin

CygWin is a blessing to the windows operating systems. Basically it makes your Windows system acts like a UNIX OS. It provides some basic UNIX OS functionality together with programming development tools like GCC, etc. You could run xemacs/emacs on cygwin as well. So, if you are an emacs person and run windows on your PC (a rare combo) you should probably get CygWin.

CygWin also allows X11 forwarding through its CygWin/X package. So basically, you could connect to a remote linux/Unix server and get the graphical output on your WinOS. And fundamentally, Cygwin consists of a library that implements the POSIX system call API in terms of Win32 system calls.

I have been trying to setup CygWin/X. And today I got stuck trying to configure X11 forwarding and setting up display settings, although I had done it some time before. Basically you need to call the startwin.sh script, as described in here. After that you can ssh to your remote host on the X-window (window that appears after you run startwin.sh).

Tomorrow I get to meet Prof. Daniel. My ITK build is now completely messed up. I cleaned up the build and now after re-building it gives me errors which I never got before. I have written a basic visualization code. I also need to invest some time in getting my Adv. viz. coursework program code to work.

Tuesday, April 04, 2006

For most parts of the weekend, I have been spending my time at Glu. Its seems like its been a while since I have taken time off, and Sunday was finally a holiday for me. I am working on my Advanced graphics coursework that requires me to render a brain CT scan using fundamental rendering algorithms. The coursework looks complicated and I am right now trying to run it on Windows. ddd Debugger is horrible. I was stuck trying to figure out what an error meant, which popped out everytime I ran ddd on the executable. To make a program debuggable, you must gcc it with a -g switch. Ah well, ddd has a poor array analyzer. I remember back in my MSc days, when I used visual C++ 98 to examine arrays, and it was so much simpler.

The coursework requires openGL. And to my surprise, the download links to SGI's openGL does not work! I recently learned that Windows OS ships with OpenGL 1.1. I have no clue about where the exes and dlls are located.

My PhD work this week is currently at a Standstill. I am still trying to do my visualization code. On Monday I had translated some of the VTK python/TCL code to C++ for visualizing using some basic rendering function. I cant remember what rendering I used, but thinking about it right now, what could be simpler than MIP rendering??? :) Strangely, at this point I cleaned my ITK build, and it is not compiling anymore. There are scores of errors and perhaps I need to go to Raj or Prof.