Computer_Vision/Chapter03/Inspecting_grayscale_images.ipynb
2024-02-13 03:34:51 +01:00

77 KiB
Raw Blame History

Open In Colab

!wget https://www.dropbox.com/s/l98leemr7r5stnm/Hemanvi.jpeg
--2020-09-24 05:01:20--  https://www.dropbox.com/s/l98leemr7r5stnm/Hemanvi.jpeg
Resolving www.dropbox.com (www.dropbox.com)... 162.125.5.1, 2620:100:601d:1::a27d:501
Connecting to www.dropbox.com (www.dropbox.com)|162.125.5.1|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: /s/raw/l98leemr7r5stnm/Hemanvi.jpeg [following]
--2020-09-24 05:01:20--  https://www.dropbox.com/s/raw/l98leemr7r5stnm/Hemanvi.jpeg
Reusing existing connection to www.dropbox.com:443.
HTTP request sent, awaiting response... 302 Found
Location: https://uc5e32e2c709a61fb3a3974fb3a2.dl.dropboxusercontent.com/cd/0/inline/A_8kYWz6Ib0IHovWnkgWldxl-D9gQmZOoriI0tEfWqwWiIbOG6Kyb0PJpOtKovd3hvBKPJT0Lyy_vvok1iqFWG2GsfC1PklEYGWp237PyuNFxw/file# [following]
--2020-09-24 05:01:20--  https://uc5e32e2c709a61fb3a3974fb3a2.dl.dropboxusercontent.com/cd/0/inline/A_8kYWz6Ib0IHovWnkgWldxl-D9gQmZOoriI0tEfWqwWiIbOG6Kyb0PJpOtKovd3hvBKPJT0Lyy_vvok1iqFWG2GsfC1PklEYGWp237PyuNFxw/file
Resolving uc5e32e2c709a61fb3a3974fb3a2.dl.dropboxusercontent.com (uc5e32e2c709a61fb3a3974fb3a2.dl.dropboxusercontent.com)... 162.125.5.15, 2620:100:601d:15::a27d:50f
Connecting to uc5e32e2c709a61fb3a3974fb3a2.dl.dropboxusercontent.com (uc5e32e2c709a61fb3a3974fb3a2.dl.dropboxusercontent.com)|162.125.5.15|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 53839 (53K) [image/jpeg]
Saving to: Hemanvi.jpeg

Hemanvi.jpeg        100%[===================>]  52.58K  --.-KB/s    in 0.03s   

2020-09-24 05:01:21 (1.89 MB/s) - Hemanvi.jpeg saved [53839/53839]

%matplotlib inline
import cv2, matplotlib.pyplot as plt
img = cv2.imread('Hemanvi.jpeg')
img = img[50:250,40:240]
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
plt.imshow(img_gray, cmap='gray')
<matplotlib.image.AxesImage at 0x7f4ad2b752e8>
img_gray_small = cv2.resize(img_gray,(25,25))
plt.imshow(img_gray_small, cmap='gray')
<matplotlib.image.AxesImage at 0x7f4ad2b0fa90>
print(img_gray_small)
[[222 220 221 220 218 253 234 245 238 235 239 243 236 232 218 193 228 228
  234 239 139 245 252 253 253]
 [221 219 219 218 232 239 186 240 231 226 227 226 215 212 209 193 199 229
  234 239 150 236 252 253 253]
 [219 218 218 218 251 163 224 241 234 238 236 231 224 204 188 166 173 180
  234 236 159 219 252 252 253]
 [218 219 216 211 196 248 231 228 243 241 229 224 201 209 210 189 181 189
  196 235 168 204 252 252 253]
 [218 214 213 240 195 242 223 246 246 249 238 211 203 196 177 168 179 176
  179 231 175 191 252 252 253]
 [212 212 208 232 254 232 252 241 232 192 155 164 166 165 164 163 168 178
  178 181 190 178 250 252 251]
 [211 209 205 232 240 251 208 191 217 158 161 166 169 169 170 170 171 169
  176 177 206 166 250 252 251]
 [209 209 205 243 242 225 193 241 215 184 169 163 159 158 160 173 176 184
  178 179 189 150 246 250 252]
 [210 207 203 232 229 236 246 214 213 196 199 185 179 179 181 172 179 180
  180 181 177 136 246 251 252]
 [209 206 222 212 242 243 244 226 184 165 104  61  57  48  27  97 158 167
  178 178 178 139 246 249 252]
 [208 206 225 243 249 254 209  82  85 105 109 100  98  95  65  43  28  24
  109 156 169 175 242 248 251]
 [207 205 252 255 242 153  33  66 111 116 117 116 115 109  78  66  22  27
   14   9 137 159 241 245 249]
 [205 204 250 225  63  15  42  77  71 104 115 118 110 101  56  64  60  34
   20  20  17  25 145 246 246]
 [207 206 209  23  16  22  90  45  39  43 110 115  99  56  23  78 107  65
   15  17  20  32  76 244 246]
 [207 239  37  22  14  19  97 102 100  90 108 133 104  94  88 108 114  57
   21  22  23  33 130 243 247]
 [205 133  48  24  15  17 110 124 118 119 124 134 119 116 109 123 116  36
   27  25  31  44 242 243 246]
 [204 124  38  30  19  16 120 146 133 121 142 138 118 114 135 145 128  24
   20  21  33 136 236 243 244]
 [205 212  39  37  20  20 110 137 110 128 119 109 109 115 119 133 121   8
    9  36  34 137 237 241 243]
 [203 206 101  31  29  21  22 132 108 102  91  97 101 111 113 122 118  11
   14  38 222 139 233 240 242]
 [200 200 200  41  36  25  24  37 117 117 116 101  99 114 111 119   4   8
   41 220 219 134 232 239 244]
 [197 196 196 199  92  37  26  25   8 127 125 118 122 116  67  31  13  11
  150 173 220 131 231 238 242]
 [195 193 193 192 198 187  58  22  25  37  97 115  93  70  55  36  33 148
  153 165 166 183 233 236 242]
 [192 190 189 240 237 202 180 147 140  66  36  52  64  61  51 150 146 138
  134 157 159 166 189 237 240]
 [189 188 197 244 229 206 194 196 157 146 138  39  63  73  53 144 143 139
  150 148 153 161 167 187 239]
 [184 220 225 245 221 167 173 209 183 157 143 116  53  74  49 144 150 150
  148 153 153 158 162 165 178]]