Next: Underlying Structure Up: Some Basic Examples: Previous: Saving the Integrated

Using an Integrated Image for Image Masking

First, let us clear some of the unneeded variables from the workspace:

     clear PETsummed1 ratio clipneg clippos

Now, we will use PETsummed2 for a very simple form of image masking: namely, we will use only pixels whose values in the integrated image are greater than the mean of the integrated image. For CBF studies, this creates a usable mask that contains only head. This is done by calculating the mean of the integrated image, and creating another image consisting entirely of 1's and 0's (a ``boolean'' image), where a 1 indicates that the pixel is inside the head, and a zero indicates outside:

     avg = mean (PETsummed2);
     mask = PETsummed2 > avg;

We can view the mask as an image itself to see a silhouette of the brain at this slice:

     viewimage (mask);
Or, we can apply the mask to the summed image and view it. To apply the mask to an image, simply perform an element-by-element multiply using the .* operator on the mask and the image; since mask consists entirely of ones and zeros, every point in the image will either be set to zero or unchanged. Thus,

     PETsummed2 = PETsummed2 .* mask;
     viewimage (PETsummed2);
will display the trapezoidally integrated image with out-of-head data set to zero.

Finally, to see just how many pixels are ``on'' in the mask, you can type

     size (find (mask))
The fact that only a fraction of the entire image consists of image data means that masking can be used to great advantage when performing analysis that requires computations for every pixel. (Generally, this should be avoided if it is all possible to take advantage of MATLAB's vectorized structure.)