Image analysis workshop
ICASS 2015
Halifax
1
Jesse Greener
Microfluidics and Spectroscopy of Materials
Laval University, Department of Chemistry
Pavillon Alexandre-Vachon
1045, avenue de la médecine, local 3607
https://jgreener.chm.ulaval.ca/
Image analysis
workshop plan
1- Human vision background
2- Digital images
3- Introduction to digital image processing
4- Image processing vs. data manipulation-examples
5- Introduction to imaging processing with ImageJ
2
Section 1 - Human vision
Section 1 Plan
1- The human eye and visual representation of the real world
2- Introduction to digital images
3- Introduction to image processing
4- Digital image manipulation-examples
3
Part 2 – Human imaging: the eye
The human eye:
We all have them.
Data is acquired and represented in very similar way to scientific instrumentation:
consisting of optical elements and photo detectors.
4
Part 2 – Human imaging: the eye
Detection elements: cones and rods:
Cones : colour discrimination high resolution imaging.
Rods: colourless, high sensitivity for low-light levels, primary detector for
peripheral vison.
Photo transduction describes mechanism for capture of a photon and conversion
to a neural signal. It is a complicated biological process.
5
Part 2 – Human imaging: the eye
Detectible colour range : “visible spectrum”
6
Part 2 – Human imaging: the eye
Primary colours : inspired by 3 types of cone detectors in the eye
ɣ,β,ρ cones differences in
-frequency
-sensitivity
Colour blindness test :
http://www.xrite.com/online-color-
test-challenge
Colour sensitivity spectrum
after sensitivity adjustment
of ɣ,β,ρ cones
7
Part 2 – Human imaging: the eye
Rods for colourless vision, in low-light environments:
All frequencies are collected, but…
they do not register in the brain as colour.
Maximum light sensitivity at 550nm.
Corresponds to what? 8
Part 2 – Human imaging: the eye
Spatial resolution (visual acuity): measured ability to discriminate b/w two
closely spaced objects. Measured by:
Eye charts: Contrast sensitivity:
9
Part 2 – Human imaging: the eye
Similar concepts in human and scientific vision:
-Light intensity
-Light frequency
-Position, changing position (motion)
-Photodetectors (colour/b&w)
-Frequency reconstruction based on RGB detector elements
-Limits of detection (intensity, target duration, spectral window, spatial and spectral
resolution)
Sensitive to: -Colour (100 different colours ). -Intensity (16-32 shades of grey), -Minimum number of photons to be registered by humans is 5-14. -Differences in position (1-3 cm from 20 m)
-Motion via simultaneous imaging with peripheral vision (low resolution due to low clustering of cones and rods away from central focal point)
-Flickering light (100 ms rods, 10-15ms cones)
10
Part 3 – Introduction to Digital images
What is an image? : A visual representation of a real-world target object.
Sensing based on :
• Optical imaging microscopy, spectral imaging photons.
• Electron microscopy electrons, tunneling barrier between sample and tip.
• Atomic force microscopy force-distance curves, tip deflection, etc, from
interaction between AFM tip and sample.
CHM 7001 optical imaging microscopy/spectral imaging.
Therefore, we talk about photons and optical elements.
11
Part 3 – Introduction to Digital images
Why use micro imaging?
To acquire optical images at the microscale that reveal information that cannot
be seen by the eye:
• Discriminate between very close objects
(improve spatial resolution and magnification)
• Discriminate between subtle differences in photon intensity
• Extend the sensitivity outside of visible spectral bandwidth
• Analyse very small that chages/movemement in samples in time
• Precisely coordinate measurements with other events
12
Part 3 – Introduction to Digital images
How are images represented by a computer?
An image
is a visual representation of… …an array of numbers
13
Part 3 – Introduction to Digital images
Pixel resolution:
Screen resolution : Pixels Per Inch (PPI)
Print resolution : Dots Per Inch (DPI)
Dots/Pixels per square inch : Monitor resolution = 68-110 PPI Eg: 72 PPI = 72 spatial positions (pixels) in 1” 72 PPI image has 722 (=5184) pixels in a 1” x 1” square
Dots/Pixels per square inch : 1080x1920 ≈ 2M Screen dimensions = 11 in x26 in = 286 in2
Resolution = 7250 PPI2
= 85 PPI
14
Part 3 – Introduction to Digital images
Pixel resolution:
Note: Camera resolution often quoted in Megapixels
Estimated DPI 35mm film: 20 megapixels
MegaPixels : Total number of camera sensing pixels Example : 5 Megapixel camera 2560x1920=4 915 200 ≈ 5 Mpixel
15
Part 3 – Introduction to Digital images
Pixel resolution:
Note: Camera resolution often quoted in Megapixels
Pixels distributed over the sensing area
MegaPixels : Total number of camera sensing pixels Example : 5 Megapixel camera 2560x1920=4 915 200 ≈ 5 Mpixel
Which requires a certain pixel size
16
Part 3 – Introduction to Digital images
Display resolution: Due to fixed monitor display resolution, higher megapixel
resolution means larger display size.
17
Note: This is why when you change your monitor resolution, the size of all
display items change.
Part 3 – Introduction to Digital images
Bit-depth resolution in greyscale:
8-bit: intensity ranging from black to white is binned into 28 = 256 different values
(approximately 4 times more intensity sensitivity than the eye).
16-bit: represents 216 = 65 536 different values.
Nu
mb
er
of
pix
els
Pixel intensity 18
A histogram
Part 3 – Introduction to Digital images
RGB colour images:
19
RGB histogram
Part 3 – Introduction to Digital images
RGB colour images:
Bit-depth resolution in colour:
15-bit rgb colour (5-bit red, 5-bit green, 5-bit blue)=25x25x25=215=32 768
16 bit rgb (5-bit red, 6-bit green, 5-bit blue)=25x26x25=215=65 536
Rgb24 (“True colour”): 28 bits red, 28 bits green, 28 bits blue
20
Part 3 – Introduction to Digital images
R G B
*0* 0 0
1 1 1
2 *2* 2
3 3 *3*
4 4 4
5 5 5
6 6 6
7 7 7
+ =
0,2,3
RGB limited intensity values:
Example: RGB9: 23 bits Red, 23 bits Green, 23 bits Blue
21
Part 3 – Introduction to Digital images
R G B
*0* 0 0
1 1 1
2 2 2
3 3 3
4 *4* 4
5 5 5
6 6 *6*
7 7 7
+
0,4,6 0,2,3
+ =
Therefore, RGB9 can only represent 2 intensities for pixel : 40% G 60% B
22
RGB limited intensity values:
Example: RGB9: 23 bits Red, 23 bits Green, 23 bits Blue
Part 3 – Introduction to Digital images
RGBA Bit-depth resolution in colour 4 components:
“RGB32”: RGBA32: 28 bits Red, 28 bits Green, 28 bits Blue, 28 bits Alpha (for intensity)
“RGB64”: RGBA64: 216 bits Red, 216 bits Green, 216 bits Blue, 216 bits Alpha (for intensity)
RGB rumber
Alpha
23
Part 3 – Introduction to Digital images
R G B
*0* 0 0
1 1 1
2 *2* 2
3 3 *3*
4 4 4
5 5 5
6 6 6
7 7 7
+
RGBA Bit-depth resolution in colour - 4 components:
Example: RGBA12: 23 bits Red, 23 bits Green, 23 bits Blue, 23 bits Alpha
A RGBA
= =
0,2,3 RGB
1,2,4,A
+
24
Image dimensionality:
A 1D image can be produced using the plot profile function
Part 3 – Introduction to Digital images
2D
1D
Exercise:
Using ImageJ:
Open image (File/Open Samples/Dot Blot)
Draw a line with line tool
Generate plot profile (Analyse/plot profile)
Image dimensionality:
2D
3D
4D
5D
Part 3 – Introduction to Digital images
26
Why use Image Processing?
1. To improve the appearance of the image.
2. To bring out obscure details in an image.
3. To carry out quantitative measurements.
Global contrast/brightness change
Local changes based
on original intensity
Local changes
based on position
Part 4 – Introduction to image processing
27
Image processing :
Ranges from simple global changes to contrast, to complex multistep data
analysis using:
- macros for automation
- other programs (matlab) for data preprocessing
- batch processing of many files at once
- Etc.
Part 4 – Introduction to image processing
28
Image processing :
Ranges from simple global changes to contrast, to complex multistep data
analysis using:
- macros for automation
- other programs (matlab) for data preprocessing
- batch processing of many files at once
- Etc.
When processing goes too far:
Image manipulation is data manipulation
29
Part 5 – Image manipulation =
data manipulation
θ
30
Part 5 – Image manipulation =
data manipulation
31
Part 5 – Image manipulation =
data manipulation
32
Part 5 – Image manipulation =
data manipulation
33
Part 5 – Image manipulation =
data manipulation
34
Part 5 – Image manipulation =
data manipulation
35
Part 5 – Image manipulation =
data manipulation
36
Part 5 – Image manipulation =
data manipulation
37
Rossner M , and Yamada K M J Cell Biol 2004;166:11-15
Merging fields of view:
38
Selective enhancement (immunogold nanoparticles)
Rossner M , and Yamada K M J Cell Biol 2004;166:11-15
39
Selective enhancement
Manipulation of blots: brightness and contrast adjustments.
Rossner M , and Yamada K M J Cell Biol 2004;166:11-15
Global (over)
enhancement by contrast
40
Histogram-equalized stretch
a. Contrast enhancement (linear uniform stretch) :
b. Contrast enhancement (non-linear / non-uniform) :
Image “manipulation”:
• Non-linear modifications that selectively enhance/change parts of the image
• Merging objects from multiple fields of view
Linear vs. non-linear image adjustments
Problem avoided if: • All image processing steps are explained • Original image is given (ie in supporting
information) • We do not rely on images as data, but
quantitative image analysis of images
IF presented as the original image
41
Image Analysis 1
1- Introduction to image analysis software “ImageJ”
-development history
-ImageJ vs. Fiji
-installation
-ImageJ website
-sample images
-tour of software environment
2- Basic image analysis using ImageJ:
-opening/saving a file
-file size vs. bit-depth and image-resolution
-calibration
-histograms, “live updates”
-contrast, brightness, saturation
-measurement: linear profiles, statistical information
-Region of Interest (ROI) and local measurements/manipulations
-image calculations
42
http://rsb.info.nih.gov/ij Adapted from : Joel B. Sheffield 43
ImageJ
• An adaptation of NIH image for the Java platform.
• Can run on any computer systems that can run Java (Sun Microsystems)
• Open source
• Two powerful scripting languages
– Java Plugins
– Macro Language
• Continual Upgrades
• Active community of several thousand users
44
Resources
45
1. Ferreia, T. et Rasband, W. Ieds) « ImageJ User Guide : IJ1.46r », National Institues of Health,
2012. (lien)
2. Baecker, V. (ed) « Workshop: Image Processing and Analysis with ImageJ », Montpellier RIO
Imaging, 2013. (lien)
3. Miure, K (ed) « Basics of image processing and analysis », Centre for Molecular and Cellular
Imaging EMBL Heidelberg, 2014. (lien)
4. ImageJ Website: http://imagej.nih.gov/ij/
5. Fiji Website: http://fiji.sc/Fiji
1.ImageJ Website: http://imagej.nih.gov/ij/
46
1. Features
2. Documentation ImageJ User Guide
3. Documentation Keyboard Shortcuts
4. Mailing list
5. Downloads example images (get these)
Menus
Introduction to the Main Menu
Of these, we’ll concentrate on:
– Image
– Process
– Analyze
– Plugins
– Help
48
49
Principale interface
Open, save, create image
Design tools
Modificatino and conversion, geometric operations
Filters and math operations.
Statistics, measurements,
graphs
Plugins and macros
Window management
Links to the website, updates
Help Menu
50
Opening and saving files
51
Drag and Drop files onto IJ control strip, or
Open samples
Exercise: open sample image “Dot Blot”
Image Menu
52
Demo:
1) Dot blots
Opening and saving files
53
Dot_Blot.tif (open sample images)
File size = 141kB
Adjust size reduce save
Zoom comparison.
File size comparison
Save as jpg
File size = 7kB
Save back to tiff
File size = 141 kB
Opening and saving files
54
Dot_Blot.tif (open sample images)
File size = 141kB
Adjust size reduce save
Zoom comparison.
File size comparison
Exercise:
Save as jpg
File size = 7kB
Save back to tiff
File size = 141 kB
Zooming
Pixels, position indicator, intensity value
Opening and saving files
55
Dot_Blot.tif (open sample images)
File size = 141kB
Adjust size reduce save
Zoom comparison.
File size comparison
Exercise:
Save as jpg
File size = 7kB
Save back to tiff
File size = 141 kB
Zooming
Pixels, position indicator, intensity value
Opening and saving files
56
M51c.tif (open sample images)
Demo:
1. Save as jpg
File size = 4kB
Do an image subtraction of new file
from original file.
2. Save back to tiff
File size = 160 kB
Do an image subtraction of new file
from original file.
Opening and saving files: Best practice
57
ALWAYS KEEP A COPY OF
THE ORIGINAL .TIF FILE.
Image Menu
58
Look Up Tables (LUTs)
59
Dot_Blot.tif (open sample images)
File size = 141kB
Image Adjust Type
Apply LUT
Histogram comparison
“Ice”
“fire”
Analyze Menu
60
The Image Histogram
Log Scale
The histogram shows the number of pixels of
each value, regardless of location. The log
display allows for the visualization of minor
components. Note that there are unused pixel
values
61
In this case, the log display indicates that virtually all pixel values are used, even
though they are a small percentage of the total.
Log Scale
62
Image Menu
63
Demo:
1) M51.tif
Adjust brightness contrast
Saturation?
No! Pixel values do not change.
Process Menu
64
Process Menu
65
Vs.
Math: +6000
Process Menu
66
Vs.
Image Calc.
+
Analyze Menu
67
Demo:
1) Dot blots
-Measure
-Set measurements
-Changing measurement types and loss of information
2) Embryos
-RGB
Analyze Menu
68
Demo:
1) Results
-Set measurements
-Make measurements
-Use math function
-Summarize
2) Edit
-Copy data
3) Plot in Excel Exercise:
1) Open M51 Galaxy sample image
-Set measurements
-Make measurements
-Use multiply command in Process/math menu (x2)
-Make measurement
-repeat 5 times
3) Plot in Excel
Analyze Menu
69
Subtract (-25)
y = 165,68e0,6931x
0
500
1000
1500
2000
2500
3000
0 1 2 3 4 5
y = -25x + 2650,6
2540
2550
2560
2570
2580
2590
2600
2610
2620
2630
0 1 2 3 4 5
Multiply (x2)
Brightness Adjustment
The brightness adjustment essentially adds or subtracts a constant to every pixel,
causing a shift in the histogram along the x axis, but no change in the distribution 70
Contrast Enhancement
For contrast enhancement, a lower value, in this case, 88, is set at zero, and a higher value, 166, is set at 255. The values of each of the pixels are adjusted proportionately. Note that because of the integer values, not all of the pixel values are used. 71
72
Addition and subtraction Process > Math > Add...
Original -125 +125
Addition and subtraction = modification in the image brightness
2500
2550
2600
2650
0 5
73
Multiplication et division Process > Math > Multiply...
Original
X 0.5 X 2
Multiplication and division = modifies the image contrast
0
1000
2000
3000
0 5
74
Automatic optimization of contrast
Process > Enhance Contrast
Thresholding
75
Analyze particles
Plugins Menu
76
Automation with ImageJ: Macros
78
Image stacks
Demo: Open Stack1-5 images “Set properties” Z-stacks, time-stacks, etc. “Set scale”
79
Image stacks
Stack to images Images to stack
Batch commands
• Simple
• Prewritten code for certain
functions
• Operates on image file from
certain directories
• Extendable with marcos
Why write a macro?
•Consistency – same procedure for all
images
•Speed – for large numbers of images or
repetitive tasks
•Documentation – for publication of novel
methods
•Sharing – within or between groups
Example macro
General approach: • Record
• Modify
• Execute
Demo: • Open Stack1-5 images
• Record macro
• Define measurement area
• “measure”
• Repeat