Lab 8: Areas and thresholding
In this lab, we will do some experiments with ImageJ combined with
some R analysis.
Assigned: Wednesday, April 2, 2014
Due: Friday , April 11, 2014
This lab will occur over two weeks.
Your report should explain what you have done, and contain snapshots of images in ImageJ, and your results, including any sources on the internet or elsewhere that you might have used.
Problem 1
Start up ImageJ. Read in a file "MPOA20.jpg", which is a section of a
brain slice. First some questions on the image itself, which do not involve
R. These questions, or tasks, are each simple, and are stated in the form
of paragraphs. A few paragraphs have two small tasks.
What is the file type and what is the disginguishing characteristic
of this file type?
What are the x and y
dimensions of the image? How did you find this out?
How many color channels does the image have? How many bits in each channel?
How many bits per pixel? How many bytes per pixel?
(remember to back up your work since "undo" is not fully implemented in imageJ and is
at times unpredictable. You can also use "duplicate" in the "image" menu, which creates
a copy of the file in imageJ.)
Create a bounding rectangle around the big white cell
(oriented at 45 degrees, from bottom-left to top-right).
Let us estimate its area. With the rectangle on the screen,
specify measurement its area.
(if certain windows are not visible that you believe should be, find
the command to "show all" windows, in one of the menus.
What is the area of the enclosing rectangle?
Let us improve on this result. Use the "oval" tool, and adjust the select
to "hug" the whitish cell. Make sure that the cell is completely
contained in the ellipse. Again, choose measure and
report the area of the ellipse. If you cannot see a column that gives the
requested area, find the Set Measurements among the menus,
and turn it on. Perform the measurement again. What is the area of the ellipse?
(hint: the area is approximately (3.14*a*b) where a is the major axis of the ellipse and b is the minor
axis of the ellipse, provided in the measurement data if the fit ellipse option is specified in set measurements.... Of course the area can be obtained directly as well.) If you compute the areas both
ways, the approach should give results close to each other.
From the measurement set, also write down the mean value and standard
deviation for the gray value.
What is the angle formed between the major axis of the ellipse and a horizontal line? Read about "Fit Ellipse" option in "Set Measurements" to figure out how to do this.
Save the measurement set into a comma delimited file (use Save As... menu.)
We now compare these results with some calculations in R.
Make sure the ellipse is visible around the cell.
Save the file in Text Image....
Before continuing in R, let us save a smaller version of the ellipse.
Crop the ellipse (the crop command is in menu image. Now
save this cropped ellipse in a file called ellipse_cropped
(in the format Text Image....
What is the size of the two files you saved? Which is smaller? The cropped or
the non-cropped file with the ellipse? (Always crop when you can to save on
space. Only keep what you need.)
Read the cropped file into R and plot this histogram of the data. (you may have to convert the data to matrix or vector form to accomplish this.)
Compute the mean gray value, and its standard deviation.
Therefore, remove all elements that are equal to 255.
Recompute the mean gray value and the standard deviation after removal of the
background. Compare these values with the value computed prior to removal.
Also compare the value with what was measured using ImageJ.
Final task: plot the histogram of the vector after removal of the background,
and superimpose it with the histogram of the vector before removal. One histogram should be in red, the other in blue. (Hint. Read the information at http://stackoverflow.com/questions/3541713/how-to-plot-two-histograms-together-in-r to figure out how to do this. Several solutions are offered. Pick the one that appears simplest and closest to what we have learned.) Are the histograms different? Why?
Problem 2
Down the file: "nonnetje1.jpg", and read it into ImageJ. The file can be found at http://vethematology.files.wordpress.com/2011/05/nonnetje1.jpg.
This image shows a thrombocyte, in the blood smear of a 4 year old Smew (what is a Smew?) Please include a picture of a "Smew" in your report.
The objective is to determine the area of a single nucleus and a single cell (dark blue region). Rather than use a selection region as in problem 1, we will use thresholding.
The procedure will be as follows: first we'll estimate the area of the cell, then of the nucleus.
After reading the file, convert the image to 8-bit.
Second, choose "Threshold" found in the "Image/Adjust" menu. Set to red (play with options in the Threshold interface panel. Click on "apply". The cells should become black. Remove the region in the center that is somewhat different than the others. Play with the two sliders that control the minimum and maximum of the histogram. You'll see the effect. Now you have a black and white selction region. N
Adjust the brightness slider until you get as much as possible of the non-cell regions to be red. Click on "select" to select the cells. Then "backspace" to white out the selection. Paint over the middle region which has some kind of distorted cell or other type of biological entity (cover with a rectangle as we did in class, click backspace to make it white. You are removing regions of non-interest. If you see other regions (spotty speckles, feel free to remove them.) Click "Apply".
Third, save the image in "Text-Image" format. Use R to compute the area of the cells (all the black regions. The cells might also be white depending on precisely which buttons you pressed.) Count the number of cells by hand, and compute the approximate area of one cell.
Repeat the above process, but adjust the threshold sliders to only cover the nucleus. Use R to compute the average area of the nucleus.
State in the report what you did, and put some snapshots of the images produced in ImageJ.
Consider searching the internet for examples on how to use "Threshold" if the above is somewhat confusing.