Assignment 8: Basic use of ImageJ
In this lab, we will do some experiments with ImageJ combined with
some R analysis.
First task: install ImageJ. Use Google to find the main site, or use the link provided in the class notes.
Start up ImageJ. Use Google Images to find a pictures of a cell in one of the following organs: liver, lung or stomach. The dimensions of the image should be {\em at least\} $1024 \times 1024$ . Ideally, the image should be in png, gif or tiff format. Download this image, load it into imageJ, and answer the following questions using the Properties and Info windows:
What is the file type?
What are the images dimensions?
What the amount of space the file occupies on disk?
How many bits are used per pixel?
What kind of color file is it? (RGB, gray, lookup table, etc.)
Note: the Undo command does not always function as expected, so create copies of
any image you wish to work with: use the Image/Duplicate... menu.
Save the file in TIFF format (with a different file name), and specify the amount of
space the save file occupies on disk (TIFF stores the file in uncompressed format.)
Compute the compression ratio, defined as the size of the uncompressed file divided by the size of the compressed file. (Usually, lossy compression results in larger ratios.)
Also save the original file in jpeg format, at 10% quality. You must go to
the menu edit/options/InputOutput... and set the appropriate parameter. Again, recompute
the compression ratio beween the 10% jpeg quality file and the file in TIFF format.
What amount of space does the file occupy on disk?
Before saving a file in "Text Image format", convert it to a "gray image" file,
where each pixel is only 8 bits (one byte). This is accomplished through
the menu Image/type/8-bit, which converts the image in-place (the original image is
replaced; make a duplicate if you wish to keep a copy, or first save it to disk to be
reopened, with a different name, if needed at a later time.)
Save the file in "Text Image" format and read it into "R" using the "read.table()"
function. Each number in the text file is
a gray value (0 is black, 255 is white). Use R to compute the mean gray value and
the standard deviation. Plot a histogram of the gray values. Use the Shapiro.test
function to evaluate whether the histogram is or is not approximately normal.
(Hint: you will have to convert the data.frame to a matrix using as.matrix() function.)
Use "R" to add a random integer value to each pixel of the image, using the
"sample()" function and the "replace" argument set to TRUE. Sample() should return
a list of integers in the range 0 to 10 for each element of the matrix. Plot the modified
histogram.
As an additional challenge (not-graded), save the modified matrix in a new
file in "Text Image" format, read it into ImageJ, and plot the resulting image.
Show a side-by-side plot of the old and new images.