|
| 1 | +- [Matlab常用图像处理命令108例(五)](#matlab常用图像处理命令108例五) |
| 2 | + - [54.imcontour](#54imcontour) |
| 3 | + - [55.imcrop](#55imcrop) |
| 4 | + - [56.imfeature](#56imfeature) |
| 5 | + - [57.imfinfo](#57imfinfo) |
| 6 | + - [58.imhist](#58imhist) |
| 7 | + - [59.immovie](#59immovie) |
| 8 | + - [60.imnoise](#60imnoise) |
| 9 | + - [61.impixel](#61impixel) |
| 10 | + - [62.improfile](#62improfile) |
| 11 | + - [63.imread](#63imread) |
| 12 | + - [64.imresize](#64imresize) |
| 13 | + - [65.imrotate](#65imrotate) |
| 14 | + |
| 15 | + |
| 16 | +# Matlab常用图像处理命令108例(五) |
| 17 | + |
| 18 | +## 54.imcontour |
| 19 | + |
| 20 | +功能:创建图像数据的轮廓图。 |
| 21 | +语法: |
| 22 | + |
| 23 | +```matlab |
| 24 | +imcontour(I,n) |
| 25 | +imcontour(I,v) |
| 26 | +imcontour(x,y,...) |
| 27 | +imcontour(...,LineSpec) |
| 28 | +[C,h] = imcontour(...) |
| 29 | +``` |
| 30 | + |
| 31 | +举例 |
| 32 | + |
| 33 | +```matlab |
| 34 | +I = imread('ic.tif'); |
| 35 | +imcontour(I,3) |
| 36 | +``` |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | +相关命令: |
| 41 | +clabel, contour, LineSpec |
| 42 | + |
| 43 | +## 55.imcrop |
| 44 | + |
| 45 | +功能:剪切图像。 |
| 46 | +语法: |
| 47 | + |
| 48 | +```matlab |
| 49 | +I2 = imcrop(I) |
| 50 | +X2 = imcrop(X,map) |
| 51 | +RGB2 = imcrop(RGB) |
| 52 | +I2 = imcrop(I,rect) |
| 53 | +X2 = imcrop(X,map,rect) |
| 54 | +RGB2 = imcrop(RGB,rect) |
| 55 | +[...] = imcrop(x,y,...) |
| 56 | +[A,rect] = imcrop(...) |
| 57 | +[x,y,A,rect] = imcrop(...) |
| 58 | +``` |
| 59 | + |
| 60 | +举例 |
| 61 | + |
| 62 | +```matlab |
| 63 | +I = imread('ic.tif'); |
| 64 | +I2 = imcrop(I,[60 40 100 90]); |
| 65 | +imshow(I) |
| 66 | +figure, imshow(I2) |
| 67 | +``` |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | +相关命令: |
| 72 | +zoom |
| 73 | + |
| 74 | +## 56.imfeature |
| 75 | + |
| 76 | +功能:计算图像区域的特征尺寸。 |
| 77 | +语法: |
| 78 | + |
| 79 | +```matlab |
| 80 | +stats = imfeature(L,measurements) |
| 81 | +stats = imfeature(L,measurements,n) |
| 82 | +``` |
| 83 | + |
| 84 | +举例 |
| 85 | + |
| 86 | +```matlab |
| 87 | +BW = imread('text.tif'); |
| 88 | +L = bwlabel(BW); |
| 89 | +stats = imfeature(L,'all'); |
| 90 | +stats(23) |
| 91 | +ans = |
| 92 | +Area: 89 |
| 93 | +Centroid: [95.6742 192.9775] |
| 94 | +BoundingBox: [87.5000 184.5000 16 15] |
| 95 | +MajorAxisLength: 19.9127 |
| 96 | +MinorAxisLength: 14.2953 |
| 97 | +Eccentricity: 0.6961 |
| 98 | +Orientation: 9.0845 |
| 99 | +ConvexHull: [28x2 double] |
| 100 | +ConvexImage: [15x16 uint8 ] |
| 101 | +ConvexArea: 205 |
| 102 | +Image: [15x16 uint8 ] |
| 103 | +FilledImage: [15x16 uint8 ] |
| 104 | +FilledArea: 122 |
| 105 | +EulerNumber: 0 |
| 106 | +Extrema: [ 8x2 double] |
| 107 | +EquivDiameter: 10.6451 |
| 108 | +Solidity: 0.4341 |
| 109 | +Extent: 0.3708 |
| 110 | +PixelList: [89x2 double] |
| 111 | +``` |
| 112 | + |
| 113 | +相关命令: |
| 114 | +bwlabel |
| 115 | + |
| 116 | +## 57.imfinfo |
| 117 | + |
| 118 | +功能:返回图形文件信息。 |
| 119 | +语法: |
| 120 | + |
| 121 | +```matlab |
| 122 | +info = imfinfo(filename,fmt) |
| 123 | +info = imfinfo(filename) |
| 124 | +``` |
| 125 | + |
| 126 | +举例 |
| 127 | + |
| 128 | +```matlab |
| 129 | +info = imfinfo('canoe.tif') |
| 130 | +info = Filename:'canoe.tif' |
| 131 | +FileModDate: '25-Oct-1996 22:10:39' |
| 132 | +FileSize: 69708 |
| 133 | +Format: 'tif' |
| 134 | +FormatVersion: [] |
| 135 | +Width: 346 |
| 136 | +Height: 207 |
| 137 | +BitDepth: 8 |
| 138 | +ColorType: 'indexed' |
| 139 | +FormatSignature: [73 73 42 0] |
| 140 | +ByteOrder: 'little-endian' |
| 141 | +NewSubfileType: 0 |
| 142 | +BitsPerSample: 8 |
| 143 | +Compression: 'PackBits' |
| 144 | +
|
| 145 | +PhotometricInterpretation: 'RGB Palette' |
| 146 | +StripOffsets: [ 9x1 double] |
| 147 | +SamplesPerPixel: 1 |
| 148 | +RowsPerStrip: 23 |
| 149 | +StripByteCounts: [ 9x1 double] |
| 150 | +XResolution: 72 |
| 151 | +YResolution: 72 |
| 152 | +ResolutionUnit: 'Inch' |
| 153 | +Colormap: [256x3 double] |
| 154 | +PlanarConfiguration: 'Chunky' |
| 155 | +TileWidth: [] |
| 156 | +TileLength: [] |
| 157 | +TileOffsets: [] |
| 158 | +TileByteCounts: [] |
| 159 | +Orientation: 1 |
| 160 | +FillOrder: 1 |
| 161 | +GrayResponseUnit: 0.0100 |
| 162 | +MaxSampleValue: 255 |
| 163 | +MinSampleValue: 0 |
| 164 | +Thresholding: 1 |
| 165 | +``` |
| 166 | + |
| 167 | +相关命令: imread, imwrite |
| 168 | + |
| 169 | +## 58.imhist |
| 170 | + |
| 171 | +功能:显示图像数据的柱状图。 |
| 172 | +语法: |
| 173 | + |
| 174 | +```matlab |
| 175 | +imhist(I,n) |
| 176 | +imhist(X,map) |
| 177 | +[counts,x] = imhist(...) |
| 178 | +``` |
| 179 | + |
| 180 | +举例 |
| 181 | + |
| 182 | +```matlab |
| 183 | +I = imread('pout.tif'); |
| 184 | +imhist(I) |
| 185 | +``` |
| 186 | + |
| 187 | + |
| 188 | + |
| 189 | +相关命令: |
| 190 | +histeq |
| 191 | + |
| 192 | +## 59.immovie |
| 193 | + |
| 194 | +功能:创建多帧索引图的电影动画。 |
| 195 | +语法: |
| 196 | + |
| 197 | +```matlab |
| 198 | +mov = immovie(X,map) |
| 199 | +``` |
| 200 | + |
| 201 | +举例 |
| 202 | + |
| 203 | +```matlab |
| 204 | +load mri |
| 205 | +mov = immovie(D,map); |
| 206 | +``` |
| 207 | + |
| 208 | +相关命令: montage |
| 209 | + |
| 210 | +## 60.imnoise |
| 211 | + |
| 212 | +功能:增加图像的渲染效果。 |
| 213 | +语法: |
| 214 | + |
| 215 | +```matlab |
| 216 | +J = imnoise(I,type) |
| 217 | +J = imnoise(I,type,parameters) |
| 218 | +``` |
| 219 | + |
| 220 | +举例 |
| 221 | + |
| 222 | +```matlab |
| 223 | +I = imread('eight.tif'); |
| 224 | +J = imnoise(I,'salt & pepper',0.02); |
| 225 | +imshow(I) |
| 226 | +figure, imshow(J) |
| 227 | +``` |
| 228 | + |
| 229 | + |
| 230 | + |
| 231 | +相关命令: |
| 232 | +rand |
| 233 | + |
| 234 | +## 61.impixel |
| 235 | + |
| 236 | +功能:确定像素颜色值。 |
| 237 | +语法: |
| 238 | + |
| 239 | +```matlab |
| 240 | +P = impixel(I) |
| 241 | +P = impixel(X,map) |
| 242 | +P = impixel(RGB) |
| 243 | +P = impixel(I,c,r) |
| 244 | +P = impixel(X,map,c,r) |
| 245 | +P = impixel(RGB,c,r) |
| 246 | +[c,r,P] = impixel(...) |
| 247 | +P = impixel(x,y,I,xi,yi) |
| 248 | +P = impixel(x,y,X,map,xi,yi) |
| 249 | +P = impixel(x,y,RGB,xi,yi) |
| 250 | +[xi,yi,P] = impixel(x,y,...) |
| 251 | +``` |
| 252 | + |
| 253 | +举例 |
| 254 | + |
| 255 | +```matlab |
| 256 | +RGB = imread('flowers.tif'); |
| 257 | +c = [12 146 410]; |
| 258 | +r = [104 156 129]; |
| 259 | +pixels = impixel(RGB,c,r) |
| 260 | +pixels = |
| 261 | +61 59 101 |
| 262 | +253 240 0 |
| 263 | +237 37 44 |
| 264 | +``` |
| 265 | + |
| 266 | +相关命令: |
| 267 | +improfile, pixval |
| 268 | + |
| 269 | +## 62.improfile |
| 270 | + |
| 271 | +功能:沿线段计算剖面图的像素值。 |
| 272 | +语法: |
| 273 | + |
| 274 | +```matlab |
| 275 | +c = improfile |
| 276 | +c = improfile(n) |
| 277 | +c = improfile(I,xi,yi) |
| 278 | +c = improfile(I,xi,yi,n) |
| 279 | +[cx,cy,c] = improfile(...) |
| 280 | +[cx,cy,c,xi,yi] = improfile(...) |
| 281 | +[...] = improfile(x,y,I,xi,yi) |
| 282 | +[...] = improfile(x,y,I,xi,yi,n) |
| 283 | +[...] = improfile(...,method) |
| 284 | +``` |
| 285 | + |
| 286 | +举例 |
| 287 | + |
| 288 | +```matlab |
| 289 | +I = imread('alumgrns.tif'); |
| 290 | +x = [35 338 346 103]; |
| 291 | +y = [253 250 17 148]; |
| 292 | +improfile(I,x,y), grid on |
| 293 | +``` |
| 294 | + |
| 295 | + |
| 296 | + |
| 297 | +相关命令: |
| 298 | +impixel, pixval |
| 299 | + |
| 300 | +## 63.imread |
| 301 | + |
| 302 | +功能:从图形文件中读取图像。 |
| 303 | +语法: |
| 304 | + |
| 305 | +```matlab |
| 306 | +A = imread(filename,fmt) |
| 307 | +[X,map] = imread(filename,fmt) |
| 308 | +[...] = imread(filename) |
| 309 | +[...] = imread(...,idx) (TIFF only) |
| 310 | +[...] = imread(...,ref) (HDF only) |
| 311 | +[...] = imread(...,’BackgroundColor’,BG) (PNG only) |
| 312 | +[A,map,alpha] = imread(...) (PNG only) |
| 313 | +``` |
| 314 | + |
| 315 | +举例 |
| 316 | + |
| 317 | +```matlab |
| 318 | +[X,map] = imread('flowers.tif',6); |
| 319 | +info = imfinfo('skull.hdf'); |
| 320 | +[X,map] = imread('skull.hdf',info(4).Reference); |
| 321 | +bg = [255 0 0]; |
| 322 | +A = imread('image.png','BackgroundColor',bg); |
| 323 | +[A,map,alpha] = imread('image.png'); |
| 324 | +``` |
| 325 | + |
| 326 | +相关命令: |
| 327 | +imfinfo, imwrite,fread,double,uint8,uint16 |
| 328 | + |
| 329 | +## 64.imresize |
| 330 | + |
| 331 | +功能:改变图像大小。 |
| 332 | +语法: |
| 333 | + |
| 334 | +```matlab |
| 335 | +B = imresize(A,m,method) |
| 336 | +B = imresize(A,[mrows ncols],method) |
| 337 | +B = imresize(...,method,n) |
| 338 | +B = imresize(...,method,h) |
| 339 | +``` |
| 340 | + |
| 341 | +## 65.imrotate |
| 342 | + |
| 343 | +功能:旋转图像。 |
| 344 | +语法: |
| 345 | + |
| 346 | +```matlab |
| 347 | +B = imrotate(A,angle,method) |
| 348 | +B = imrotate(A,angle,method,'crop') |
| 349 | +``` |
| 350 | + |
| 351 | +举例 |
| 352 | + |
| 353 | +```matlab |
| 354 | +I = imread('ic.tif'); |
| 355 | +J = imrotate(I,–4,'bilinear','crop'); |
| 356 | +imshow(I) |
| 357 | +figure, imshow(J) |
| 358 | +``` |
| 359 | + |
| 360 | + |
| 361 | + |
| 362 | +相关命令: |
| 363 | +imcrop, imresize |
| 364 | + |
| 365 | + |
| 366 | + |
| 367 | +参考文献: |
| 368 | + |
| 369 | +[1] [Rafael C. Gonzalez, Richard E. Woods, and Steven L. Eddins. 2003. Digital Image Processing Using MATLAB. Prentice-Hall, Inc., USA.](https://github.com/timerring/digital-image-processing-matlab/blob/main/reference/Digital_Image_Processing_Using_Matlab.pdf) |
| 370 | + |
| 371 | +[2] [阮秋琦. 数字图像处理(MATLAB版)[M]. 北京:电子工业出版社, 2014.](https://github.com/timerring/digital-image-processing-matlab/blob/main/reference/Digital_Image_Processing_(MATLAB_version).pdf) |
| 372 | + |
| 373 | +[3] [冈萨雷斯. 数字图像处理(第三版)[M]. 北京:电子工业出版社, 2011.](https://github.com/timerring/digital-image-processing-matlab/blob/main/reference/Digital_Image_Processing_(Third_Edition).pdf) |
| 374 | + |
| 375 | +[返回首页](https://github.com/timerring/digital-image-processing-matlab) |
0 commit comments