Homeworks 5 & 6

36 thoughts on “Homeworks 5 & 6

  1. Hey all,

    I used to be able to get linux to work on my laptop through chrome and the citrux receiver using mylab. But now when I open the Linux desktop I get a blank grey screen. Anyone else having this issue? Anyone know how to fix it? Thanks a bunch!


  2. Here is an alternative for the intrepid. This installs it locally on your personal computer and makes you independent from Citrix Receiver.

    Preparation: Your computer needs a good chunk of memory, ideally 8+ GB of RAM, and you need about 6GB of free hard disk space.

    1) Download and install VirtualBox from http://www.virtualbox.org — Windows, Mac — works for both.

    2) Download the Ubuntu virtual hard disk that I prepared for you from here:


    Note: This is a 3.6 gigabyte download — make sure you have a fast connection. Ideally, you’d download this while in Driftmier. Or I can copy it on a flash drive if you wish.

    3) Unpack the virtual hard disk. It is bzip-compressed and you need an appropriate program (bunzip2, no idea what it is in Windows)

    4) In Virtualbox, start a new virtual machine. When you get to the point where it asks you for the hard disk, say that you have an existing hard drive and give it this file (Kubuntu.vhd)

    5) Finish the virtual machine and start it up. You find not only cimage and ImageJ installed, but a large number of other nifty software packages.

    Note: To make the virtual machine run smoothly, you should give it sufficient resources. I suggest 4 GB of RAM, 2 CPUs (you may want to set an execution cap at 80% or so), give it a bridged or NAT network adapter, and create a permanent shared folder that points to your documents so you can freely exchange data between the virtual environment and your computer.

    Enjoy your freedoms associated for Free software!

  3. Thank you! I got it working!
    I have one more question! What do you mean by smoothing the image in Task 2 of the first part? Is this smoothing the histogram?

  4. Process -> Spatial Filters, then select “Smoothing (Gaussian 3×3)”.

    If you are feeling adventurous (just kidding), you can try the “Generalized Gaussian” further down the list. It gives you a variable kernel size and thus more smoothing strength.

  5. Thanks, btw, for your comments. Even though you figured it out on your own, others may get some good ideas by looking at your comments. This is how it is supposed to work.

  6. This needs to be looked at separately. Start with #4. You’ll find a bimodal distribution, meaning, the background values are spread over a certain range of values. If you wish, use Process -> Background removal -> Parabolic Plane as a reference standard. You’ll see a new image with the background that was removed. Also, you can re-examine the histogram and you’ll see that the background peak has narrowed and shifted to zero. This is the result you are trying to achieve with a highpass filter; this way, you also demonstrate that the low-frequency components that the highpass removes correspond to the background.

    #6 goes back to the early Fourier demonstrations we had. Periodic components show up as peaks in the image. If you look at the Fourier transform and adjust contrast accordingly (use log-abs visualization, it should help), you’ll identify the moire pattern as symmetric groups of peaks. By deleting these specific peaks (total of 8) you remove the periodic component — the moire pattern — completely.

  7. How to delete the peaks… this is funny, because I was quite sure I had some instructions out there. I can’t find them, however.

    Try various ways of bringing out the peaks with the colormaps option (brigthness, contrast, but also log-abs visualization).

    Hover the mouse over one of the peaks and hit “C” for a circle. You should see the blinking circular ROI. (repeated “c” and “C” shrink and enlarge the circle, respectively)

    Use Edit -> Image values to modify the values (set to zero). Make sure that you checked the “all slices” button, because zeroing needs to be performed for both real and imaginary component (!). Repeat for all sets of 4 peaks. You can use the middle button to drag the ROI to a different location. Right button deletes the ROI.

  8. In response to an e-mailed question: This student used thresholding and multiplication as part of the processing chain. Please don’t use thresholding in HW5 — this will become important in HW6, but not before.

    To subtract a blurred version of an image from the original, you can use the following steps:

    • Load the original image
    • Open the image math dialog.
    • Select “push” then execute to move the original image to the background
    • Blur the image
    • Select math’s “sub” and execute to subtract the blurred image (m) from the one previously saved (x)

    I apologize for the somewhat unwieldy image math — this was a design decision at some point to have only one image open at a time. It avoids the ambiguity on which image an operator acts if multiple images are open (as sometimes happens in ImageJ)

  9. I’m really confused about SNR!
    If we had a noise free image wouldn’t the ratio reach infinity because you have no noise? OR would it be close to one? because you deviate from the average equal to the average? Except! We would want a larger signal to noise ratio correct? Because that means more signal and less noise….I’m so confused.

  10. Right… this is the key question. You are right that *in theory*, SNR would go to infinity for a noise-free image. Now ask yourself, does it do that for our SNR approximation? If you had a totally “flat” image, yes — consider one of the homogeneous regions of the Shepp-Logan head phantom. But is the image you have totally flat? I’d say it isn’t, so where does the SD come from? Not *only* the noise, right?

    • Right! It comes from deviations from the tissues correct? By flat image I’m assuming you mean a single slice? or a two-dimensional image rather than 3-dimensional?

      • Actually, “flat” refers to something I occasionally used — the intensity mountainscape where intensity is height. Thy this in cimage:

        Start w/o image and go to Special -> Generate -> Shepp-Logan head phantom. Increase contrast, but don’t add noise.

        Use View -> 3D surface plot.

        Then you’ll see what I mean with “flat”. Compare that to the liver MR slice, which is certainly not flat. And this variability creates a standard deviation even if no noise is present — a real limitation of our “cheap” SNR metric as you can see.

  11. Another clarification in response to an e-mail: The goal of Task 4 is background removal via Fourier filter. You can do this in one step with a highpass filter, or you can do this in two steps with a lowpass filter (very strong blurring) and subtracting this blurred version (i.e., approximate background) from the original image.

    The answer to Task 4 is slightly different, because the background image is asked for. So you need two steps either way. Blur, show the background image; subtract, show the background-flattened image.

    Or use the highpass filter and show the background-flattened image, then subtract that from the original image, which leaves the background.

    Once again, to best show these images, use the Colormaps function to create a good visualization and hit the “create” button to create a compatible PNG image.

  12. I am having some questions about task5, Can anyone explain what exactly that we need to demonstrate in this task? Do we need to demonstrated the histogram of the image after convolution which is similar to the histogram of a image after a high pass filter ?

  13. For whatever reason, I’ve been getting an error when trying to save my filtered background image. Sometimes it goes through- but if it does it’s not 8-bit and I can’t do the image math on that portion. Anyone know what could be causing that?

    • 1) What error do you get?

      2) Sure it is not 8-bit after image math. If the result does not fit 8 bits, cimage automatically expands. To export something that can be imported in a word processor, see comment above:

      “Once again, to best show these images, use the Colormaps function to create a good visualization and hit the “create” button to create a compatible PNG image.”

  14. Do we need one more class day to understand how to do HW 6?

    I’m really confused about what the word cluster means. I feel like I’ve heard it several times but I still don’t know what it really means.
    Also, should I contrast the images before trying to determine a threshold value? Although, I guess that’s the whole point of the homework…

    • Yes, more material is still needed. Most importantly, we need to talk about filters that act on a binary image (such as the mask): morphological filters, watershed segmentation, cluster labeling.

      Simply, a cluster is a bunch of connected pixels in a binary image. Thus, in the segmented image, a cell should be represented by one cluster. You can try something simple (for a head-start): Use a painting program (such as GIMP) and draw a few non-connected shapes in white on black background. Load in cimage and use Process -> Cluster Labeling (check “Tabular Results” and let it label by size rank). The result is probably self-explanatory.

  15. A comment about parabolic plane background removal: With “gold standard” I did not mean that it is the best option. Rather, I wanted to provide a point of reference for HW5.

    Fitting a parabolic plane has its own shortcomings and can in many cases be quite inferior to a well-balanced highpass filter or unsharp masking.

  16. Quick question: When looking at histograms, what does the red line represent in the graph? Is that the mean value or where the threshold is located?

    • There is a lot more information than you need, such as the red line (adjustable histogram percentile) or the blue dot (histogram center of gravity) or the light blue line (smoothed histogram). I implemented those at some point for various research projects. If you are not sure what it means, please ignore those!

      As for the threshold — this is just the question. You’d try to hit the valley between background and features, but this valley may not always be well-defined. Especially when you have cells of different brightness that may cause more than one feature peak…

  17. I’m just wondering if anyone is able to use the clean boundary function on Cimage. I’ve tried it three times and Cimage just shuts off and then I tried to restart the virtual lab and it’s still not working… Is there something I must do to the image beforehand inorder to use ‘clean boundary’ function?

    • Yikes! This should not happen! Can you mail me the image(s), please? I will take care of this for you. Plus find the bug if possible.

      • Oh, is your image binary? Meaning, background regions are represented by the image value zero? It does not make it less of a bug, but the background flood-filling tends to crash if it has to flood-fill the entire image.

  18. For task 2, how do you get the graph of the mean cluster size over the threshold value. I got the number of clusters drawn over the threshold value. And I can pull up the mean cluster size values, but it won’t let me save that data separately from the other data values.

    • Fair question… Do clustering with different thresholds, this is straightforward. You then have the number of clusters $n$.

      Measure image statistics after that. It gives you the area of nonzero pixels in the second block “… if zero is out-of-region…”, now divide this area (number of pixels) by $n$ and you have the mean cluster size.

      Alternatively, take the cluster table and add all sizes (spreadsheet).

  19. Is anyone else having major problem with the Linux desktop on the mylab server? I’ve been using it for a few days now but all of the sudden my Linux desktop shows up black with all of my saved document but I can access the top bar anymore to get to the applications. Anyone else having this problem?

Leave a Reply

Your email address will not be published. Required fields are marked *