Introduction to Image Processing Earl F. Glynn Scientific Programmer Bioinformatics 8 March 2002 1 Introduction to Image Processing • Pixels: Grey Scale • • • • Pixels: Color Color Issues Image Manipulation Image Enhancement 2 1 Introduction to Image Processing Pixels: Grey Scale 1.0 (white) 255 – 8 bits 16383 – 14 bits 65535 – 16 bits 0 (black) 24 Columns 106 107 112 110 115 118 118 117 113 122 119 105 113 117 104 76 115 128 89 98 110 118 120 118 130 120 122 125 115 119 115 122 113 105 117 129 87 95 115 118 123 124 124 129 123 129 126 116 123 124 116 111 117 118 108 107 110 118 123 121 127 130 126 133 109 119 132 118 117 116 113 116 122 118 121 118 120 123 124 116 115 117 96 109 122 123 121 124 112 112 118 121 129 118 121 117 103 108 110 108 107 101 125 121 120 131 117 108 123 129 124 120 119 103 91 86 100 101 101 100 117 107 117 128 123 117 131 138 123 116 106 102 68 53 68 65 66 78 96 108 119 127 128 118 137 133 117 106 101 82 46 46 44 42 28 36 85 104 118 131 125 121 136 128 111 90 78 47 38 30 45 39 20 25 55 103 109 120 135 130 132 127 103 105 58 42 38 40 51 43 28 24 49 92 112 126 130 132 135 119 96 106 63 36 75 185 175 95 56 34 52 82 115 124 123 126 135 118 93 103 42 37 137 213 210 141 117 35 43 100 115 130 127 128 136 122 96 117 63 41 98 194 195 98 40 42 47 99 116 130 129 125 136 123 97 106 62 39 32 84 90 32 35 37 64 90 108 126 118 116 129 132 126 126 101 111 88 106 58 75 52 76 37 51 121 68 199 129 59 44 38 46 46 89 86 95 95 119 116 123 129 136 130 134 129 126 126 134 123 100 87 86 89 87 84 66 86 85 113 121 126 131 133 130 110 128 120 119 99 94 96 88 99 92 86 108 121 125 126 125 127 128 104 117 114 120 116 112 106 116 123 96 96 117 127 129 121 125 126 123 89 99 118 123 130 120 116 116 123 116 115 126 131 120 127 122 125 122 18 Rows Matrix: 24 Columns x 18 Rows = 432 numbers 86 86 109 122 125 121 120 114 127 124 124 127 127 117 125 117 123 116 82 94 116 116 122 121 117 121 129 121 126 129 125 117 125 121 117 121 99 101 111 102 126 125 115 119 114 115 118 119 122 112 118 118 123 117 Each number is a picture element or “pixel” 3 Introduction to Image Processing Pixels: Grey Scale 0 (black) 24 Columns 1.0 (white) 255 – 8 bits 16383 – 14 bits 65535 – 16 bits Each square is a picture element, or “pixel” 18 Rows 24 Columns x 18 Rows = 432 pixels Not all display levels are perceivable on all devices 4 2 Introduction to Image Processing Pixels: Grey Scale 106 107 112 110 115 118 118 117 113 122 119 105 113 117 104 76 115 128 89 98 110 118 120 118 130 120 122 125 115 119 115 122 113 105 117 129 87 95 115 118 123 124 124 129 123 129 126 116 123 124 116 111 117 118 108 107 110 118 123 121 127 130 126 133 109 119 132 118 117 116 113 116 122 118 121 118 120 123 124 116 115 117 96 109 122 123 121 124 112 112 118 121 129 118 121 117 103 108 110 108 107 101 125 121 120 131 117 108 123 129 124 120 119 103 91 86 100 101 101 100 117 107 117 128 123 117 131 138 123 116 106 102 68 53 68 65 66 78 96 108 119 127 128 118 137 133 117 106 101 82 46 46 44 42 28 36 85 104 118 131 125 121 136 128 111 90 78 47 38 30 45 39 20 25 55 103 109 120 135 130 132 127 103 105 58 42 38 40 51 43 28 24 49 92 112 126 130 132 135 119 96 106 63 36 75 185 175 95 56 34 52 82 115 124 123 126 135 118 93 103 42 37 137 213 210 141 117 35 43 100 115 130 127 128 136 122 96 117 63 41 98 194 195 98 40 42 47 99 116 130 129 125 136 123 97 106 62 39 32 84 90 32 35 37 64 90 108 126 118 116 129 126 101 88 58 52 37 121 199 59 38 46 86 95 116 129 130 129 132 126 111 106 75 76 51 68 129 44 46 89 95 119 123 136 134 126 126 134 123 100 87 86 89 87 84 66 86 85 113 121 126 131 133 130 110 128 120 119 99 94 96 88 99 92 86 108 121 125 126 125 127 128 104 117 114 120 116 112 106 116 123 96 96 117 127 129 121 125 126 123 89 99 118 123 130 120 116 116 123 116 115 126 131 120 127 122 125 122 86 86 109 122 125 121 120 114 127 124 124 127 127 117 125 117 123 116 82 94 116 116 122 121 117 121 129 121 126 129 125 117 125 121 117 121 99 101 111 102 126 125 115 119 114 115 118 119 122 112 118 118 123 117 Contour / surface map created using MathCad 5 Introduction to Image Processing • Pixels: Grey Scale • Pixels: Color • Color Issues • Image Manipulation • Image Enhancement 6 3 Introduction to Image Processing Pixels: Color 165 178 191 177 186 192 192 192 194 184 211 206 177 190 188 195 145 195 225 166 153 173 184 204 202 198 208 204 206 205 206 194 188 213 192 189 207 215 167 136 167 190 204 210 206 211 213 207 219 214 201 209 208 207 188 192 213 168 186 176 186 201 209 210 209 220 216 223 200 207 225 207 206 196 191 200 169 202 208 200 207 211 206 210 201 198 202 182 187 212 223 218 216 201 199 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 203 221 228 229 222 218 230 229 220 215 209 207 203 169 156 141 116 127 159 207 221 239 231 216 215 201 211 212 211 206 209 217 205 184 145 140 152 161 214 222 215 219 188 176 168 157 164 159 150 186 204 200 180 197 185 188 195 204 207 202 188 152 172 178 169 191 170 134 163 166 183 203 213 204 203 172 207 201 189 164 142 98 116 68 102 106 84 121 148 163 202 218 216 207 212 203 189 171 142 79 68 45 47 49 44 61 105 129 146 175 201 201 202 210 186 152 129 57 52 53 63 143 121 39 40 71 145 144 181 195 199 199 186 177 165155 166 80 167 62 168 49 169 47 170187 171209 172215 173108 174109 175 60 176131 177120 178181 179195 180196 181197 182191 183 184 194 13215796106 108 58 127 55 145 63 131196 139212 153217 160106 159211 159124 157107 165118 162175 170194 162202 157210 148186 129 128 194 115168 105 96 107 57 128 51 129 57 141113 147169 153132 153 45 136 69 142 44 136107 130133 139160 138200 147206 146204 165193 152 138 175 136178 122113 131 43 124 39 135 45 150 50 137141 139 50 124 50 121 47 109 59 106125 115146 109158 116192 110210 120210 151202 130 131 178 131160 139140 136 58 140 41 137 31 135 44 146 44 136 54 118 49 106 59 125134 131125 131158 151189 130204 104207 121209 111194 143 137 217 196 168 141 86 64 72 58 65 90 128 152 188 199 217 217 220 210 204 134 142 147 153 136 140 142 121 131 80 62 68 42 64 56 57 74 96 121 131 216 192 186 190 171 163 127 162 177 149 167 214 207 216 230 218 202 203 188 152 138 153 142 151 136 113 120 82 38 31 36 33 39 36 59 91 90 101 125 216 151205 166210 154206 158197 145195 107192 1122016819949200362064122287228 150224 13022135233432274521586200 120 109 223 140227 140211 161218 164204 134213 1312159622857230412202322934236 191227 230221 224213 101226 12922170218 10620797 135 208 9 227 1973233 1943216 1246228 2147237 20 10 12 2396225 27 21 18 12 132215 137214 141212 147227 130221 116222 114 172236 226218 218224 200219 137212 109211 121 27 145 190 201 215 205 227 222 225 230 225 218 222 222 228 224 223 217 216 214 200 17 16 13 17 19 17 21 23 17 32 26 22 13 138 146 149 160 130 114 118 76 43 40 48 108 150 99 35 47 37 73 115 1698 133 116 147 115 96 134 24 118 2471 2421 21 9 2924 2481 15 159 1650 940 2434 2460 15 122 889 17 113 9 117 137 131 135 129 110 15 116 1177 1633 1416 1125 1638 935 1145 1237 1253 20 117 11 105 10 139 147 6 18 127 134 143 161 147 140 20 132 17 102 1394 954 1551 1654 1645 1049 1063 14 112 16 124 134 150 23 157 8 16 129 132 150 122 137 135 10 108 18 120 14 112 12 131 1299 13 102 130 116 23 116 24 111 27 142 28 138 33 148 37 152 13 16 9 16 17 17 9 9 34 28 21 75 120 43 105 135 123 133 137 137 138 128 132 127 135 131 140 147 119 142 142 146 151 138 7 13 9 23 58 107 128 132 139 151 18 140 18 144 14 156 142 149 17 145 156 146 36 136 19 155 41 161177 158201 152143 148 124 120 135 132 121 130 25 132 23 150 22 147 17 164 19 156 22 136 30 146 26 141 31 129 34 152 44 155157 159194 150150 141 140 151 119 122 115 118 19 132 25 128 19 144 17 152 19 156 16 140 17 148 24 142 28 121 26 151 26 150 65 158105 157 64 140 19 24 19 13 12 13 9 16 21 12 17 37 52 20 23 28 17 16 13 16 25 17 17 20 16 21 27 27 23 23 19 12 9 20 24 19 20 26 32 32 27 28 36 22 16 25 11 14 21 20 12 9 15 18 10 4 12 12 18 13 8 8 8 19 16 5 8 23 4 3 27 20 19 22 17 20 18 26 21 16 18 14 8 15 28 24 26 18 15 13 22 22 16 16 14 13 10 15 21 21 22 27 22 17 20 13 16 11 20 14 8 10 RGB 185 186 187 84 110 91 129 94 114 139 122 147 139 146 135 153 146 147 129 140 143 132 145 135 135 123 143 25 143 17 150 32 153 21 136 27 143 25 142 17 141 44 147 27 147 18 153 28 152 34 150 25 165 34 149 32 144 38 136 37 135 33 133 24 147 28 146 38 145 43 137126 123 76 129 70 150187 144128 131 18 141 61 125 52 141 15 34 20 26 27 17 39 18 11 7 7 3 6 2 5 22 5 13 9 10 11 10 14 6 188 119 128 125 119 150 138 124 133 27 143 22 146 14 143 24 136 18 133 41 122 36 135 26 133 36 141 20 141 13 26 17 18 4 10 5 5 33 29 30 33 15 37 26 49 58 28 23 27 15 11 4 4 13 4 28 31 32 22 15 37 30 34 49 31 17 16 8 5 5 16 14 7 42 23 19 18 20 31 21 20 34 13 12 21 12 6 3 5 2 10 33 24 22 18 15 23 18 25 30 24 17 22 14 14 3 8 8 8 30 18 14 11 14 19 18 25 25 18 21 29 23 16 15 16 10 10 21 15 15 17 16 28 36 35 15 7 11 28 30 26 21 16 18 12 7 Red-Green-Blue Matrices Introduction to Image Processing Red-Green-Blue Color Cube R = 0 to 255 G = 0 to 255 Blue B = 0 to 255 255 White Cyan Not all colors are perceivable on all devices Magenta 255, 255, 255 Grey Line Black 255 0, 0, 0 Green 255 Yellow 24-bit graphics: 256 x 256 x 256 = 16,777,216 colors 256 shades of grey Red 0.0 to 1.0 0 to 255 (8-bits) 8 4 Introduction to Image Processing Pixels: Color 8 bits 8 bits 8 bits Red Green Blue 24 bits RGB 9 Introduction to Image Processing Pixel Profile of RGB Image B A 10 5 Introduction to Image Processing Pixel Profile of RGB Image A B From www.efg2.com/Lab/ImageProcessing/PixelProfile.htm 11 Introduction to Image Processing • Pixels: Grey Scale • Pixels: Color • Color Issues • Image Manipulation • Image Enhancement 12 6 Introduction to Image Processing Color Issue: Too Many Bits Pixels with Axon Scanner 16 bits Red (Cy5) 16 bits Green (Cy3) 1111 0010 1101 0100 24-bit RGB Pixel: 1010 0101 1010 0101 1111 0010 1010 0101 0000 0000 Similar problem with 14-bit microscope images displayed in color. Analysis of raw data may show details not seen on an image. 13 Introduction to Image Processing Color Issue: Fidelity CRT Gamut From www.efg2.com/Lab/Graphics/Colors/Chromaticity.htm 14 7 Introduction to Image Processing 3D Color Gamut From “Visualization of Expanded Printing Gamuts Using 3-Dimensional Convex Hulls” by Karl Guyler, Hallmark Cards, Kansas City Note: Color calibration can be used to minimize needless differences 15 Introduction to Image Processing • Pixels: Grey Scale • Pixels: Color • Color Issues • Image Manipulation – Image Registration – Image Comparison • Image Enhancement 16 8 Introduction to Image Processing Image Manipulation Comparison without Registration 17 Introduction to Image Processing Image Manipulation: Registration Two registration points needed if image has rotation 18 9 Introduction to Image Processing Image Manipulation: Registration Translation and Rotation: Align second image with first 19 Introduction to Image Processing Image Manipulation: Comparison Comparison with Alignment 20 10 Image Processing at CooperSurgical Aceto-Positive Cervical Lesion Research Original images from the web site of the American Society for Colposcopy and Cervical Pathology www.asccp.org 21 Introduction to Image Processing • • • • • Pixels: Grey Scale Pixels: Color Color Issues Image Manipulation Image Enhancement – Contrast Improvement – Spatial Filters 22 11 Introduction to Image Processing Image Enhancement: Contrast Improvement Original Image 2 3 2 3 2 4 Enhanced Image 3 4 3 1 3 1 6 6 5 5 4 4 Stretch 2 3 5 3 Histostretched Original Histogram 3 3 1 5 1 3 2 1 0 1 2 3 4 5 to improve contrast 0 1 2 3 4 5 23 Introduction to Image Processing Image Enhancement: Contrast Improvement From www.efg2.com/Lab/ImageProcessing/HistoStretchGrays.htm 24 12 Introduction to Image Processing Image Enhancement: Contrast Improvement 25 Introduction to Image Processing Image Enhancement: Contrast Improvement Histogram stretching the color planes separately will yield an image with maximum contrast, but may introduce a color shift. The color shift here is negligible. Usually, convert Red-Green-Blue (RGB) → Hue-Saturation-Intensity (HSI), stretch I to yield I’, and 26 then convert HSI’ → R’G’B’ 13 Image Processing of Microarray Slides Axon Sample: Human2 Preview Original Autoscale 27 Introduction to Image Processing Spatial Frequency Frequency = 1 1 Cycle Frequency = 2 2 Cycles 28 14 Introduction to Image Processing Spatial Filters: Convolution Output Image Input Image Column Column Row Convolution Kernel, a smoothing kernel in this example 106 101 102 82 68 46 78 47 38 1 1 1 1 1 1 1 9 1 1 1 Row Single Pixel 106 + 101 + 78 + 102 + 82 + 47 + 68 + 46 + 38 = 74.2 ≈ 74 9 ∑=1 29 Introduction to Image Processing Spatial Filters: Convolution Type Low-Pass Spatial Filter Smooth High-Boost Spatial Filter Sharpen Laplace Filter Edge Enhance 1 1 1 1 1 1 1 9 1 1 1 ∑=1 − 1 − 1 − 1 ∑ = 1 − 1 9 − 1 − 1 − 1 − 1 1 0 0 1 − 4 1 0 1 0 ∑= 0 30 15 Introduction to Image Processing Spatial Filter: Smooth Original Enhanced 31 Introduction to Image Processing Spatial Filter: Sharpen (original) Picture Copyright © Adaptec, Used with Permission 32 16 Introduction to Image Processing Spatial Filter: Sharpen (enhanced) 33 Introduction to Image Processing Spatial Filter: Edge Enhance Original Laplace Filter Mask Enhanced 50% 34 17 Introduction to Image Processing • Pixels: Grey Scale • Pixels: Color • Color Issues • Image Manipulation • Image Enhancement 35 Image Processing of Microarray Slides Axon Example: Single Feature 36 18 Acknowledgements Bioinformatics Arcady Mushegian CooperSurgical Kerry Blair Genomics Ranjan Perera Angel McKee Diane Stark George Washington University Medical Center John L. Marlow, MD 37 19