Manipulation et analyse d`images numériques
Transcription
Manipulation et analyse d`images numériques
Your images Image processing and analysis Monique Vasseur et Gabriel Lapointe BCM6013 Summer 2011 1 Image processing for what? Image processing for what? Processing for different purposes 2 What can you do with an imaging software? Make your image nicer Crop only one person Zoom on details Erase what you don’t want Replace a spot by an other image Make a montage of pictures Change its format, colors… Can you do that for scientific images? What are you allowed to do with scientific images? NOT EVERYTHING IS PERMITTED! There is rules and ethics in imaging Certain manipulations will destroy your data Quantification needs more caution Be aware that some softwares will automatically and irreversibly modify your image (scaling, stretching, loose metadata ) 3 Ethics in scientific imaging Images are data Always keep the originals Work on copies Always compare images acquired and processed in the same way Do not modify partially an image Log all image modification details, reviewers can ask for them Imaging software, what for? Image processing Image - Image Image Segmentation Image - objects Image Analysis Objects/Image - Informations 4 Imaging Introduction Why ImageJ? Main interface Menus What is a digital Image? Pixel characteristics Intensity in greyscale, pseudocolor and color images Intensity and dynamic range ImageJ image types Image formats and conversion Why ImageJ ? Software in the public domain open source: IT’S FREE! Can run on any system where you can install Java A laptop at home is enough for 95% of the cases If missing memory on your laptop, use one of ESI servers at UdeM Supports multiple types of programming languages Macro in "Java Simplified" (uses existing ImageJ functions) Plugins in Java (add new features) Javascript and Python Frequently updated (every month) Supported by an active community 10 5 ImageJ ImageJ Menus 11 ©2011 Gabriel Lapointe Certains droits réservés The main interface Open, Save, New image Assembly, drawing tools Modification and conversion, geometric operation Filters & Operations Statistics, Measures, graphic Access to plugins ©2010 Gabriel Lapointe Certains droits réservés Window Management Shortcuts to the website, information and updates 12 6 Menu : Edit ● ● ● ● ● Maximum memory Windows 32-bit: the smallest number, 75% of total or 1.4 Gb Windows 64-bit: 75% of total Mac OSX 32-bit: the smallest number, 75% of total or 1.8 Gb Linux 32-bit: 3 Gb Linux 64-bit: Unlimited ©2010 Gabriel Lapointe Certains droits réservés 13 Menu : Image ©2011 Gabriel Lapointe Certains droits réservés 14 7 Menu: Process ©2011 Gabriel Lapointe Certains droits réservés 15 Menu : Analyze ©2011 Gabriel Lapointe Certains droits réservés 16 8 Menu : Plugins ©2011 Gabriel Lapointe Certains droits réservés 17 The Plugins ImageJ can be viewed as a collection of small programs or "plugins" written in java This modular structure has the advantage of allowing easy addition of new features in ImageJ ©2011 Gabriel Lapointe Certains droits réservés 18 9 Recording macro commands and operations register Plugins > Macros > Record... Records the actions taken and implement macro language Can also be used as a logging tool for future references ©2011 Gabriel Lapointe Certains droits réservés 19 Menus : Help ©2010 Gabriel Lapointe Certains droits réservés 20 10 Exercises 0: Launch ImageJ Folder: Logiciels spécialisés 1) Create a new image (assembly) 2) Look at the pictures provided as examples File / Open Samples 3) Have a look on your experimental images ©2011 Gabriel Lapointe Certains droits réservés 21 What is a digital image? 22 11 Digital image Matrix of pixels (Picture Elements) Digital image Pixel: smallest subunit of an image Pixel characteristics x and y coordinates Intensity value (values for color image) The maximum intensity value is defined by the bit depth 12 Each pixel has an xy coordinate & intensity (x,y) (0,0) (3,4) (?,?) ©2011Gabriel Lapointe Certains droits réservés 25 Each pixel has an xy coordinate & intensity Analyse > Plot profile Analyse > Surface plot 13 How does it work with color images? 27 Colors In everyday’s life Painting colors Our eye view Light sources On screen Digital images Does it work the same way? 14 Formation of colors Object colors Paint mix Human view Light sources On screen Digital images Colors are subtractive Colors are additive Primary colors: magenta, cyan & yellow Primary colors: red, green & blue Light reflected by object is visible Screen: self-luminous light source Light absorbed by object is not visible How intensity of a color pixel is written? RGB color image Standard images, fluorescence images Pixel intensity: (R,G,B): WHITE: (255, 255, 255) BLACK: ( 0, 0, 0) RED: (255, 0, 0) YELLOW: (255, 255, 0) GREEN: ( 0, 255, 0) CYAN: ( 0, 255, 255) BLUE: ( 0, 0, 255) 15 Intensity of an HSB color image? HSI (HSB) color image (more suitable for histology stained images) Pixel intensity: (Hue, Saturation, Brightness) WHITE: ( 0, 0, 255) BLACK: ( 0, 0, 0) RED: ( 0, 255, 255) YELLOW: ( 60, 255, 255) GREEN: (120, 255, 255) CYAN: (180, 255, 255) BLUE: (240, 255, 255) RGB Color Image intensity matrix ©2011 Gabriel Lapointe Certains droits réservés 32 16 Color Image intensity value Main interface bar Analyze > Tools > Color Histogram As we move the cursor over different parts of the image, the color values appear in the status bar of the program. RGB color image intensity Image > Plugins > Graphics > RGB profile plot Analyse > Plot profile RGB color Plugins > Graphics > RGB Profiles plot 17 Intensity values 35 Max. intensity is defined by bit depth Max intensity of 1bit image: 1 18 Bit depth defines the max. intensity Max intensity of 8 bit image: 255 12 bit image: 4 095 16 bit image: 65 536 Bit depth and Dynamic range Higher dynamic range permits to see more details; low and high signals together Binary: Fax, Mask 2 (2¹ tones) 4 (2² tones) 8 (2³ tones) 16 32 64 128 8-bits: Camera, Computer screen... 256 (2⁸ tones) ... 12 et 16-bits: CCD Camera, PMT... 4 096 (2¹² tones) ... 65 536 (2¹⁶ tones) 32-bits: deconvolved images... ... 4 294 967 296 (2³² tones) ©2011Gabriel Lapointe Certains droits réservés 38 19 Image type: Binary Only 2 possibilities: Black or white No dynamic range Black = 0 White = … 1 bit image: 1 8 bit image: 255 12 bit image: 4 095 16 bit image: 65 536 Image type: Greyscale Monochrome (one color) in levels of greys Min. = 0 Max. intensity of … 8 bit image: 255 12 bit image: 4 095 16 bit image: 65 536 20 Image type: Color - Pseudocolor Monochrome, each grayvalue is represented by a different color Color is not related to specimen color, but to pixel intensity Min. = 0 Max. intensity of … 8 bit image: 255 12 bit image: 4 095 16 bit image: 65 536 Image type: Color - Monochrome Monochrome, colored in levels of one color Min. = 0 Max. intensity of … 8 bit image: 255 12 bit image: 4 095 16 bit image: 65 536 21 Image type: Color - Multicolored Mix of 3 colors Red, Green and Blue: RGB Bayer mask in Standard digital camera NOT FOR QUANTITATIVE MEASURES You are getting only ¼ red photons ¼ blue photons ½ green photons 3 frames with CCD camera For each frame: Min. = 0 Max. =… 8 bit image: 255 12 bit image: 4 095 16 bit image: 65 536 OK FOR QUANTITATIVE MEASURES But expect delay! Image type: Color - Multicolored Mix of 3 colors Red, Green and Blue: RGB Bayer mask in Standard digital camera NOT FOR QUANTITATIVE MEASURES You are getting only ¼ red photons ¼ blue photons ½ green photons 3 frames with CCD camera ! Note that… Max. intensity for each individual frame is the same as the total added frames in the RGB overlay image: 3 x 8 bit image: 24 bit RGB 3 x 12 bit image: 36 bit RGB 3 x 16 bit image: 48 bit RGB 255 4 095 65 536 OK FOR QUANTITATIVE MEASURES But expect delay! 22 Image type: Multi-dimensional Image types in ImageJ Binary: 1 bit (21) Greyscale: 8, 12, 16 bit Color Pseudocoloured: 8, 16, 32 bit indexed colors Monochrome color: 8, 16 bit color Multicoloured: 8, 24 or 32 bit RGB Composite: “stack of channels”: keeps originals as is Multidimensional: hyperstacks 23 Image types in ImageJ 8-bit Binary images are considered as 8-bit images with only 2 values from 0 (black) and 255 (white)16-bit 32-bit: addition of 4 8-bits images 8-bit Color Grayscale with artificial coloring (Lookup Table) RGB Color Standard color images RGB Stack Images whose colors have been separated into their red, green and blue in a stack (group of pictures stacked on top of each other). HSB Stack Images whose colors have been separated into their components Hue, Saturation and Brightness. ©2011 Gabriel Lapointe Certains droits réservés 47 Need info about your image? Image > Show info Image > Properties ©2011 Gabriel Lapointe Certains droits réservés 48 24 Image conversion In ImageJ 49 8 or 16 bit color TO RGB color Image > Type > RGB color R Original monochrome 16 bit green Transformed to RBG color Be careful each 16 bit channel will be decreased to 8 bits G B 25 16 bit color images TO Hyperstacks Image > Color > Merge Channels… (Create composite) Hyperstack Advantages: Composite Preserves bit depth Multi-color (the first 4 colors are easy, more requires a macro) Multidimensional (Z and T axis supported) preserves the16 bit Dynamic range of original channels Can be spilt to original image without data loss Look at: Image > hyperstack > Channels tools... 2011-06-09 51 ©2011 Gabriel Lapointe some rights reserved. RGB color TO individual channels Image > Color > Split Channels Split in 3 grayscale images Image > LUT Original RGB color 26 RGB color TO a montage Plugins > Color Function > RGB to montage Original RGB color If pseudocolour option is OFF, each channel will be greyscale RGB color to greyscale Image > Plugins > Graphics > RGB profile plot RGB color To greyscale Each color intensity is divided by 3, And then added together To give the new grey value 27 RGB color TO individual channels Image > Color > Split Channels Split in 3 grayscale images Image > LUT RGB color of 4 channels If not a composite image, you can not get back to your 4 original images Image formats Commun format Specialized Generally limited to 8 bit, no meta-data and unique image. Contain all the information (lossless), with meta-data, and can be multidimensional Lossy Standard: Can be opened in most software .jpg .tif .gif .ics Lossless .tif .ome.tif and .ome Proprietary: Frequent incompatibility. .png .stk (Metamorph) .raw .lei & .lif (Leica) .gif .lsm (Zeiss LSM) .oif (Olympus Floview1000) .nd2 (Nikon)... 56 ©2011 Gabriel Lapointe Certains droits réservés 28 Conversion to smaller files or other formats Compression hazards ©2011 Gabriel Lapointe Certains droits réservés 57 Pre-processing: Enhance Visualisation Image histogram Brightness and contrast LUT Single pixel operations on single image Single pixel operations on multiple images 58 29 Image Histogram To enhance visualisation 59 Histogram Analyze > Histogram Représentation de la répartition de l'intensité lumineuse d'une image où l'on porte en abscisse le numéro des niveaux de gris et en ordonnée pour chaque niveau le nombre de pixels ayant l'intensité correspondante à ce niveau. Frequency distribution of the image intensity Linear Logaritmic The abscisse represents the gray level The ordinate, the number of pixels ©2011 Gabriel Lapointe Certains droits réservés 60 30 The interpretation of the histogram Underexposed Normal Overexposed Reduced dynamic range ©2011 Gabriel Lapointe Certains droits réservés 61 Histogram and Microscopy images In fluorescence image The biggest peak is often the background! An easy image to work with might have a signal 3X higher than the background ©2011 Gabriel Lapointe Certains droits réservés 62 31 Brightness and Contrast To enhance visualisation 63 Comparison of images Why do I see red where it was supposed to negative? What is the problem? Tubuline control PABP control (no tubuline marquage) BE CAREFUL TO Autoscale display Adjustment of brightness and contrast Display range: 143-3722 Display range: 140-240 32 Comparison of images Tubuline control PABP control (no tubuline marquage) Why do I see something strong in red. I didn’t expect this! Same display range for both images Display range: 143-3722 Display range: 143-3722 To be comparable, the images issued from the same channel (same filter cube) should be displayed with the same range of values Adjusting brightness and contrast Image > Adjust > Brightness/Contrast... Adjusts the maximum and minimum value of the pixels and change the brightness and contrast of an image Works on all types of images For RGB images, Color Balance allows you to control each color individually Will not change the value of the pixels Unless you press Apply (for 8-bit and color images only) Set can directly enter the maximum or minimum values Useful to normalize multiple images ©2011 Gabriel Lapointe Certains droits réservés 66 33 Adjusting brightness and contrast Image > Adjust > Brightness/Contrast... ©2011 Gabriel Lapointe Certains droits réservés 67 LUT: Lookup tables To enhance visualisation 68 34 Lookup Table (LUT) Image > Lookup Table Notes: Image is not converted into RGB Pixel values are preserved Image can be used in subsequent testing ©2011 Gabriel Lapointe Certains droits réservés 69 Exercises 1: Texte-1.tif Read the text without changing the contraste Make text white on black background Cellules-1.tif Identify: Image creation date software used exposure time pixel size Make transfected cells visible (only) ©2011 Gabriel Lapointe Certains droits réservés 70 35 Operations on pixels Point or Single pixel Local Global Operations Changes the pixel values according to different mathematical functions Single pixel operations: Change the value of a pixel without considering the value of adjacent pixels Filters : Change the value of a pixel depending on the value of adjacent pixels 72 36 Single pixel operations To enhance visualisation Addition and subtraction •Multiplication and division •Histrogram stretching •Gamma • Mathematics and images ! Addition Intensity Intensity Subtraction Pixels Pixels Multiplication Logarythmic Intensity Intensity Division Exponential Pixels Pixels ©2011 Gabriel Lapointe Certains droits réservés 74 37 Addition and subtraction Process > Math > Add... -125 Original +125 Addition and subtraction = change the image brightness 75 ©2011 Gabriel Lapointe Certains droits réservés Multiplication and division Process > Math > Multiply... X 0.5 Original X2 Multiplication and division = change the image contrast ©2011 Gabriel Lapointe Certains droits réservés 76 38 Mathematics on images Multiplication Addition Intensity Intensity Division Subtraction Pixels Pixels Fluorescence light emission is an additive process Transmitted light absorption is a multiplicative process So background correction operations seems better when using a substraction for fluorescence image and division for transmitted light images. Automatic contrast enhancement Process > Enhance Contrast 39 Automatic contrast enhancement Process > Enhance Contrast ©2011 Gabriel Lapointe Certains droits réservés 79 Gamma (γ) : logarithmic or exponential factor Process > Math > Gamma Bring non-linear change to the pixel intensity ©2011Gabriel Lapointe Certains droits réservés 80 40 Color image gamma 1.0 Gamma 2.2 on the same image 41 The importance of gamma (γ) 83 ©2011 Gabriel Lapointe Certains droits réservés The influence of gamma (γ) Original Brightness & Contrast Gamma 0.5 ©2011 Gabriel Lapointe Certains droits réservés Gamma 2 84 42 Gamma correction (γ) Process > Math > Gamma... Plugins > Filters > Gamma scroll ©2011 Gabriel Lapointe Certains droits réservés 85 Image enhancement 43 Single pixel operations To help visualisation of multiple images Overlay of images 87 Image Overlay Process > Image Calculator... 16-bit Images with LUT Convert to RGB You can also use plugins: Addition Color Merge ● 2 images at a time ●Choice of several colors ●images 16-bit supported ● RGB Gray Merge ● Up to 4 images at a time Weak color choice ●Transform 16 bit to 8-bit (24 bit result) ● ● Image > Color > Channel Merging... ● Up to 4 images at a time Weak color choice ●8, 16 et 32 bit ●Can provide an Hyperstack (depth conserved) ● ● 88 ©2011 Gabriel Lapointe Certains droits réservés 44 Image Overlay Process > Image Calculator... Subtraction Convert to RGB 16-bit images with LUT Addition ©2011 Gabriel Lapointe Certains droits réservés 89 Image Overlay Process > Image Calculator... Additions Additions + Subtractions ©2011 Gabriel Lapointe Certains droits réservés 90 45 Mask subtraction for data mining Process > Image Calculator... Inverted Mask Subtraction Is there a signal of tubulin in the nuclei? 91 ©2011 Gabriel Lapointe Certains droits réservés Background correction = + Edit / Invert Background (illumination problem) – to eliminate ©2011 Gabriel Lapointe Certains droits réservés 92 46 Exercises 2: Restore-1.tif Improve image Cellules-3_*.tif Improve images (Contrast, γ, etc.) Make a color assembly ©2011 Gabriel Lapointe Certains droits réservés 93 Pre-processing: Enhance Visualisation Local operations on pixels: Median filter Mean filter Modal filter FFT Bandpass filter 94 47 Filters in imagery ©2011 Gabriel Lapointe Certains droits réservés. 95 The concept of Kernel ©2011 Gabriel Lapointe Certains droits réservés. 96 48 Kernel size and shape r=0.5 r=1.0 r=1.5 r=2.0 r=2.5 r=3.0 r=3.5 r=4.0 r=4.5 r=5.0 r=5.5 r=6.0 ©2011 Gabriel Lapointe Certains droits réservés. 97 The noise Random variation in the intensity of the pixels. Do not confused with the background, the black level or a nonspecific signal. Salt & pepper : Black pixel in a clear area and white in a dark area. Often caused by a dead pixel in the camera. Gaussien : Variation with a Gaussian distribution, independent of the intensity of the pixels. Generally increases with the voltage applied to the detector. 2010-11-12 ©2010 Gabriel Lapointe Certains droits réservés. 98 49 Noise correction Process > Filters > ... Median Gaussian Mean 99 ©2011 Gabriel Lapointe Certains droits réservés. The impact of the size of the kernel Median Mean r=0.5 r=1.0 r=2.0 ©2011 Gabriel Lapointe Certains droits réservés. r=6.0 100 50 Edge Enhancement Process > Filters > ... Sharpen Variance Unsharpen 101 ©2011 Gabriel Lapointe Certains droits réservés. Edge Enhancement : a bad idea Process > Filters > ... Sharpen Variance Unsharpen ©2011 Gabriel Lapointe Certains droits réservés. 102 51 The space of sequences Fourrier transform (Fast Fourrier Transform) ©2011 Gabriel Lapointe Certains droits réservés. 103 Bandpass Filter Process > FFT > Bandpass Filter... ©2011 Gabriel Lapointe Certains droits réservés. 104 52 Periodicity and frequency ©2011 Gabriel Lapointe Certains droits réservés. 105 Images rebuild with FFT Process > FFT > ... FFT Inverse FFT ©2011 Gabriel Lapointe Certains droits réservés. 106 53 Exercises 3: Restore-3.tif Remove image noise using the filters Try several and see the differences, which seems most appropriate? Cellules-5_*.tif (series of images) Enhancing images using filters… Attempt to obtain greater precision of details ©2011 Gabriel Lapointe Certains droits réservés. 107 Afternoon workshop Work on your images Follow the procedures which will be given to improve your images Questions, problems ... Ask us, we're here for you!! 54 Ressources Official website : http://rsbweb.nih.gov/ij/index.html Macbiophotonics : http://www.macbiophotonics.ca/imagej/ Wiki : http://imagejdocu.tudor.lu/doku.php Diffusion list : https://list.nih.gov/archives/imagej.html Burger et Burge : Digital Image Processing, An Algorithmic Introduction using Java; Springer Verlag, 2008 http://www.imagingbook.com/ 109 ©2011Gabriel Lapointe Certains droits réservés Plugins : Installing and Compiling (1) The plugins are easily installed simply by placing them in the plugins folders To find the plugins folder: Plugins > Utilities > ImageJ Properties... Find the line that begins : Menus.getPlugInsPath The plugins are found in 3 formats *.java : Source code, can change the plugins. Need to be compiled to use them (Plugins> Compile and run ...) *.class : File already compiled that can be used directly by ImageJ *.jar : Plugins for more complex, requiring multiple class files are grouped in an archive file. Can be used directly by ImageJ ©2011 Gabriel Lapointe Certains droits réservés 110 55 Plugins : Installing and Compiling (2) All *. class, *. jar and *. txt in the plugins folder, and contain a "_"in their name, will be recognized by ImageJ and accessible in the menu Plugins. ©2010 Gabriel Lapointe Certains droits réservés 111 56
Documents pareils
ImageJ_bcm6013-E2011-J2- PL-MV-final
Exclude from the first image what
is common with the second image