1 # Created by Octave 3.6.1, Mon Mar 12 21:54:04 2012 UTC <root@t61>
13 # name: <cell-element>
17 -- Function File: A = applylut (BW,LUT)
18 Uses lookup tables to perform a neighbour operation on binary
21 A = applylut(BW,LUT) returns the result of a neighbour operation
22 using the lookup table LUT which can be created by makelut.
24 It first computes a matrix with the index of each element in the
25 lookup table. To do this, it convolves the original matrix with a
26 matrix which assigns each of the neighbours a bit in the resulting
27 index. Then LUT is accessed to compute the result.
35 # name: <cell-element>
39 Uses lookup tables to perform a neighbour operation on binary images.
43 # name: <cell-element>
50 # name: <cell-element>
54 -- Function File: SIZ = bestblk ([M N], K)
55 -- Function File: [MB NB] = bestblk ([M N], K)
56 Calculates the best size of block for block processing.
58 `siz=bestblk([m,n],k)' calculates the optimal block size for block
59 processing for a M-by-N image. K is the maximum side dimension of
60 the block. Its default value is 100. SIZ is a row vector which
61 contains row and column dimensions for the block.
63 `[mb,nb]=bestblk([m,n],k)' behaves as described above but returns
64 block dimensions to MB and NB.
68 For each dimension (M and N), it follows this algorithm:
70 1.- If dimension is less or equal than K, it returns the dimension
73 2.- If not then returns the value between
74 `round(min(dimension/10,k/2))' which minimizes padding.
82 # name: <cell-element>
86 Calculates the best size of block for block processing.
90 # name: <cell-element>
97 # name: <cell-element>
101 -- Function File: B = blkproc (A, [M,N], FUN)
102 -- Function File: B = blkproc (A, [M,N], FUN, ...)
103 -- Function File: B = blkproc (A, [M,N], [MBORDER,NBORDER], FUN, ...)
104 -- Function File: B = blkproc (A, 'indexed', ...)
105 Processes image in blocks using user-supplied function.
107 `B=blkproc(A,[m,n],fun)' divides image A in M-by-N blocks, and
108 passes them to user-supplied function FUN, which result is
109 concatenated to build returning matrix B. If padding is needed to
110 build M-by-N, it is added at the bottom and right borders of the
111 image. 0 is used as a padding value.
113 `B=blkproc(A,[m,n],fun,...)' behaves as described above but passes
114 extra parameters to function FUN.
116 `B=blkproc(A,[m,n],[mborder,nborder],fun,...)' behaves as
117 described but uses blocks which overlap with neighbour blocks.
118 Overlapping dimensions are MBORDER vertically and NBORDER
119 horizontally. This doesn't change the number of blocks in an image
120 (which depends only on size(A) and [M,N]). Adding a border
121 requires extra padding on all edges of the image. 0 is used as a
124 `B=blkproc(A,'indexed',...)' assumes that A is an indexed image,
125 so it pads the image using proper value: 0 for uint8 and uint16
126 images and 1 for double images. Keep in mind that if 'indexed' is
127 not specified padding is always done using 0.
129 See also: colfilt, inline, bestblk
135 # name: <cell-element>
139 Processes image in blocks using user-supplied function.
143 # name: <cell-element>
150 # name: <cell-element>
154 -- Function File: bmpwrite (X, MAP, FILE)
155 Write the bitmap X into FILE (8-bit indexed uncompressed). The
156 values in X are indices into the given RGB colour MAP.
158 -- Function File: bmpwrite (X, FILE)
159 Write the bitmap X into FILE (24-bit truecolor uncompressed). X
160 is an m x n x 3 array of R,G,B integer values in the range 0 to
166 # name: <cell-element>
170 Write the bitmap X into FILE (8-bit indexed uncompressed).
174 # name: <cell-element>
181 # name: <cell-element>
185 -- Function File: TOTAL = bwarea(BW)
186 Estimates the area of the "on" pixels of BW. If BW is a binary
187 image "on" pixels are defined as pixels valued 1. If BW is a
188 grayscale image "on" pixels is defined as pixels with values
189 larger than zero. This algorithm is not the same as counting the
190 number of "on" pixels as it tries to estimate the area of the
191 original object and not the image object.
196 # name: <cell-element>
200 Estimates the area of the "on" pixels of BW.
204 # name: <cell-element>
211 # name: <cell-element>
215 -- Function File: B = bwborder (IM)
216 Finds the borders of foreground objects in a binary image.
218 B is the borders in the 0-1 matrix IM. 4-neighborhood is
221 A pixel is on the border if it is set in IM, and it has at least
222 one neighbor that is not set.
227 # name: <cell-element>
231 Finds the borders of foreground objects in a binary image.
235 # name: <cell-element>
242 # name: <cell-element>
246 -- Function File: BOUNDARIES = bwboundaries(BW)
247 -- Function File: BOUNDARIES = bwboundaries(BW, CONN)
248 -- Function File: BOUNDARIES = bwboundaries(BW, CONN, HOLES)
249 -- Function File: [BOUNDARIES, LABELS] = bwboundaries(...)
250 -- Function File: [BOUNDARIES, LABELS, NUM_LABELS] = bwboundaries(...)
251 Trace the boundaries of the objects in a binary image.
253 BOUNDARIES is a cell array in which each element is the boundary
254 of an object in the binary image BW. The clockwise boundary of
255 each object is computed by the `boundary' function.
257 By default the boundaries are computed using 8-connectivity. This
258 can be changed to 4-connectivity by setting CONN to 4.
260 By default `bwboundaries' computes all boundaries in the image,
261 i.e. both interior and exterior object boundaries. This behaviour
262 can be changed through the HOLES input argument. If this is
263 'holes', both boundary types are considered. If it is instead
264 'noholes', only exterior boundaries will be traced.
266 If two or more output arguments are requested, the algorithm also
267 returns the labelled image computed by `bwlabel' in LABELS. The
268 number of labels in this image is optionally returned in
271 See also: boundary, bwlabel
277 # name: <cell-element>
281 Trace the boundaries of the objects in a binary image.
285 # name: <cell-element>
292 # name: <cell-element>
296 -- Function File: CC = bwconncomp (BW)
297 -- Function File: CC = bwconncomp (BW, CONNECTIVITY)
298 Trace the boundaries of objects in a binary image.
300 `bwconncomp' traces the boundaries of objects in a binary image BW
301 and returns information about them in a structure with the
305 The connectivity used in the boundary tracing.
308 The size of the image BW.
311 The number of objects in the image BW.
314 A cell array containing where each element corresponds to an
315 object in BW. Each element is represented as a vector of
316 linear indices of the boundary of the given object.
318 The connectivity used in the tracing is by default 4, but can be
319 changed by setting the CONNECTIVITY input parameter to 8. Sadly,
320 this is not yet implemented.
322 See also: bwlabel, bwboundaries, ind2sub
328 # name: <cell-element>
332 Trace the boundaries of objects in a binary image.
336 # name: <cell-element>
343 # name: <cell-element>
347 -- Function File: D = bwdist(BW)
348 Computes the distance transform of the image BW. BW should be a
349 binary 2D array, either a Boolean array or a numeric array
350 containing only the values 0 and 1. The return value D is a
351 double matrix of the same size as BW. Elements with value 0 are
352 considered background pixels, elements with value 1 are considered
353 object pixels. The return value for each background pixel is the
354 distance (according to the chosen metric) to the closest object
355 pixel. For each object pixel the return value is 0.
357 -- Function File: D = bwdist(BW, METHOD)
358 METHOD is a string to choose the distance metric. Currently
359 available metrics are 'euclidean', 'chessboard', 'cityblock' and
360 'quasi-euclidean', which may each be abbreviated to any string
361 starting with 'e', 'ch', 'ci' and 'q', respectively. If METHOD is
362 not specified, 'euclidean' is the default.
364 -- Function File: [D,C] = bwdist(BW, METHOD)
365 If a second output argument is given, the linear index for the
366 closest object pixel is returned for each pixel. (For object
367 pixels, the index points to the pixel itself.) The return value C
368 is a matrix the same size as BW.
373 # name: <cell-element>
377 Computes the distance transform of the image BW.
381 # name: <cell-element>
388 # name: <cell-element>
392 -- Function File: EUL = bweuler (BW,N)
393 Calculates the Euler number of a binary image.
395 EUL=bweuler(BW, N) calculates the Euler number EUL of a binary
396 image BW, which is a scalar whose value is the total number of
397 objects in an image minus the number of holes.
399 N can have the values:
401 bweuler will use 4-connected neighbourhood definition.
404 bweuler will use 8-connected neighbourhood definition. This
405 is the default value.
407 This function uses Bit Quads as described in "Digital Image
408 Processing" to calculate euler number.
410 References: W. K. Pratt, "Digital Image Processing", 3rd Edition,
419 # name: <cell-element>
423 Calculates the Euler number of a binary image.
427 # name: <cell-element>
434 # name: <cell-element>
438 -- Function File: BW2 = bwhitmiss (BW1, SE1, SE1)
439 -- Function File: BW2 = bwhitmiss (BW1, INTERVAL)
440 Perform the binary hit-miss operation.
442 If two structuring elements SE1 and SE1 are given, the hit-miss
443 operation is defined as
444 bw2 = erode(bw1, se1) & erode(!bw1, se2);
445 If instead an 'interval' array is given, two structuring elements
447 se1 = (interval == 1)
448 se2 = (interval == -1)
449 and then the operation is defined as previously.
457 # name: <cell-element>
461 Perform the binary hit-miss operation.
465 # name: <cell-element>
472 # name: <cell-element>
476 -- Function File: BW2 = bwmorph (BW,OPERATION)
477 -- Function File: BW2 = bwmorph (BW,OPERATION,N)
478 Perform a morphological operation on a binary image.
480 BW2=bwmorph(BW,operation) performs a morphological operation
481 specified by OPERATION on binary image BW. All possible operations
482 and their meaning are specified in a table below.
484 BW2=bwmorph(BW,operation,n) performs a morphological operation N
485 times. Keep in mind that it has no sense to apply some operations
486 more than once, since some of them return the same result
487 regardless how many iterations we request. Those return a warning
488 if are called with n>1 and they compute the result for n=1.
490 N>1 is actually used for the following operations: diag, dilate,
491 erode, majority, shrink, skel, spur, thicken and thin.
494 Performs a bottom hat operation, a closing operation (which
495 is a dilation followed by an erosion) and finally substracts
499 Performs a bridge operation. Sets a pixel to 1 if it has two
500 nonzero neighbours which are not connected, so it "bridges"
501 them. There are 119 3-by-3 patterns which trigger setting a
505 Performs an isolated pixel remove operation. Sets a pixel to
506 0 if all of its eight-connected neighbours are 0.
509 Performs closing operation, which is a dilation followed by
510 erosion. It uses a ones(3) matrix as structuring element for
514 Performs a diagonal fill operation. Sets a pixel to 1 if that
515 eliminates eight-connectivity of the background.
518 Performs a dilation operation. It uses ones(3) as structuring
522 Performs an erosion operation. It uses ones(3) as structuring
526 Performs a interior fill operation. Sets a pixel to 1 if all
527 four-connected pixels are 1.
530 Performs a H-break operation. Breaks (sets to 0) pixels that
534 Performs a majority black operation. Sets a pixel to 1 if five
535 or more pixels in a 3-by-3 window are 1. If not it is set to
539 Performs an opening operation, which is an erosion followed
540 by a dilation. It uses ones(3) as structuring element.
543 Performs a iterior pixel remove operation. Sets a pixel to 0
544 if all of its four-connected neighbours are 1.
547 Performs a shrink operation. Sets pixels to 0 such that an
548 object without holes erodes to a single pixel (set to 1) at
549 or near its center of mass. An object with holes erodes to a
550 connected ring lying midway between each hole and its nearest
551 outer boundary. It preserves Euler number.
554 Performs a skeletonization operation. It calculates a "median
555 axis skeleton" so that points of this skeleton are at the
556 same distance of its nearby borders. It preserver Euler
557 number. Please read compatibility notes for more info.
559 It uses the same algorithm as skel-pratt but this could
560 change for compatibility in the future.
563 Performs a skeletonization operation as described in Gonzalez
564 & Woods "Digital Image Processing" pp 538-540. The text
565 references Lantuejoul as authour of this algorithm.
567 It has the beauty of being a clean and simple approach, but
568 skeletons are thicker than they need to and, in addition, not
569 guaranteed to be connected.
571 This algorithm is iterative. It will be applied the minimum
572 value of N times or number of iterations specified in
573 algorithm description. It's most useful to run this algorithm
577 Performs a skeletonization operation as described by William
578 K. Pratt in "Digital Image Processing".
581 Performs a remove spur operation. It sets pixel to 0 if it
582 has only one eight-connected pixel in its neighbourhood.
585 Performs a thickening operation. This operation "thickens"
586 objects avoiding their fusion. Its implemented as a thinning
587 of the background. That is, thinning on negated image.
588 Finally a diagonal fill operation is performed to avoid
589 "eight-connecting" objects.
592 Performs a thinning operation. When n=Inf, thinning sets
593 pixels to 0 such that an object without holes is converted to
594 a stroke equidistant from its nearest outer boundaries. If
595 the object has holes it creates a ring midway between each
596 hole and its near outer boundary. This differ from shrink in
597 that shrink converts objects without holes to a single pixels
598 and thin to a stroke. It preserves Euler number.
601 Performs a top hat operation, a opening operation (which is an
602 erosion followed by a dilation) and finally substracts the
605 Some useful concepts to understant operators:
607 Operations are defined on 3-by-3 blocks of data, where the pixel in
608 the center of the block. Those pixels are numerated as follows:
614 *Neighbourhood definitions used in operation descriptions:*
616 It refers to pixels which are connected horizontally or
617 vertically to X: X1, X3, X5 and X7.
620 It refers to all pixels which are connected to X: X0, X1, X2,
621 X3, X4, X5, X6 and X7.
623 *Compatibility notes:*
625 Checking MATLAB behaviour is needed because its documentation
626 doesn't make clear if it creates a black pixel if all
627 eight-connected pixels are black or if four-connected suffice
628 (as we do currently following Pratt's book).
631 Algorithm used here is described in Pratt's book. When
632 applying it to the "circles" image in MATLAB documentation,
633 results are not the same. Perhaps MATLAB uses Blum's algoritm
634 (for further info please read comments in code).
637 This option is not available in MATLAB.
640 This option is not available in MATLAB.
643 This implementation also thickens image borders. This can
644 easily be avoided i necessary. MATLAB documentation doesn't
645 state how it behaves.
647 References: W. K. Pratt, "Digital Image Processing" Gonzalez and
648 Woods, "Digital Image Processing"
650 See also: dilate, erode, makelut, applylut
656 # name: <cell-element>
660 Perform a morphological operation on a binary image.
664 # name: <cell-element>
671 # name: <cell-element>
675 -- Function File: BW2 = bwperim(BW1)
676 -- Function File: BW2 = bwperim(BW1, N)
677 Find the perimeter of objects in binary images.
679 A pixel is part of an object perimeter if its value is one and
680 there is at least one zero-valued pixel in its neighborhood.
682 By default the neighborhood of a pixel is 4 nearest pixels, but if
683 N is set to 8 the 8 nearest pixels will be considered.
688 # name: <cell-element>
692 Find the perimeter of objects in binary images.
696 # name: <cell-element>
703 # name: <cell-element>
707 -- Function File: [IMOUT, IDX] = bwselect(IM, COLS, ROWS, CONNECT)
708 Select connected regions in a binary image.
714 vectors of starting points (x,y)
717 connectedness 4 or 8. default is 8
720 the image of all objects in image im that overlap pixels in
724 index of pixels in imout
729 # name: <cell-element>
733 Select connected regions in a binary image.
737 # name: <cell-element>
744 # name: <cell-element>
748 -- Function File: [Y, NEWMAP] = cmpermute (X,MAP)
749 -- Function File: [Y, NEWMAP] = cmpermute (X,MAP,INDEX)
750 Reorders colors in a colormap.
752 `[Y,newmap]=cmpermute(X,map)' rearranges colormap MAP randomly
753 returning colormap NEWMAP and generates indexed image Y so that it
754 mantains correspondence between indices and the colormap from
755 original indexed image X (both image and colormap pairs produce
758 `[Y,newmap]=cmpermute(X,map,index)' behaves as described above but
759 instead of sorting colors randomly, it uses INDEX to define the
760 order of the colors in the new colormap.
762 *Note:* `index' shouldn't have repeated elements, this function
763 won't explicitly check this, but it will fail if it has.
769 # name: <cell-element>
773 Reorders colors in a colormap.
777 # name: <cell-element>
784 # name: <cell-element>
788 -- Function File: [Y, NEWMAP] = cmunique (X,MAP)
789 -- Function File: [Y, NEWMAP] = cmunique (RGB)
790 -- Function File: [Y, NEWMAP] = cmunique (I)
791 Finds colormap with unique colors and corresponding image.
793 `[Y,newmap]=cmunique(X,map)' returns an indexed image Y along with
794 its associated colormap NEWMAP equivalent (which produce the same
795 image) to supplied X and its colormap MAP; but eliminating any
796 repeated rows in colormap colors and adjusting indices in the
797 image matrix as needed.
799 `[Y,newmap]=cmunique(RGB)' returns an indexed image Y along with
800 its associated colormap NEWMAP computed from a true-color image
801 RGB (a m-by-n-by-3 array), where NEWMAP is the smallest colormap
802 possible (alhough it could be as long as number of pixels in
805 `[Y,newmap]=cmunique(I)' returns an indexed image Y along with its
806 associated colormap NEWMAP computed from a intensity image I,
807 where NEWMAP is the smallest colormap possible (alhough it could
808 be as long as number of pixels in image).
812 NEWMAP is always a M-by-3 matrix, even if input image is a
813 intensity grey-scale image I (all three RGB planes are assigned
816 NEWMAP is always of class double. If we use a RGB or intensity
817 image of class uint8 or uint16, the colors in the colormap will be
818 of class double in the range [0,1] (they are divided by
819 intmax("uint8") and intmax("uint16") respectively.
825 # name: <cell-element>
829 Finds colormap with unique colors and corresponding image.
833 # name: <cell-element>
840 # name: <cell-element>
844 -- Function File: A = col2im (B, [M,N], [MM,NN], BLOCK_TYPE)
845 -- Function File: A = col2im (B, [M,N], [MM,NN])
846 Rearranges matrix columns into blocks.
848 `A=col2im(B,[m,n],[mm,nn],block_type)' rearranges columns of
849 matrix B intro blocks in a way controlled by BLOCK_TYPE param,
850 which can take the following values:
853 It uses M-by-N distinct blocks (which are not overlapped),
854 and are rearranged to form a MM-by-NN matrix A. B's height
855 must be M*N and `col2im' rearranges each column to a M-by-N
856 block and uses them to fill the whole matrix in left-to-right
857 and then up-to-down order.
860 Is uses M-by-N sliding blocks. It rearranges row vector B to
861 a (MM-M+1)-by-(NN-N+1) matrix A. B must be a
862 1-by-(MM-M+1)*(NN-N+1).
864 `A=col2im(B,[m,n],[mm,nn])' takes `distinct' as a default value
873 # name: <cell-element>
877 Rearranges matrix columns into blocks.
881 # name: <cell-element>
888 # name: <cell-element>
892 -- Function File: colfilt (A, [R, C], [M, N], 'sliding', F,...)
893 Apply filter to matrix blocks
895 For each R x C overlapping subblock of A, add a column in matrix C
896 F(C,...) should return a row vector which is then reshaped into a
897 a matrix of size A and returned. A is processed in chunks of size
900 -- Function File: colfilt (A, [R, C], [M, N], 'distinct', F,...)
901 For each R x C non-overlapping subblock of A, add a column in
902 matrix C F(C,...) should return a matrix of size C each column
903 of which is placed back into the subblock from whence it came. A
904 is processed in chunks of size M x N.
906 The present version requires that [M, N] divide size(A), but for
907 compatibility it should work even if [M, N] does not divide A. Use
908 the following instead:
910 padA = zeros (m*ceil(r/m),n*ceil(c/n));
912 B = colfilt(padA,...);
915 The present version does not handle 'distinct'
920 # name: <cell-element>
924 Apply filter to matrix blocks
929 # name: <cell-element>
936 # name: <cell-element>
940 -- Function File: M = colorgradient(C, W, N)
941 Define a colour map which smoothly traverses the given colors. C
942 contains the colours, one row per r,g,b value. W(i) is the
943 relative length of the transition from colour i to colour i+1 in
944 the entire gradient. The default is ones(rows(C)-1,1). n is the
945 length of the colour map. The default is rows(colormap).
948 colorgradient([0,0,1; 1,1,0; 1,0,0]) # blue -> yellow -> red
949 x = linspace(0,1,200);
950 imagesc(x(:,ones(30,1)))';
955 # name: <cell-element>
959 Define a colour map which smoothly traverses the given colors.
963 # name: <cell-element>
970 # name: <cell-element>
974 -- Function File: CONN = conndef (NUM_DIMS, TYPE)
975 Creates a connectivity array.
977 `conn=conndef(num_dims,type)' creates a connectivity array (CONN)
978 of NUM_DIMS dimensions and which type is defined by TYPE as
981 Neighbours touch the central element on a
982 (NUM_DIMS-1)-dimensional surface.
985 Neighbours touch the central element in any way. Equivalent to
986 `ones(repmat(3,1,NUM_DIMS))'.
992 # name: <cell-element>
996 Creates a connectivity array.
1000 # name: <cell-element>
1007 # name: <cell-element>
1011 -- Function File: R = corr2 (I,J)
1012 Returns the correlation coefficient between I and J. I, J must be
1013 real type matrices or vectors of same size.
1021 # name: <cell-element>
1025 Returns the correlation coefficient between I and J.
1029 # name: <cell-element>
1036 # name: <cell-element>
1040 -- Function File: BW2 = dilate (BW1,SE)
1041 -- Function File: BW2 = dilate (BW1,SE,ALG)
1042 -- Function File: BW2 = dilate (BW1,SE,...,N)
1043 Perform a dilation morphological operation on a binary image.
1045 BW2 = dilate(BW1, SE) returns a binary image with the result of a
1046 dilation operation on BW1 using neighbour mask SE.
1048 For each point in BW1, dilate search its neighbours (which are
1049 defined by setting to 1 their in SE). If any of its neighbours is
1050 on (1), then pixel is set to 1. If all are off (0) then it is set
1053 Center of SE is calculated using floor((size(SE)+1)/2).
1055 Pixels outside the image are considered to be 0.
1057 BW2 = dilate(BW1, SE, alg) returns the result of a dilation
1058 operation using algorithm ALG. Only 'spatial' is implemented at
1061 BW2 = dilate(BW1, SE, ..., n) returns the result of N dilation
1070 # name: <cell-element>
1074 Perform a dilation morphological operation on a binary image.
1078 # name: <cell-element>
1085 # name: <cell-element>
1089 -- Function File: BW = edge (IM, METHOD)
1090 -- Function File: BW = edge (IM, METHOD, ARG1, ARG2)
1091 -- Function File: [BW, THRESH] = edge (...)
1092 Detect edges in the given image using various methods. The first
1093 input IM is the gray scale image in which edges are to be
1094 detected. The second argument controls which method is used for
1095 detecting the edges. The rest of the input arguments depend on the
1096 selected method. The first output BW is a `logical' image
1097 containing the edges. Most methods also returns an automatically
1098 computed threshold as the second output.
1100 The METHOD input argument can any of the following strings (the
1101 default value is "Sobel")
1104 Finds the edges in IM using the Sobel approximation to the
1105 derivatives. Edge points are defined as points where the
1106 length of the gradient exceeds a threshold and is larger than
1107 it's neighbours in either the horizontal or vertical
1108 direction. The threshold is passed to the method in the third
1109 input argument ARG1. If one is not given, a threshold is
1110 automatically computed as 4*M, where M is the mean of the
1111 gradient of the entire image. The optional 4th input argument
1112 controls the direction in which the gradient is approximated.
1113 It can be either "horizontal", "vertical", or "both"
1117 Finds the edges in IM using the Prewitt approximation to the
1118 derivatives. This method works just like "Sobel" except a
1119 different aproximation the gradient is used.
1122 Finds the edges in IM using the Roberts approximation to the
1123 derivatives. Edge points are defined as points where the
1124 length of the gradient exceeds a threshold and is larger than
1125 it's neighbours in either the horizontal or vertical
1126 direction. The threshold is passed to the method in the third
1127 input argument ARG1. If one is not given, a threshold is
1128 automatically computed as 6*M, where M is the mean of the
1129 gradient of the entire image. The optional 4th input argument
1130 can be either "thinning" (default) or "nothinning". If it is
1131 "thinning" a simple thinning procedure is applied to the edge
1132 image such that the edges are only one pixel wide. If ARG2 is
1133 "nothinning", this procedure is not applied.
1136 Finds the edges in IM using the Kirsch approximation to the
1137 derivatives. Edge points are defined as points where the
1138 length of the gradient exceeds a threshold and is larger than
1139 it's neighbours in either the horizontal or vertical
1140 direction. The threshold is passed to the method in the third
1141 input argument ARG1. If one is not given, a threshold is
1142 automatically computed as M, where M is the mean of the
1143 gradient of the entire image. The optional 4th input argument
1144 controls the direction in which the gradient is approximated.
1145 It can be either "horizontal", "vertical", or "both"
1149 Finds edges in IM by convolving with the Laplacian of
1150 Gaussian (LoG) filter, and finding zero crossings. Only zero
1151 crossings where the filter response is larger than an
1152 automatically computed threshold are retained. The threshold
1153 is passed to the method in the third input argument ARG1. If
1154 one is not given, a threshold is automatically computed as
1155 0.75*M, where M is the mean of absolute value of LoG filter
1156 response. The optional 4th input argument sets the spread of
1157 the LoG filter. By default this value is 2.
1160 Finds edges in the image IM by convolving it with the
1161 user-supplied filter ARG2 and finding zero crossings larger
1162 than the threshold ARG1. If ARG1 is [] a threshold is
1163 computed as the mean value of the absolute filter response.
1166 Finds edges using the Canny edge detector. The optional third
1167 input argument ARG1 sets the thresholds used in the
1168 hysteresis thresholding. If ARG1 is a two dimensional vector
1169 it's first element is used as the lower threshold, while the
1170 second element is used as the high threshold. If, on the
1171 other hand, ARG1 is a single scalar it is used as the high
1172 threshold, while the lower threshold is 0.4*ARG1. The
1173 optional 4th input argument ARG2 is the spread of the
1174 low-pass Gaussian filter that is used to smooth the input
1175 image prior to estimating gradients. By default this scale
1179 Finds edges using in IM using the differential geometric
1180 single-scale edge detector given by Tony Lindeberg. The
1181 optional third input argument ARG1 is the scale (spread of
1182 Gaussian filter) at which the edges are computed. By default
1186 A.Adler's idea (c) 1999. Somewhat based on the canny method.
1188 1. Do a Sobel edge detection and to generate an image at a
1189 high and low threshold.
1191 2. Edge extend all edges in the LT image by several pixels,
1192 in the vertical, horizontal, and 45 degree directions.
1193 Combine these into edge extended (EE) image.
1195 3. Dilate the EE image by 1 step.
1197 4. Select all EE features that are connected to features in
1200 The parameters for the method is given in a vector:
1201 params(1)==0 or 4 or 8
1202 Perform x connected dilatation (step 3).
1205 Dilatation coeficient (threshold) in step 3.
1208 Length of edge extention convolution (step 2).
1211 Coeficient of extention convolution in step 2.
1212 defaults = [8, 1, 3, 3]
1215 See also: fspecial, nonmax_supress
1221 # name: <cell-element>
1225 Detect edges in the given image using various methods.
1229 # name: <cell-element>
1236 # name: <cell-element>
1240 -- Function File: E = entropy (IM)
1241 -- Function File: E = entropy (IM, NBINS)
1242 Computes the entropy of an image.
1244 The entropy of the elements of the image IM is computed as
1246 E = -sum (P .* log2 (P)
1248 where P is the distribution of the elements of IM. The distribution
1249 is approximated using a histogram with NBINS cells. If IM is
1250 `logical' then two cells are used by default. For other classes
1251 256 cells are used by default.
1253 When the entropy is computed, zero-valued cells of the histogram
1256 See also: entropyfilt
1262 # name: <cell-element>
1266 Computes the entropy of an image.
1270 # name: <cell-element>
1277 # name: <cell-element>
1281 -- Function File: E = entropyfilt (IM)
1282 -- Function File: E = entropyfilt (IM, DOMAIN)
1283 -- Function File: E = entropyfilt (IM, DOMAIN, PADDING, ...)
1284 Computes the local entropy in a neighbourhood around each pixel in
1287 The entropy of the elements of the neighbourhood is computed as
1289 E = -sum (P .* log2 (P)
1291 where P is the distribution of the elements of IM. The distribution
1292 is approximated using a histogram with NBINS cells. If IM is
1293 `logical' then two cells are used. For other classes 256 cells are
1296 When the entropy is computed, zero-valued cells of the histogram
1299 The neighbourhood is defined by the DOMAIN binary mask. Elements
1300 of the mask with a non-zero value are considered part of the
1301 neighbourhood. By default a 9 by 9 matrix containing only non-zero
1304 At the border of the image, extrapolation is used. By default
1305 symmetric extrapolation is used, but any method supported by the
1306 `padarray' function can be used. Since extrapolation is used, one
1307 can expect a lower entropy near the image border.
1309 See also: entropy, paddarray, stdfilt
1315 # name: <cell-element>
1319 Computes the local entropy in a neighbourhood around each pixel in an
1324 # name: <cell-element>
1331 # name: <cell-element>
1335 -- Function File: BW2 = erode (BW1,SE)
1336 -- Function File: BW2 = erode (BW1,SE,ALG)
1337 -- Function File: BW2 = erode (BW1,SE,...,N)
1338 Perform an erosion morphological operation on a binary image.
1340 BW2 = erosion(BW1, SE) returns a binary image with the result of
1341 an erosion operation on BW1 using neighbour mask SE.
1343 For each point in BW1, erode searchs its neighbours (which are
1344 defined by setting to 1 their in SE). If all neighbours are on
1345 (1), then pixel is set to 1. If any is off (0) then it is set to 0.
1347 Center of SE is calculated using floor((size(SE)+1)/2).
1349 Pixels outside the image are considered to be 0.
1351 BW2 = erode(BW1, SE, alg) returns the result of a erosion operation
1352 using algorithm ALG. Only 'spatial' is implemented at the moment.
1354 BW2 = erosion(BW1, SE, ..., n) returns the result of N erosion
1363 # name: <cell-element>
1367 Perform an erosion morphological operation on a binary image.
1371 # name: <cell-element>
1378 # name: <cell-element>
1382 -- Function File: FCC = fchcode (BOUND)
1383 Determine the Freeman chain code for a boundary.
1385 `fchcode' computes the Freeman chain code for the N-connected
1386 boundary BOUND. N must be either 8 or 4.
1388 BOUND is a K-by-2 matrix containing the row/column coordinates of
1389 points on the boundary. Optionally, the first point can be
1390 repeated as the last point, resulting in a (K+1)-by-2 matrix.
1392 FCC is a structure containing the following elements.
1394 x0y0 = Row/column coordinates where the code starts (1-by-2)
1395 fcc = Freeman chain code (1-by-K)
1396 diff = First difference of fcc (1-by-K)
1398 The code uses the following directions.
1404 See also: bwboundaries
1410 # name: <cell-element>
1414 Determine the Freeman chain code for a boundary.
1418 # name: <cell-element>
1425 # name: <cell-element>
1429 -- Function File: fftconv2 (A, B, SHAPE)
1430 -- Function File: fftconv2 (V1, V2, A, SHAPE)
1431 Convolve 2 dimensional signals using the FFT.
1433 This method is faster but less accurate than CONV2 for large A and
1434 B. It also uses more memory. A small complex component will be
1435 introduced even if both A and B are real.
1443 # name: <cell-element>
1447 Convolve 2 dimensional signals using the FFT.
1451 # name: <cell-element>
1458 # name: <cell-element>
1462 -- Function File: FILTER = fspecial(TYPE, ARG1, ARG2)
1463 Create spatial filters for image processing.
1465 TYPE determines the shape of the filter and can be
1467 Rectangular averaging filter. The optional argument ARG1
1468 controls the size of the filter. If ARG1 is an integer N, a N
1469 by N filter is created. If it is a two-vector with elements N
1470 and M, the resulting filter will be N by M. By default a 3 by
1471 3 filter is created.
1474 Circular averaging filter. The optional argument ARG1
1475 controls the radius of the filter. If ARG1 is an integer N, a
1476 2 N + 1 filter is created. By default a radius of 5 is used.
1479 Gaussian filter. The optional argument ARG1 controls the size
1480 of the filter. If ARG1 is an integer N, a N by N filter is
1481 created. If it is a two-vector with elements N and M, the
1482 resulting filter will be N by M. By default a 3 by 3 filter is
1483 created. The optional argument ARG2 sets spread of the
1484 filter. By default a spread of 0.5 is used.
1487 Laplacian of Gaussian. The optional argument ARG1 controls
1488 the size of the filter. If ARG1 is an integer N, a N by N
1489 filter is created. If it is a two-vector with elements N and
1490 M, the resulting filter will be N by M. By default a 5 by 5
1491 filter is created. The optional argument ARG2 sets spread of
1492 the filter. By default a spread of 0.5 is used.
1495 3x3 approximation of the laplacian. The filter is
1497 (4/(ALPHA+1))*[ALPHA/4, (1-ALPHA)/4, ALPHA/4; ...
1498 (1-ALPHA)/4, -1, (1-ALPHA)/4; ...
1499 ALPHA/4, (1-ALPHA)/4, ALPHA/4];
1500 where ALPHA is a number between 0 and 1. This number can be
1501 controlled via the optional input argument ARG1. By default
1505 Sharpening filter. The following filter is returned
1506 (1/(ALPHA+1))*[-ALPHA, ALPHA-1, -ALPHA; ...
1507 ALPHA-1, ALPHA+5, ALPHA-1; ...
1508 -ALPHA, ALPHA-1, -ALPHA];
1509 where ALPHA is a number between 0 and 1. This number can be
1510 controlled via the optional input argument ARG1. By default
1514 Moion blur filter of width 1 pixel. The optional input
1515 argument ARG1 controls the length of the filter, which by
1516 default is 9. The argument ARG2 controls the angle of the
1517 filter, which by default is 0 degrees.
1520 Horizontal Sobel edge filter. The following filter is returned
1526 Horizontal Prewitt edge filter. The following filter is
1533 Horizontal Kirsch edge filter. The following filter is
1542 # name: <cell-element>
1546 Create spatial filters for image processing.
1550 # name: <cell-element>
1557 # name: <cell-element>
1561 -- Function File: X = grayslice (I,N)
1562 -- Function File: X = grayslice (I,V)
1563 creates an indexed image X from an intensitiy image I using
1564 multiple threshold levels. A scalar integer value N sets the
1573 For irregular threshold values a real vector V can be used. The
1574 values must be in the range [0,1].
1576 X = grayslice(I,[0.1,0.33,0.75,0.9])
1584 # name: <cell-element>
1588 creates an indexed image X from an intensitiy image I using multiple
1593 # name: <cell-element>
1600 # name: <cell-element>
1604 -- Function File: LEVEL= graythresh (I)
1605 Compute global image threshold using Otsu's method.
1607 The output LEVEL is a global threshold (level) that can be used to
1608 convert an intensity image to a binary image with `im2bw'. LEVEL
1609 is a normalized intensity value that lies in the range [0, 1].
1611 The function uses Otsu's method, which chooses the threshold to
1612 minimize the intraclass variance of the black and white pixels.
1614 Color images are converted grayscale before LEVEL is computed.
1622 # name: <cell-element>
1626 Compute global image threshold using Otsu's method.
1630 # name: <cell-element>
1637 # name: <cell-element>
1641 -- Function File: J = histeq (I, N)
1642 Histogram equalization of a gray-scale image. The histogram
1643 contains N bins, which defaults to 64.
1645 I: Image in double format, with values from 0.0 to 1.0
1647 J: Returned image, in double format as well
1655 # name: <cell-element>
1659 Histogram equalization of a gray-scale image.
1663 # name: <cell-element>
1670 # name: <cell-element>
1674 -- Function File: ACCUM = hough_circle (BW, R)
1675 Perform the Hough transform for circles with radius R on the
1676 black-and-white image BW.
1678 As an example, the following shows how to compute the Hough
1679 transform for circles with radius 3 or 7 in the image IM
1681 accum = hough_circle(bw, [3, 7]);
1682 If IM is an NxM image ACCUM will be an NxMx2 array, where
1683 ACCUM(:,:,1) will contain the Hough transform for circles with
1684 radius 3, and ACCUM(:,:,2) for radius 7. To find good circles you
1685 now need to find local maximas in ACCUM, which can be a hard
1686 problem. If you find a local maxima in ACCUM(row, col, 1) it
1687 means that a good circle exists with center (row,col) and radius 3.
1695 # name: <cell-element>
1699 Perform the Hough transform for circles with radius R on the
1704 # name: <cell-element>
1711 # name: <cell-element>
1715 -- Function File: H = houghtf (BW)
1716 -- Function File: H = houghtf (BW, METHOD)
1717 -- Function File: H = houghtf (BW, METHOD, ARG)
1718 Perform the Hough transform for lines or circles.
1720 The METHOD argument chooses between the Hough transform for lines
1721 and circles. It can be either "line" (default) or "circle".
1725 If METHOD is "line", the function will compute the Hough transform
1726 for lines. A line is parametrised in R and THETA as
1727 R = x*cos(THETA) + y*sin(THETA),
1728 where R is distance between the line and the origin, while THETA
1729 is the angle of the vector from the origin to this closest point.
1730 The result H is an N by M matrix containing the Hough transform.
1731 Here, N is the number different values of R that has been
1732 attempted. This is computed as `2*diag_length - 1', where
1733 `diag_length' is the length of the diagonal of the input image. M
1734 is the number of different values of THETA. These can be set
1735 through the third input argument ARG. This must be a vector of
1736 real numbers, and is by default `pi*(-90:90)/180'.
1740 If METHOD is "circle" the function will compute the Hough
1741 transform for circles. The circles are parametrised in R which
1742 denotes the radius of the circle. The third input argument ARG
1743 must be a real vector containing the possible values of R. If the
1744 input image is N by M, then the result H will be an N by M by K
1745 array, where K denotes the number of different values of R.
1747 As an example, the following shows how to compute the Hough
1748 transform for circles with radius 3 or 7 in the image IM
1750 H = houghtf(bw, "circle", [3, 7]);
1751 Here H will be an NxMx2 array, where H(:,:,1) will contain the
1752 Hough transform for circles with radius 3, and H(:,:,2) for radius
1753 7. To find good circles you now need to find local maximas in H.
1754 If you find a local maxima in H(row, col, 1) it means that a good
1755 circle exists with center (row,col) and radius 3. One way to
1756 locate maximas is to use the `immaximas' function.
1758 See also: hough_line, hough_circle, immaximas
1764 # name: <cell-element>
1768 Perform the Hough transform for lines or circles.
1772 # name: <cell-element>
1779 # name: <cell-element>
1783 -- Function File: BW = im2bw (I,threshold)
1784 -- Function File: BW = im2bw (X,CMAP,threshold)
1785 Converts image data types to a black-white (binary) image. The
1786 treshold value should be in the range [0,1].
1791 # name: <cell-element>
1795 Converts image data types to a black-white (binary) image.
1799 # name: <cell-element>
1806 # name: <cell-element>
1810 -- Function File: B = im2col (A, [M,N], BLOCK_TYPE)
1811 -- Function File: B = im2col (A, [M,N])
1812 -- Function File: B = im2col (A, 'indexed', ...)
1813 Rearranges image blocks into columns.
1815 `B=im2col(A, [m, n], blocktype)' rearranges blocks in A into
1816 columns in a way that's determined by BLOCK_TYPE, which can take
1817 the following values:
1820 Rearranges each distinct M-by-N block in image A into a
1821 column of B. Blocks are scanned from left to right and the up
1822 to bottom in A, and columns are added to B from left to
1823 right. If A's size is not multiple M-by-N it is padded.
1826 Rearranges any M-by-N sliding block of A in a column of B,
1827 without any padding, so only sliding blocks which can be
1828 built using a full M-by-N neighbourhood are taken. In
1829 consequence, B has M*N rows and (MM-M+1)*(NN-N+1) columns
1830 (where MM and NN are the size of A).
1832 This case is thought to be used applying operations on
1833 columns of B (for instance using sum(:)), so that result is a
1834 1-by-(MM-M+1)*(NN-N+1) vector, that is what the complementary
1835 function `col2im' expects.
1837 `B=im2col(A,[m,n])' takes `distinct' as a default value for
1840 `B=im2col(A,'indexed',...)' will treat A as an indexed image, so
1841 it will pad using 1 if A is double. All other cases (incluing
1842 indexed matrices with uint8 and uint16 types and non-indexed
1843 images) will use 0 as padding value.
1845 Any padding needed in 'distinct' processing will be added at right
1846 and bottom edges of the image.
1854 # name: <cell-element>
1858 Rearranges image blocks into columns.
1862 # name: <cell-element>
1869 # name: <cell-element>
1873 -- Function File: IM2 = im2double(IM1)
1874 Converts the input image to an image of class double.
1876 If the input image is of class double the output is unchanged. If
1877 the input is of class uint8 the result will be converted to doubles
1878 and divided by 255, and if the input is of class uint16 the image
1879 will be converted to doubles and divided by 65535.
1881 See also: im2bw, im2uint16, im2uint8
1887 # name: <cell-element>
1891 Converts the input image to an image of class double.
1895 # name: <cell-element>
1902 # name: <cell-element>
1906 -- Function File: IM2 = im2uint16(IM1)
1907 Converts the input image to an image of class uint16.
1909 If the input image is of class uint16 the output is unchanged. If
1910 the input is of class uint8 the result will be converted to uint16
1911 and multiplied by 257, and if the input is of class double the
1912 image will be multiplied by 65535 and converted to uint16.
1914 See also: im2bw, im2double, im2uint8
1920 # name: <cell-element>
1924 Converts the input image to an image of class uint16.
1928 # name: <cell-element>
1935 # name: <cell-element>
1939 -- Function File: IM2 = im2uint8(IM1)
1940 Converts the input image to an image of class uint8.
1942 If the input image is of class uint8 the output is unchanged. If
1943 the input is of class double the result will be multiplied by 255
1944 and converted to uint8, and if the input is of class uint16 the
1945 image will be divided by 257 and converted to uint8.
1947 See also: im2bw, im2uint16, im2double
1953 # name: <cell-element>
1957 Converts the input image to an image of class uint8.
1961 # name: <cell-element>
1968 # name: <cell-element>
1972 -- Function File: J = imadjust (I)
1973 -- Function File: J = imadjust (I,[LOW_IN;HIGH_IN])
1974 -- Function File: J = imadjust (I,[LOW_IN;HIGH_IN],[LOW_OUT;HIGH_OUT])
1975 -- Function File: J = imadjust (..., GAMMA)
1976 -- Function File: NEWMAP = imadjust (MAP, ...)
1977 -- Function File: RGB_OUT = imadjust (RGB, ...)
1978 Adjust image or colormap values to a specified range.
1980 `J=imadjust(I)' adjusts intensity image I values so that 1% of
1981 data on lower and higher values (2% in total) of the image is
1982 saturated; choosing for that the corresponding lower and higher
1983 bounds (using `stretchlim') and mapping them to 0 and 1. J is an
1984 image of the same size as I which contains mapped values. This is
1985 equivalent to `imadjust(I,stretchlim(I))'.
1987 `J=imadjust(I,[low_in;high_in])' behaves as described but uses
1988 LOW_IN and HIGH_IN values instead of calculating them. It maps
1989 those values to 0 and 1; saturates values lower than first limit
1990 to 0 and values higher than second to 1; and finally maps all
1991 values between limits linearly to a value between 0 and 1. If `[]'
1992 is passes as `[low_in;high_in]' value, then `[0;1]' is taken as a
1995 `J=imadjust(I,[low_in;high_in],[low_out;high_out])' behaves as
1996 described but maps output values between LOW_OUT and HIGH_OUT
1997 instead of 0 and 1. A default value `[]' can also be used for this
1998 parameter, which is taken as `[0;1]'.
2000 `J=imadjust(...,gamma)' takes, in addition of 3 parameters
2001 explained above, an extra parameter GAMMA, which specifies the
2002 shape of the mapping curve between input elements and output
2003 elements, which is linear (as taken if this parameter is omitted).
2004 If GAMMA is above 1, then function is weighted towards lower
2005 values, and if below 1, towards higher values.
2007 `newmap=imadjust(map,...)' applies a transformation to a colormap
2008 MAP, which output is NEWMAP. This transformation is the same as
2009 explained above, just using a map instead of an image. LOW_IN,
2010 HIGH_IN, LOW_OUT, HIGH_OUT and GAMMA can be scalars, in which case
2011 the same values are applied for all three color components of a
2012 map; or it can be 1-by-3 vectors, to define unique mappings for
2015 `RGB_out=imadjust(RGB,...)' adjust RGB image RGB (a M-by-N-by-3
2016 array) the same way as specified in images and colormaps. Here
2017 too LOW_IN, HIGH_IN, LOW_OUT, HIGH_OUT and GAMMA can be scalars or
2018 1-by-3 matrices, to specify the same mapping for all planes, or
2019 unique mappings for each.
2021 The formula used to realize the mapping (if we omit saturation) is:
2023 `J = low_out + (high_out - low_out) .* ((I - low_in) / (high_in -
2026 *Compatibility notes:*
2028 * Prior versions of imadjust allowed `[low_in; high_in]' and
2029 `[low_out; high_out]' to be row vectors. Compatibility with
2030 this behaviour has been keeped, although preferred form is
2031 vertical vector (since it extends nicely to 2-by-3 matrices
2032 for RGB images and colormaps).
2034 * Previous version of imadjust, if `low_in>high_in' it
2035 "negated" output. Now it is negated if `low_out>high_out',
2036 for compatibility with MATLAB.
2038 * Class of I is not considered, so limit values are not
2039 modified depending on class of the image, just treated "as
2040 is". When Octave 2.1.58 is out, limits will be multiplied by
2041 255 for uint8 images and by 65535 for uint16 as in MATLAB.
2043 See also: stretchlim, brighten
2049 # name: <cell-element>
2053 Adjust image or colormap values to a specified range.
2057 # name: <cell-element>
2064 # name: <cell-element>
2068 -- Function File: B = imclose (A, SE)
2069 Perform morphological closing on a given image. The image A must
2070 be a grayscale or binary image, and SE must be a structuring
2073 The closing corresponds to a dilation followed by an erosion of
2075 B = imerode(imdilate(A, se), se);
2077 See also: imdilate, imerode, imclose
2083 # name: <cell-element>
2087 Perform morphological closing on a given image.
2091 # name: <cell-element>
2098 # name: <cell-element>
2102 -- Function File: B = imcomplement(A)
2103 Computes the complement image. Intuitively this corresponds to the
2104 intensity of bright and dark regions being reversed.
2106 For binary images, the complement is computed as `!A', for floating
2107 point images it is computed as `1 - A', and for integer images as
2108 `intmax(class(A)) - A'.
2113 # name: <cell-element>
2117 Computes the complement image.
2121 # name: <cell-element>
2128 # name: <cell-element>
2132 -- Function File: B = imdilate (A, SE)
2133 Perform morphological dilation on a given image.
2135 The image A must be a grayscale or binary image, and SE must be a
2136 structuring element. Both must have the same class, e.g., if A is a
2137 logical matrix, SE must also be logical.
2139 See also: imerode, imopen, imclose
2145 # name: <cell-element>
2149 Perform morphological dilation on a given image.
2153 # name: <cell-element>
2160 # name: <cell-element>
2164 -- Function File: [Y, NEWMAP] = imdither (IMG)
2165 -- Function File: [Y, NEWMAP] = imdither (IMG, COLORS)
2166 -- Function File: [Y, NEWMAP] = imdither (IMG, COLORS, DITHTYPE)
2167 -- Function File: [Y, NEWMAP] = imdither (IMG, MAP)
2168 -- Function File: [Y, NEWMAP] = imdither (IMG, MAP, COLORS)
2169 -- Function File: [Y, NEWMAP] = imdither(IMG, MAP, COLORS, DITHTYPE)
2170 Reduce the number a colors of rgb or indexed image.
2172 Note: this requires the ImageMagick "convert" utility. get this
2173 from www.imagemagick.org if required additional documentation of
2174 options is available from the convert man page.
2176 where DITHTYPE is a value from list:
2180 * "FloydSteinberg" (default)
2184 COLORS is a maximum number of colors in result map
2186 TODO: Add facility to use already created colormap over "-remap"
2189 BUGS: This function return a 0-based indexed images when colormap
2190 size is lower or equals to 256 like at cmunique code
2198 # name: <cell-element>
2202 Reduce the number a colors of rgb or indexed image.
2206 # name: <cell-element>
2213 # name: <cell-element>
2217 -- Function File: B = imerode (A, SE)
2218 Perform morphological erosion on a given image.
2220 The image A must be a grayscale or binary image, and SE must be a
2221 structuring element. Both must have the same class, e.g., if A is a
2222 logical matrix, SE must also be logical.
2224 See also: imdilate, imopen, imclose
2230 # name: <cell-element>
2234 Perform morphological erosion on a given image.
2238 # name: <cell-element>
2245 # name: <cell-element>
2249 -- Function File: J = imfilter(I, F)
2250 -- Function File: J = imfilter(I, F, OPTIONS, ...)
2251 Computes the linear filtering of the image I and the filter F.
2252 The computation is performed using double precision floating point
2253 numbers, but the class of the input image is preserved as the
2254 following example shows.
2255 I = 255*ones(100, 100, "uint8");
2256 f = fspecial("average", 3);
2261 The function also accepts a number of optional arguments that
2262 control the details of the filtering. The following options is
2265 If a scalar input argument is given, the image is padded with
2266 this scalar as part of the filtering. The default value is 0.
2269 The image is padded symmetrically.
2272 The image is padded using the border of the image.
2275 The image is padded by circular repeating of the image
2279 The size of the output image is the same as the input image.
2280 This is the default behaviour.
2283 Returns the full filtering result.
2286 The filtering is performed using correlation. This is the
2290 The filtering is performed using convolution.
2292 See also: conv2, filter2, fspecial, padarray
2298 # name: <cell-element>
2302 Computes the linear filtering of the image I and the filter F.
2306 # name: <cell-element>
2313 # name: <cell-element>
2317 -- Function File: HW = imginfo (FILENAME)
2318 -- Function File: [H, W] = imginfo (FILENAME)
2319 Get image size from file FILENAME.
2321 The output is the size of the image
2323 Height of image, in pixels.
2326 Width of image, in pixels.
2329 Height and width of image.
2331 NOTE : imginfo relies on the 'convert' program.
2336 # name: <cell-element>
2340 Get image size from file FILENAME.
2344 # name: <cell-element>
2351 # name: <cell-element>
2355 -- Function File: imhist (I,N)
2356 -- Function File: imhist (I)
2357 -- Function File: imhist (X,CMAP)
2358 -- Function File: [N,X] = imhist (...)
2359 Shows the histogram of an image using hist.
2367 # name: <cell-element>
2371 Shows the histogram of an image using hist.
2375 # name: <cell-element>
2382 # name: <cell-element>
2386 -- Function File: [R, C] = immaximas (IM, RADIUS)
2387 -- Function File: [R, C] = immaximas (IM, RADIUS, THRESH)
2388 -- Function File: [R, C, ...] = immaximas (...)
2389 -- Function File: [..., VAL] = immaximas (...)
2390 Finds local spatial maximas of the given image. A local spatial
2391 maxima is defined as an image point with a value that is larger
2392 than all neighbouring values in a square region of width
2393 2*RADIUS+1. By default RADIUS is 1, such that a 3 by 3
2394 neighbourhood is searched. If the THRESH input argument is
2395 supplied, only local maximas with a value greater than THRESH are
2398 The output vectors R and C contain the row-column coordinates of
2399 the local maximas. The actual values are computed to sub-pixel
2400 precision by fitting a parabola to the data around the pixel. If
2401 IM is N-dimensional, then N vectors will be returned.
2403 If IM is N-dimensional, and N+1 outputs are requested, then the
2404 last output will contain the image values at the maximas. Currently
2405 this value is not interpolated.
2407 See also: ordfilt2, ordfiltn
2413 # name: <cell-element>
2417 Finds local spatial maximas of the given image.
2421 # name: <cell-element>
2428 # name: <cell-element>
2432 -- Function File: B = imnoise (A, TYPE)
2433 Adds noise to image in A.
2435 `imnoise (A, 'gaussian' [, mean [, var]])'
2436 additive gaussian noise: B = A + noise defaults to mean=0,
2439 `imnoise (A, 'salt & pepper' [, density])'
2440 lost pixels: A = 0 or 1 for density*100% of the pixels
2441 defaults to density=0.05, or 5%
2443 `imnoise (A, 'speckle' [, var])'
2444 multiplicative gaussian noise: B = A + A*noise defaults to
2450 # name: <cell-element>
2454 Adds noise to image in A.
2458 # name: <cell-element>
2465 # name: <cell-element>
2469 -- Function File: B = imopen (A, SE)
2470 Perform morphological opening on a given image. The image A must
2471 be a grayscale or binary image, and SE must be a structuring
2474 The opening corresponds to an erosion followed by a dilation of
2476 B = imdilate(imerode(A, se), se);
2478 See also: imdilate, imerode, imclose
2484 # name: <cell-element>
2488 Perform morphological opening on a given image.
2492 # name: <cell-element>
2499 # name: <cell-element>
2503 -- Function File: impad(A, XPAD, YPAD, [PADDING, [CONST]])
2504 Pad (augment) a matrix for application of image processing
2507 Pads the input image A with XPAD(1) elements from left, XPAD(2),
2508 elements from right, YPAD(1) elements from above and YPAD(2)
2509 elements from below. Values of padding elements are determined
2510 from the optional arguments PADDING and CONST. PADDING is one of
2513 pad with zeros (default)
2519 pad with a value obtained from the optional fifth argument
2523 pad with values obtained from A so that the padded image
2524 mirrors A starting from edges of A
2527 same as symmetric, but the edge rows and columns are not used
2531 pad with values obtained from A so that the padded image
2532 repeates itself in two dimensions
2538 # name: <cell-element>
2542 Pad (augment) a matrix for application of image processing algorithms.
2546 # name: <cell-element>
2553 # name: <cell-element>
2557 -- Function File: WARPED = imperspectivewarp(IM, P, INTERP, BBOX,
2559 -- Function File: [ WARPED, VALID] = imperspectivewarp(...)
2560 Applies the spatial perspective homogeneous transformation P to
2561 the image IM. The transformation matrix P must be a 3x3
2562 homogeneous matrix, or 2x2 or 2x3 affine transformation matrix.
2564 The resulting image WARPED is computed using an interpolation
2565 method that can be selected through the INTERP argument. This must
2566 be one of the following strings
2568 Nearest neighbor interpolation.
2572 Bilinear interpolation. This is the default behavior.
2576 Bicubic interpolation.
2578 By default the resulting image contains the entire warped image.
2579 In some situation you only parts of the warped image. The argument
2580 BBOX controls this, and can be one of the following strings
2582 The entire warped result is returned. This is the default
2586 The central part of the image of the same size as the input
2590 The size and coordinate system of the input image is keept.
2592 All values of the result that fall outside the original image will
2593 be set to EXTRAPVAL. For images of class `double' EXTRAPVAL
2594 defaults to `NA' and for other classes it defaults to 0.
2596 The optional output VALID is a matrix of the same size as WARPED
2597 that contains the value 1 in pixels where WARPED contains an
2598 interpolated value, and 0 in pixels where WARPED contains an
2601 See also: imremap, imrotate, imresize, imshear, interp2
2607 # name: <cell-element>
2611 Applies the spatial perspective homogeneous transformation P to the
2616 # name: <cell-element>
2623 # name: <cell-element>
2627 -- Function File: WARPED = imremap(IM, XI, YI)
2628 -- Function File: WARPED = imremap(IM, XI, YI, INTERP, EXTRAPVAL)
2629 -- Function File: [ WARPED, VALID ] = imremap(...)
2630 Applies any geometric transformation to the image IM.
2632 The arguments XI and YI are lookup tables that define the resulting
2634 WARPED(y,x) = IM(YI(y,x), XI(y,x))
2635 where IM is assumed to be a continuous function, which is achieved
2636 by interpolation. Note that the image IM is expressed in a (X,
2637 Y)-coordinate system and not a (row, column) system.
2639 The argument INTERP selects the used interpolation method, and
2640 most be one of the following strings
2642 Nearest neighbor interpolation.
2646 Bilinear interpolation. This is the default behavior.
2650 Bicubic interpolation.
2652 All values of the result that fall outside the original image will
2653 be set to EXTRAPVAL. For images of class `double' EXTRAPVAL
2654 defaults to `NA' and for other classes it defaults to 0.
2656 The optional output VALID is a matrix of the same size as WARPED
2657 that contains the value 1 in pixels where WARPED contains an
2658 interpolated value, and 0 in pixels where WARPED contains an
2661 See also: imperspectivewarp, imrotate, imresize, imshear, interp2
2667 # name: <cell-element>
2671 Applies any geometric transformation to the image IM.
2675 # name: <cell-element>
2682 # name: <cell-element>
2686 -- Function File: B = imresize (A, M)
2687 Scales the image A by a factor M using bicubic neighbour
2688 interpolation. If M is less than 1 the image size will be reduced,
2689 and if M is greater than 1 the image will be enlarged.
2691 -- Function File: B = imresize (A, M, INTERP)
2692 Same as above except INTERP interpolation is performed instead of
2693 using nearest neighbour. INTERP can be any interpolation method
2694 supported by interp2. By default, bicubic interpolation is used.
2696 -- Function File: B = imresize (A, [MROW MCOL])
2697 Scales the image A to be of size MROWxMCOL.
2699 -- Function File: B = imresize (A, [MROW MCOL], INTERP)
2700 Same as above except INTERP interpolation is performed. INTERP can
2701 be any interpolation method supported by interp2.
2703 See also: imremap, imrotate, interp2
2709 # name: <cell-element>
2713 Scales the image A by a factor M using bicubic neighbour interpolation.
2717 # name: <cell-element>
2724 # name: <cell-element>
2728 -- Function File: imrotate(IMGPRE, THETA, METHOD, BBOX, EXTRAPVAL)
2729 Rotation of a 2D matrix about its center.
2733 IMGPRE a gray-level image matrix
2735 THETA the rotation angle in degrees counterclockwise
2738 "nearest" neighbor: fast, but produces aliasing effects
2741 "bilinear" interpolation: does anti-aliasing, but is slightly
2744 "bicubic" interpolation: does anti-aliasing, preserves edges
2745 better than bilinear interpolation, but gray levels may
2746 slightly overshoot at sharp edges. This is probably the best
2747 method for most purposes, but also the slowest.
2749 "Fourier" uses Fourier interpolation, decomposing the
2750 rotation matrix into 3 shears. This method often results in
2751 different artifacts than homography-based methods. Instead
2752 of slightly blurry edges, this method can result in ringing
2753 artifacts (little waves near high-contrast edges). However,
2754 Fourier interpolation is better at maintaining the image
2755 information, so that unrotating will result in an image
2756 closer to the original than the other methods.
2759 "loose" grows the image to accommodate the rotated image
2762 "crop" rotates the image about its center, clipping any part
2763 of the image that is moved outside its boundaries.
2765 EXTRAPVAL sets the value used for extrapolation. The default value
2766 is `NA' for images represented using doubles, and 0 otherwise.
2767 This argument is ignored of Fourier interpolation is used.
2771 IMGPOST the rotated image matrix
2773 H the homography mapping original to rotated pixel
2774 coordinates. To map a coordinate vector c = [x;y] to its
2775 rotated location, compute round((H * [c; 1])(1:2)).
2777 VALID a binary matrix describing which pixels are valid,
2778 and which pixels are extrapolated. This output is
2779 not available if Fourier interpolation is used.
2784 # name: <cell-element>
2788 Rotation of a 2D matrix about its center.
2792 # name: <cell-element>
2799 # name: <cell-element>
2803 -- Function File: imrotate(M, THETA, METHOD, BBOX)
2804 Rotation of a 2D matrix.
2806 Applies a rotation of THETA degrees to matrix M.
2808 The METHOD argument is not implemented, and is only included for
2809 compatibility with Matlab. This function uses Fourier
2810 interpolation, decomposing the rotation matrix into 3 shears.
2812 BBOX can be either 'loose' or 'crop'. 'loose' allows the image to
2813 grow to accomodate the rotated image. 'crop' keeps the same size
2814 as the original, clipping any part of the image that is moved
2815 outside the bounding box.
2820 # name: <cell-element>
2824 Rotation of a 2D matrix.
2828 # name: <cell-element>
2835 # name: <cell-element>
2839 -- Function File: imshear (M, AXIS, ALPHA, BBOX)
2840 Applies a shear to the image M.
2842 The argument M is either a matrix or an RGB image.
2844 AXIS is the axis along which the shear is to be applied, and can
2845 be either 'x' or 'y'. For example, to shear sideways is to shear
2846 along the 'x' axis. Choosing 'y' causes an up/down shearing.
2848 ALPHA is the slope of the shear. For an 'x' shear, it is the
2849 horizontal shift (in pixels) applied to the pixel above the
2850 center. For a 'y' shear, it is the vertical shift (in pixels)
2851 applied to the pixel just to the right of the center pixel.
2853 NOTE: ALPHA does NOT need to be an integer.
2855 BBOX can be one of 'loose', 'crop' or 'wrap'. 'loose' allows the
2856 image to grow to accomodate the new transformed image. 'crop'
2857 keeps the same size as the original, clipping any part of the image
2858 that is moved outside the bounding box. 'wrap' keeps the same
2859 size as the original, but does not clip the part of the image that
2860 is outside the bounding box. Instead, it wraps it back into the
2863 If called with only 3 arguments, BBOX is set to 'loose' by default.
2868 # name: <cell-element>
2872 Applies a shear to the image M.
2876 # name: <cell-element>
2883 # name: <cell-element>
2887 -- Function File: J = imsmooth(I, NAME, OPTIONS)
2888 Smooth the given image using several different algorithms.
2890 The first input argument I is the image to be smoothed. If it is
2891 an RGB image, each color plane is treated separately. The
2892 variable NAME must be a string that determines which algorithm will
2893 be used in the smoothing. It can be any of the following strings
2896 Isotropic Gaussian smoothing. This is the default.
2899 Smoothing using a rectangular averaging linear filter.
2902 Smoothing using a circular averaging linear filter.
2908 Gaussian bilateral filtering.
2913 Smoothing using nonlinear isotropic diffusion as described by
2917 Gaussian smoothing with a spatially varying covariance matrix.
2919 In all algorithms the computation is done in double precision
2920 floating point numbers, but the result has the same type as the
2921 input. Also, the size of the smoothed image is the same as the
2924 *Isotropic Gaussian smoothing*
2926 The image is convolved with a Gaussian filter with spread SIGMA.
2927 By default SIGMA is 0.5, but this can be changed. If the third
2928 input argument is a scalar it is used as the filter spread.
2930 The image is extrapolated symmetrically before the convolution
2933 *Rectangular averaging linear filter*
2935 The image is convolved with N by M rectangular averaging filter.
2936 By default a 3 by 3 filter is used, but this can e changed. If the
2937 third input argument is a scalar N a N by N filter is used. If the
2938 third input argument is a two-vector `[N, M]' a N by M filter is
2941 The image is extrapolated symmetrically before the convolution
2944 *Circular averaging linear filter*
2946 The image is convolved with circular averaging filter. By default
2947 the filter has a radius of 5, but this can e changed. If the third
2948 input argument is a scalar R the radius will be R.
2950 The image is extrapolated symmetrically before the convolution
2955 Each pixel is replaced with the median of the pixels in the local
2956 area. By default, this area is 3 by 3, but this can be changed. If
2957 the third input argument is a scalar N the area will be N by N,
2958 and if it's a two-vector [N, M] the area will be N by M.
2960 The image is extrapolated symmetrically before the filtering is
2963 *Gaussian bilateral filtering*
2965 The image is smoothed using Gaussian bilateral filtering as
2966 described by Tomasi and Manduchi [2]. The filtering result is
2968 J(x0, y0) = k * SUM SUM I(x,y) * w(x, y, x0, y0, I(x0,y0), I(x,y))
2970 where `k' a normalisation variable, and
2971 w(x, y, x0, y0, I(x0,y0), I(x,y))
2972 = exp(-0.5*d([x0,y0],[x,y])^2/SIGMA_D^2)
2973 * exp(-0.5*d(I(x0,y0),I(x,y))^2/SIGMA_R^2),
2974 with `d' being the Euclidian distance function. The two paramteres
2975 SIGMA_D and SIGMA_R control the amount of smoothing. SIGMA_D is
2976 the size of the spatial smoothing filter, while SIGMA_R is the size
2977 of the range filter. When SIGMA_R is large the filter behaves
2978 almost like the isotropic Gaussian filter with spread SIGMA_D, and
2979 when it is small edges are preserved better. By default SIGMA_D is
2980 2, and SIGMA_R is 10/255 for floating points images (with integer
2981 images this is multiplied with the maximal possible value
2982 representable by the integer class).
2984 The image is extrapolated symmetrically before the filtering is
2989 The image is smoothed using nonlinear isotropic diffusion as
2990 described by Perona and Malik [1]. The algorithm iteratively
2991 updates the image using
2993 I += lambda * (g(dN).*dN + g(dS).*dS + g(dE).*dE + g(dW).*dW)
2995 where `dN' is the spatial derivative of the image in the North
2996 direction, and so forth. The function G determines the behaviour
2997 of the diffusion. If g(x) = 1 this is standard isotropic
3000 The above update equation is repeated ITER times, which by default
3001 is 10 times. If the third input argument is a positive scalar,
3002 that number of updates will be performed.
3004 The update parameter LAMBDA affects how much smoothing happens in
3005 each iteration. The algorithm can only be proved stable is LAMBDA
3006 is between 0 and 0.25, and by default it is 0.25. If the fourth
3007 input argument is given this parameter can be changed.
3009 The function G in the update equation determines the type of the
3010 result. By default `G(D) = exp(-(D./K).^2)' where K = 25. This
3011 choice gives privileges to high-contrast edges over low-contrast
3012 ones. An alternative is to set `G(D) = 1./(1 + (D./K).^2)', which
3013 gives privileges to wide regions over smaller ones. The choice of G
3014 can be controlled through the fifth input argument. If it is the
3015 string `"method1"', the first mentioned function is used, and if
3016 it is "METHOD2" the second one is used. The argument can also be a
3017 function handle, in which case the given function is used. It
3018 should be noted that for stability reasons, G should return values
3021 The following example shows how to set `G(D) = exp(-(D./K).^2)'
3022 where K = 50. The update will be repeated 25 times, with LAMBDA =
3025 G = @(D) exp(-(D./50).^2);
3026 J = imsmooth(I, "p&m", 25, 0.25, G);
3028 *Custom Gaussian Smoothing*
3030 The image is smoothed using a Gaussian filter with a spatially
3031 varying covariance matrix. The third and fourth input arguments
3032 contain the Eigenvalues of the covariance matrix, while the fifth
3033 contains the rotation of the Gaussian. These arguments can be
3034 matrices of the same size as the input image, or scalars. In the
3035 last case the scalar is used in all pixels. If the rotation is not
3036 given it defaults to zero.
3038 The following example shows how to increase the size of an Gaussian
3039 filter, such that it is small near the upper right corner of the
3040 image, and large near the lower left corner.
3042 [LAMBDA1, LAMBDA2] = meshgrid (linspace (0, 25, columns (I)), linspace (0, 25, rows (I)));
3043 J = imsmooth (I, "Custom Gaussian", LAMBDA1, LAMBDA2);
3045 The implementation uses an elliptic filter, where only
3046 neighbouring pixels with a Mahalanobis' distance to the current
3047 pixel that is less than 3 are used to compute the response. The
3048 response is computed using double precision floating points, but
3049 the result is of the same class as the input image.
3053 [1] P. Perona and J. Malik, "Scale-space and edge detection using
3054 anisotropic diffusion", IEEE Transactions on Pattern Analysis and
3055 Machine Intelligence, 12(7):629-639, 1990.
3057 [2] C. Tomasi and R. Manduchi, "Bilateral Filtering for Gray and
3058 Color Images", Proceedings of the 1998 IEEE International
3059 Conference on Computer Vision, Bombay, India.
3061 See also: imfilter, fspecial
3067 # name: <cell-element>
3071 Smooth the given image using several different algorithms.
3075 # name: <cell-element>
3082 # name: <cell-element>
3086 -- Function File: B = imtophat (A, SE)
3087 -- Function File: B = imtophat (A, SE, TYPE)
3088 Perform morphological top hat filtering.
3090 The image A must be a grayscale or binary image, and SE must be a
3091 structuring element. Both must have the same class, e.g., if A is a
3092 logical matrix, SE must also be logical.
3094 TYPE defines the type of top hat transform. To perform a white, or
3095 opening, top-hat transform its value must be `open' or `white'. To
3096 perform a black, or closing, top-hat transform its value must be
3097 `close' or `black'. If TYPE is not specified, it performs a white
3100 See also: imerode, imdilate, imopen, imclose, mmgradm
3106 # name: <cell-element>
3110 Perform morphological top hat filtering.
3114 # name: <cell-element>
3121 # name: <cell-element>
3125 -- Function File: Y = imtranslate (M, X, Y [, BBOX])
3126 Translate a 2D image by (x,y) using Fourier interpolation.
3128 M is a matrix, and is translated to the right by X pixels and
3129 translated up by Y pixels.
3131 BBOX can be either 'crop' or 'wrap' (default).
3137 # name: <cell-element>
3141 Translate a 2D image by (x,y) using Fourier interpolation.
3145 # name: <cell-element>
3152 # name: <cell-element>
3156 -- Function: RECON = iradon (PROJ, THETA, INTERP, FILTER, SCALING,
3158 Performs filtered back-projection on the projections in PROJ to
3159 reconstruct an approximation of the original image.
3161 PROJ should be a matrix whose columns are projections of an image
3162 (or slice). Each element of THETA is used as the angle (in
3163 degrees) that the corresponding column of PROJ was projected at.
3164 If THETA is omitted, it is assumed that projections were taken at
3165 evenly spaced angles between 0 and 180 degrees. THETA can also be
3166 a scalar, in which case it is taken as the angle between
3167 projections if more than one projection is provided.
3169 INTERP determines the type of interpolation that is used in the
3170 back-projection. It must be one of the types accepted by
3171 `interp1', and defaults to 'Linear' if it is omitted.
3173 FILTER and SCALING determine the type of rho filter to apply. See
3174 the help for `rho_filter' for their use.
3176 OUTPUT_SIZE sets the edge length of the output image (it is always
3177 square). This argument does not scale the image. If it is
3178 omitted, the length is taken to be
3179 2 * floor (size (proj, 1) / (2 * sqrt (2))).
3181 If PROJ was obtained using `radon', there is no guarantee that the
3182 reconstructed image will be exactly the same size as the original.
3184 -- Function: [RECON, FILT] = iradon (...)
3185 This form also returns the filter frequency response in the vector
3188 Performs filtered back-projection in order to reconstruct an image
3189 based on its projections.
3191 Filtered back-projection is the most common means of reconstructing
3192 images from CT scans. It is a two step process: First, each of the
3193 projections is filtered with a `rho filter', so named due to its
3194 frequency domain definition, which is simply |rho|, where rho is the
3195 radial axis in a polar coordinate system. Second, the filtered
3196 projections are each `smeared' across the image space. This is the
3197 back-projection part.
3201 projections = radon (P, 1:179);
3202 reconstruction = iradon (filtered_projections, 1:179, 'Spline', 'Hann');
3203 figure, imshow (reconstruction, [])
3208 # name: <cell-element>
3212 Performs filtered back-projection on the projections in PROJ to
3217 # name: <cell-element>
3224 # name: <cell-element>
3228 -- Function File: BOOL = isbw (BW)
3229 Returns true for a black-white (binary) image. All values must be
3235 # name: <cell-element>
3239 Returns true for a black-white (binary) image.
3243 # name: <cell-element>
3250 # name: <cell-element>
3254 -- Function File: BOOL = isgray (I)
3255 Returns true for an gray-scale intensity image. An variable is a
3256 gray scale image if it is 2-dimensional matrix, and
3257 * is of class double and all values are in the range [0, 1], or
3259 * is of class uint8 or uint16.
3264 # name: <cell-element>
3268 Returns true for an gray-scale intensity image.
3272 # name: <cell-element>
3279 # name: <cell-element>
3283 -- Function File: BOOL = isind (X)
3284 Returns true for an index image. All index values must be
3285 intergers and greater than or equal to 1.
3290 # name: <cell-element>
3294 Returns true for an index image.
3298 # name: <cell-element>
3305 # name: <cell-element>
3309 -- Function File: FLAG = isrgb (A)
3310 Returns true if parameter is a RGB image.
3312 `flag=isrgb(A)' returns 1 if A is a RGB image and 0 if not.
3314 To the decide `isrgb' uses the follow algorithm:
3315 * If A is of class double then it checks if all values are
3316 between 0 and 1, and if size is m-by-n-by-3.
3318 * If A is of class uint16, uint8 or logical then it checks is
3321 *Compatibility notes:*
3323 Information needed on whether MATLAB accepts logical arrays as RGB
3324 images (now this functions accepts them if they are m-by-n-by-3
3331 # name: <cell-element>
3335 Returns true if parameter is a RGB image.
3339 # name: <cell-element>
3346 # name: <cell-element>
3350 -- Function File: RGB = label2rgb(L)
3351 -- Function File: RGB = label2rgb(L, MAP)
3352 -- Function File: RGB = label2rgb(L, MAP, BACKGROUND)
3353 -- Function File: RGB = label2rgb(L, MAP, BACKGROUND, ORDER)
3354 Converts a labeled image to an RGB image.
3356 label2rgb(L) returns a color image, where the background color
3357 (the background is the zero-labeled pixels) is white, and all other
3358 colors come from the `jet' colormap.
3360 label2rgb(L, MAP) uses colors from the given colormap. MAP can be
3361 * A string containing the name of a function to be called to
3362 produce a colormap. The default value is "jet".
3364 * A handle to a function to be called to produce a colormap.
3366 * A N-by-3 colormap matrix.
3368 label2rgb(L, MAP, BACKGROUND) sets the background color.
3369 BACKGROUND can be a 3-vector corresponding to the wanted RGB
3370 color, or one of the following strings
3372 The background color will be blue.
3375 The background color will be cyan.
3378 The background color will be green.
3381 The background color will be black.
3384 The background color will be magenta.
3387 The background color will be red.
3390 The background color will be white. This is the default
3394 The background color will be yellow.
3396 label2rgb(L, MAP, BACKGROUND, ORDER) allows for random
3397 permutations of the colormap. ORDER must be one of the following
3400 The colormap is not permuted in any ways. This is the default.
3403 The used colormap is permuted randomly.
3405 See also: bwlabel, ind2rgb
3411 # name: <cell-element>
3415 Converts a labeled image to an RGB image.
3419 # name: <cell-element>
3426 # name: <cell-element>
3430 -- Function File: LUT = makelut (FUN,N)
3431 -- Function File: LUT = makelut (FUN,N,P1,P2,...)
3432 Create a lookup table which can be used by applylut.
3434 lut = makelut(fun,n) returns a vector which can be used by applylut
3437 FUN can be a function object as created by inline, or simply a
3438 string which contains the name of a function. FUN should accept a
3439 N-by-N matrix whose elements are binary (0 or 1) and returns an
3440 scalar (actually anything suitable to be included in a vector).
3442 makelut calls FUN with all possible matrices and builds a vector
3443 with its result, suitable to be used by applylut. The length of
3444 this vector is 2^(N^2), so 16 for 2-by-2 and 512 for 3-by-3.
3446 makelut also passes parameters P1, P2, .... to FUN.
3454 # name: <cell-element>
3458 Create a lookup table which can be used by applylut.
3462 # name: <cell-element>
3469 # name: <cell-element>
3473 -- Function File: I = mat2gray (M,[min max])
3474 Converts a matrix to a intensity image.
3479 # name: <cell-element>
3483 Converts a matrix to a intensity image.
3487 # name: <cell-element>
3494 # name: <cell-element>
3498 -- Function File: M = mean2 (I)
3499 Returns the mean value for a 2d real type matrix. Uses
3502 See also: std2, mean
3508 # name: <cell-element>
3512 Returns the mean value for a 2d real type matrix.
3516 # name: <cell-element>
3523 # name: <cell-element>
3527 -- Function File: medfilt2(A, [DOMAIN, PADDING])
3528 Two dimensional median filtering.
3530 Replaces elements of A with the median of their neighbours defined
3531 by true elements of logical matrix DOMAIN. The default DOMAIN is a
3532 3 by 3 matrix with all elements equal to 1. If DOMAIN is 1 by 2
3533 row vector, the domain matrix will be logical(ones(DOMAIN(2),
3536 Optional variable PADDING defines the padding used in augmenting
3537 the borders of A. See impad for details.
3545 # name: <cell-element>
3549 Two dimensional median filtering.
3553 # name: <cell-element>
3560 # name: <cell-element>
3564 -- Function File: GRAD = mmgradm(A, SE)
3565 -- Function File: GRAD = mmgradm(A, SE_DIL, SE_ERO)
3566 Calculates the morphological gradient GRAD of a given image A.
3568 In the first form, the same structuring element SE is used for
3569 dilation and erosion. In the second form, SE_DIL and SE_ERO are the
3570 corresponding structuring elements used for dilation and erosion
3572 The image A must be a grayscale or a binary image.
3574 The morphological gradient of a image corresponds to its erosion
3575 subtracted to its dilation.
3577 See also: imerode, imdilate, imopen, imclose, imtophat
3583 # name: <cell-element>
3587 Calculates the morphological gradient GRAD of a given image A.
3591 # name: <cell-element>
3598 # name: <cell-element>
3602 -- Function File: B = nlfilter (A, [M,N], FUN)
3603 -- Function File: B = nlfilter (A, [M,N], FUN, ...)
3604 -- Function File: B = nlfilter (A,'indexed', ...)
3605 Processes image in sliding blocks using user-supplied function.
3607 `B=nlfilter(A,[m,n],fun)' passes sliding M-by-N blocks to
3608 user-supplied function FUN. A block is build for every pixel in A,
3609 such as it is centered within the block. FUN must return a
3610 scalar, and it is used to create matrix B. NLFILTER pads the
3611 M-by-N block at the edges if necessary.
3613 Center of block is taken at ceil([M,N]/2).
3615 `B=nlfilter(A,[m,n],fun,...)' behaves as described above but
3616 passes extra parameters to function FUN.
3618 `B=nlfilter(A,'indexed',...)' assumes that A is an indexed image,
3619 so it pads the image using proper value: 0 for uint8 and uint16
3620 images and 1 for double images. Keep in mind that if 'indexed' is
3621 not specified padding is always done using 0.
3623 See also: colfilt, blkproc, inline
3629 # name: <cell-element>
3633 Processes image in sliding blocks using user-supplied function.
3637 # name: <cell-element>
3644 # name: <cell-element>
3648 -- Function File: ordfilt2(A, NTH, DOMAIN, [S, PADDING])
3649 Two dimensional ordered filtering.
3651 Ordered filter replaces an element of A with the NTH element of
3652 the sorted set of neighbours defined by the logical (boolean)
3653 matrix DOMAIN. Neighbour elements are selected to the sort if the
3654 corresponding element in the DOMAIN matrix is true.
3656 The optional variable S is a matrix of size(DOMAIN). Values of S
3657 corresponding to nonzero values of domain are added to values
3658 obtained from A when doing the sorting.
3660 Optional variable PADDING determines how the matrix A is padded
3661 from the edges. See impad for details.
3669 # name: <cell-element>
3673 Two dimensional ordered filtering.
3677 # name: <cell-element>
3684 # name: <cell-element>
3688 -- Function File: ordfiltn(A, NTH, DOMAIN, [S, PADDING])
3689 Two dimensional ordered filtering.
3691 Ordered filter replaces an element of A with the NTH element of
3692 the sorted set of neighbours defined by the logical (boolean)
3693 matrix DOMAIN. Neighbour elements are selected to the sort if the
3694 corresponding element in the DOMAIN matrix is true.
3696 The optional variable S is a matrix of size(DOMAIN). Values of S
3697 corresponding to nonzero values of domain are added to values
3698 obtained from A when doing the sorting.
3700 Optional variable PADDING determines how the matrix A is padded
3701 from the edges. See `padarray' for details.
3703 See also: ordfilt2, padarray
3709 # name: <cell-element>
3713 Two dimensional ordered filtering.
3717 # name: <cell-element>
3724 # name: <cell-element>
3728 -- Function File: B = padarray (A,PADSIZE)
3729 -- Function File: B = padarray (A,PADSIZE,PADVAL)
3730 -- Function File: B = padarray (A,PADSIZE,PADVAL,DIRECTION)
3731 Pads an array in a configurable way.
3733 B = padarray(A,padsize) pads an array A with zeros, where PADSIZE
3734 defines the amount of padding to add in each dimension (it must be
3735 a vector of positive integers).
3737 Each component of PADSIZE defines the number of elements of
3738 padding that will be added in the corresponding dimension. For
3739 instance, [4,5] adds 4 elements of padding in first dimension
3740 (vertical) and 5 in second dimension (horizontal).
3742 B = padarray(A,padsize,padval) pads A using the value specified by
3743 PADVAL. PADVAL can be a scalar or a string. Possible values are:
3746 Pads with 0 as described above. This is the default behaviour.
3749 Pads using PADVAL as a padding value.
3752 Pads with a circular repetition of elements in A (similar to
3756 Pads replicating values of A which are at the border of the
3760 Pads with a mirror reflection of A.
3763 Same as "symmetric", but the borders are not used in the
3766 B = padarray(A,padsize,padval,direction) pads A defining the
3767 direction of the pad. Possible values are:
3770 For each dimension it pads before the first element the number
3771 of elements defined by PADSIZE and the same number again after
3772 the last element. This is the default value.
3775 For each dimension it pads before the first element the
3776 number of elements defined by PADSIZE.
3779 For each dimension it pads after the last element the number
3780 of elements defined by PADSIZE.
3785 # name: <cell-element>
3789 Pads an array in a configurable way.
3793 # name: <cell-element>
3800 # name: <cell-element>
3804 -- Function: P = phantom ('Shepp-Logan', N)
3805 Produces the Shepp-Logan phantom, with size N x N. If N is
3806 omitted, 256 is used.
3808 -- Function: P = phantom ('Modified Shepp-Logan', N)
3809 Produces a modified version of the Shepp-Logan phantom which has
3810 higher contrast than the original, with size N x N. If N is
3811 omitted, 256 is used.
3813 -- Function: P = phantom (ELLIPSES, N)
3814 Produces a custom phantom using the ellipses described in ELLIPSES.
3815 Each row of ELLIPSES describes one ellipse, and must have 6
3816 columns: {I, a, b, x0, y0, phi}:
3818 is the additive intensity of the ellipse
3821 is the length of the major axis
3824 is the length of the minor axis
3827 is the horizontal offset of the centre of the ellipse
3830 is the vercal offset of the centre of the ellipse
3833 is the counterclockwise rotation of the ellipse in degrees,
3834 measured as the angle between the x axis and the ellipse
3838 The image bounding box in the algorithm is {[-1, -1], [1, 1]}, so
3839 the values of a, b, x0, y0 should all be specified with this in
3840 mind. If N is omitted, 256 is used.
3842 -- Function: P = phantom (N)
3843 Creates a modified Shepp-Logan phantom with size N x N.
3845 -- Function: P = phantom ()
3846 Creates a modified Shepp-Logan phantom with size 256 x 256.
3848 Create a Shepp-Logan or modified Shepp-Logan phantom.
3850 A phantom is a known object (either real or purely mathematical) that
3851 is used for testing image reconstruction algorithms. The Shepp-Logan
3852 phantom is a popular mathematical model of a cranial slice, made up of
3853 a set of ellipses. This allows rigorous testing of computed tomography
3854 (CT) algorithms as it can be analytically transformed with the radon
3855 transform (see the function `radon').
3864 Shepp, L. A.; Logan, B. F.; Reconstructing Interior Head Tissue
3865 from X-Ray Transmissions, IEEE Transactions on Nuclear Science, Feb.
3868 Toft, P.; "The Radon Transform - Theory and Implementation", Ph.D.
3869 thesis, Department of Mathematical Modelling, Technical University of
3875 # name: <cell-element>
3879 Produces the Shepp-Logan phantom, with size N x N.
3883 # name: <cell-element>
3890 # name: <cell-element>
3894 -- Function File: BW = poly2mask (X,Y,M,N)
3895 Convert a polygon to a region mask.
3897 BW=poly2mask(x,y,m,n) converts a polygon, specified by a list of
3898 vertices in X and Y and returns in a M-by-N logical mask BW the
3899 filled polygon. Region inside the polygon is set to 1, values
3900 outside the shape are set to 0.
3902 X and Y should always represent a closed polygon, first and last
3903 points should be coincident. If they are not poly2mask will close
3904 it for you. If X or Y are fractional they are nearest integer.
3906 If all the polygon or part of it falls outside the masking area
3907 (1:m,1:n), it is discarded or clipped.
3909 This function uses scan-line polygon filling algorithm as described
3910 in http://www.cs.rit.edu/~icss571/filling/ with some minor
3911 modifications: capability of clipping and scan order, which can
3912 affect the results of the algorithm (algorithm is described not to
3913 reach ymax, xmax border when filling to avoid enlarging shapes). In
3914 this function we scan the image backwards (we begin at ymax and end
3915 at ymin), and we don't reach ymin, xmin, which we believe should be
3916 compatible with MATLAB.
3921 # name: <cell-element>
3925 Convert a polygon to a region mask.
3929 # name: <cell-element>
3936 # name: <cell-element>
3940 -- Function File: S = qtdecomp (I)
3941 -- Function File: S = qtdecomp (I,THRESHOLD)
3942 -- Function File: S = qtdecomp (I,THRESHOLD,MINDIM)
3943 -- Function File: S = qtdecomp (I,THRESHOLD,[MINDIM MAXDIM])
3944 -- Function File: S = qtdecomp (I,FUN)
3945 -- Function File: S = qtdecomp (I,FUN,P1,P2,...)
3946 Performs quadtree decomposition.
3948 qtdecomp decomposes a square image I into four equal-sized blocks.
3949 Then it performs some kind of test on each block to decide if it
3950 should decompose them further. This process is repeated
3951 iteratively until there's no block left to be decomposed.
3953 Note that blocks are not decomposed if their dimensions are not
3956 The output is a sparse matrix whose non-zero elements determine the
3957 position of the block (the element is at top-left position in the
3958 block) and size of each block (the value of the element determines
3959 length of a side of the square-shaped block).
3961 S = qtdecomp(I) decomposes an intensity image I as described
3962 above. By default it doesn't split a block if all elements are
3965 S = qtdecomp(I, threshold) decomposes an image as decribed, but
3966 only splits a block if the maximum value in the block minus the
3967 minimum value is greater than THRESHOLD, which is a value between
3968 0 and 1. If I is of class uint8, THRESHOLD is multiplied by 255
3969 before use. Also, ifI is of class uint16, THRESHOLD is multiplied
3972 S = qtdecomp(I, threshold, mindim) decomposes an image using the
3973 THRESHOLD as just described, but doesn't produce blocks smaller
3976 S = qtdecomp(I, threshold, [mindim maxdim]) decomposes an image as
3977 described, but produces blocks that can't be bigger than maxdim. It
3978 decomposes to maxdim even if it isn't needed if only THRESHOLD was
3981 S = qtdecomp(I, fun) decomposes an image I and uses function FUN
3982 to decide if a block should be splitted or not. FUN is called with
3983 a m-by-m-by-k array of m-by-m blocks to be considered, and should
3984 return a vector of size k, whose elements represent each block in
3985 the stacked array. FUN sets the corresponding value to 1 if the
3986 block should be split, and 0 otherwise.
3988 S = qtdecomp(I, fun, ...) behaves as qtdecomp(I, fun) but passes
3989 extra parameters to FUN.
3991 See also: qtgetblk, qtsetblk
3997 # name: <cell-element>
4001 Performs quadtree decomposition.
4005 # name: <cell-element>
4012 # name: <cell-element>
4016 -- Function File: [VALS] = qtgetblk (I,S,DIM)
4017 -- Function File: [VALS,IDX] = qtgetblk (I,S,DIM)
4018 -- Function File: [VALS,R,C] = qtgetblk (I,S,DIM)
4019 Obtain block values from a quadtree decomposition.
4021 [vals]=qtgetblk(I,S,dim) returns a dim-by-dim-by-k array in VALS
4022 which contains the dim-by-dim blocks in the quadtree decomposition
4023 (S, which is returned by qtdecomp) of I. If there are no blocks,
4024 an empty matrix is returned.
4026 [vals,idx]=qtgetblk(I,S,dim) returns VALS as described above. In
4027 addition, it returns IDX, a vector which contains the linear
4028 indices of the upper left corner of each block returned (the same
4029 result as find(full(S)==dim)).
4031 [vals,r,c]=qtgetblk(I,S,dim) returns VALS as described, and two
4032 vectors, R and C, which contain the row and column coordinates of
4033 the blocks returned.
4035 See also: qtdecomp, qtsetblk
4041 # name: <cell-element>
4045 Obtain block values from a quadtree decomposition.
4049 # name: <cell-element>
4056 # name: <cell-element>
4060 -- Function File: J = qtsetblk (I,S,DIM,VALS)
4061 Set block values in a quadtree decomposition.
4063 J=qtsetblk(I,S,dim,vals) sets all the DIM-by-DIM blocks in the
4064 quadtree decomposition (S returned by qtdecomp) of I to DIM-by-DIM
4065 blocks in VALS, which is itself a DIM-by-DIM-by-k array. k is the
4066 number of DIM-by-DIM blocks in the quadtree decomposition.
4068 See also: qtdecomp, qtgetblk
4074 # name: <cell-element>
4078 Set block values in a quadtree decomposition.
4082 # name: <cell-element>
4089 # name: <cell-element>
4093 -- Function File: [RT,XP] = radon(I, THETA)
4094 -- Function File: [RT,XP] = radon(I)
4095 Calculates the 2D-Radon transform of the matrix I at angles given
4096 in THETA. To each element of THETA corresponds a column in RT.
4097 The variable XP represents the x-axis of the rotated coordinate.
4098 If THETA is not defined, then 0:179 is assumed.
4103 # name: <cell-element>
4107 Calculates the 2D-Radon transform of the matrix I at angles given in
4112 # name: <cell-element>
4119 # name: <cell-element>
4123 -- Function File: R = rangefilt (IM)
4124 -- Function File: R = rangefilt (IM, DOMAIN)
4125 -- Function File: R = rangefilt (IM, DOMAIN, PADDING, ...)
4126 Computes the local intensity range in a neighbourhood around each
4129 The intensity range of the pixels of a neighbourhood is computed as
4131 R = max (X) - min (X)
4133 where X is the value of the pixels in the neighbourhood,
4135 The neighbourhood is defined by the DOMAIN binary mask. Elements
4136 of the mask with a non-zero value are considered part of the
4137 neighbourhood. By default a 3 by 3 matrix containing only non-zero
4140 At the border of the image, extrapolation is used. By default
4141 symmetric extrapolation is used, but any method supported by the
4142 `padarray' function can be used.
4144 See also: paddarray, entropyfilt, stdfilt
4150 # name: <cell-element>
4154 Computes the local intensity range in a neighbourhood around each pixel
4159 # name: <cell-element>
4166 # name: <cell-element>
4170 -- Function File: EXIF = readexif(FILENAME, THUMBNAIL)
4171 Read EXIF information from JPEG image data.
4173 The exif tag information are returned in the EXIF data structure.
4174 Integer ratios are expressed as column vector. For example, a
4175 focal number of 2.8 is expressed as FNumber=[28; 10]. Otherwise
4176 all data are returned by the type as specified in the IFD
4179 The filename for the thumbnail image is optional. If given, the
4180 thumbnail jpeg image will be stored to file THUMBNAIL.
4182 Reference: JEITA CP-3451, Exchangeable image file format for
4183 digital still cameras: Exif Version 2.2
4185 See also: imwrite, imfinfo
4191 # name: <cell-element>
4195 Read EXIF information from JPEG image data.
4199 # name: <cell-element>
4206 # name: <cell-element>
4210 -- Function File: PROPS = regionprops (BW)
4211 -- Function File: PROPS = regionprops (BW, PROPERTIES, ...)
4212 Compute object properties in a binary image.
4214 `regionprops' computes various properties of the individual
4215 objects (as identified by `bwlabel') in the binary image BW. The
4216 result is a structure array containing an entry per property per
4219 The following properties can be computed.
4222 The number of pixels in the object.
4226 The Euler number of the object (see `bweuler' for details).
4230 The bounding box of the object. This is represented as a
4231 4-vector where the first two entries are the x and y
4232 coordinates of the upper left corner of the bounding box, and
4233 the two last entries are the width and the height of the box.
4236 The area of the object divided by the area of the bounding
4240 The length of the boundary of the object.
4243 The center coordinate of the object.
4247 The indices of the pixels in the object.
4251 The area of the object including possible holes.
4255 The actual pixel values inside the object. This is only
4256 useful for grey scale images.
4260 A binary image with the same size as the object's bounding
4261 box that contains the object with all holes removed.
4264 An image with the same size as the bounding box that contains
4265 the original pixels.
4269 The maximum intensity inside the object.
4273 The minimum intensity inside the object.
4277 The centroid of the object where pixel values are used as
4282 The mean intensity inside the object.
4286 The pixel values inside the object represented as a vector.
4288 The requested properties can either be specified as several input
4289 arguments or as a cell array of strings. As a short-hand it is
4290 also possible to give the following strings as arguments.
4293 The following properties are computed: "Area", "Centroid" and
4297 All properties are computed.
4299 If no properties are given, basic is assumed.
4301 See also: bwlabel, bwperim, bweuler
4307 # name: <cell-element>
4311 Compute object properties in a binary image.
4315 # name: <cell-element>
4322 # name: <cell-element>
4326 -- Function File: GRAY = rgb2gray (RGB)
4327 Converts an RGB image to a gray scale image, or a color map to a
4330 If the input is an RGB image, the conversion to a gray image is
4331 computed as the mean value of the color channels.
4333 If the input is a color map it is converted into the YIQ space of
4334 ntsc. The luminance value (Y) is taken to create a gray color map.
4340 # name: <cell-element>
4344 Converts an RGB image to a gray scale image, or a color map to a gray
4349 # name: <cell-element>
4356 # name: <cell-element>
4360 -- Function File: B = rgb2ycbcr(A)
4361 Perform colour convertion from RGB to YCbCr on a given image.
4363 The image A must be a NxMx3 image. The conversion The convertion
4364 changes the image from the RGB color model to YCbCr e.g.
4365 imOut = rgb2ycbcr(imIn);
4366 Currently this function only works with `uint8' and will always
4367 return an `uint8' matrix.
4375 # name: <cell-element>
4379 Perform colour convertion from RGB to YCbCr on a given image.
4383 # name: <cell-element>
4390 # name: <cell-element>
4394 -- Function File: rgbplot (MAP)
4395 -- Function File: H = rgbplot (MAP)
4396 Plot a given color map. The matrix MAP must be a M by 3 matrix.
4397 The three columns of the colormap matrix are plotted in red,
4398 green, and blue lines.
4400 If an output is requested, a graphics handle to the plot is
4406 # name: <cell-element>
4410 Plot a given color map.
4414 # name: <cell-element>
4421 # name: <cell-element>
4425 -- Function: FILTERED = rho_filter (PROJ, TYPE, SCALING)
4426 Filters the parallel ray projections in the columns of PROJ,
4427 according to the filter type chosen by TYPE. TYPE can be chosen
4431 * 'Ram-Lak' (default)
4441 If given, SCALING determines the proportion of frequencies below
4442 the nyquist frequency that should be passed by the filter. The
4443 window function is compressed accordingly, to avoid an abrupt
4444 truncation of the frequency response.
4446 -- Function: [FILTERED, FILTER] = rho_filter (...)
4447 This form also returns the frequency response of the filter in the
4451 Performs rho filtering on the parallel ray projections provided.
4453 Rho filtering is performed as part of the filtered back-projection
4454 method of CT image reconstruction. It is the filtered part of the name.
4455 The simplest rho filter is the Ramachadran-Lakshminarayanan (Ram-Lak),
4456 which is simply |rho|, where rho is the radial component of spatial
4457 frequency. However, this can cause unwanted amplification of noise,
4458 which is what the other types attempt to minimise, by introducing
4459 roll-off into the response. The Hann and Hamming filters multiply the
4460 standard response by a Hann or Hamming window, respectively. The
4461 cosine filter is the standard response multiplied by a cosine shape,
4462 and the Shepp-Logan filter multiplies the response with a sinc shape.
4463 The 'none' filter performs no filtering, and is included for
4464 completeness and to enable incorporating this function easily into
4465 scripts or functions that may offer the ability to choose to apply no
4468 This function is designed to be used by the function `iradon', but
4469 has been exposed to facilitate custom inverse radon transforms and to
4470 more clearly break down the process for educational purposes. The
4472 filtered = rho_filter (proj);
4473 reconstruction = iradon (filtered, 1, 'linear', 'none');
4474 are exactly equivalent to
4475 reconstruction = iradon (proj, 1, 'linear', 'Ram-Lak');
4479 projections = radon (P);
4480 filtered_projections = rho_filter (projections, 'Hamming');
4481 reconstruction = iradon (filtered_projections, 1, 'linear', 'none');
4482 figure, imshow (reconstruction, [])
4487 # name: <cell-element>
4491 Filters the parallel ray projections in the columns of PROJ, according
4496 # name: <cell-element>
4503 # name: <cell-element>
4507 -- Function File: BW = roicolor (A,LOW,HIGH)
4508 -- Function File: BW = roicolor (A,V)
4509 Select a Region Of Interest of an image based on color.
4511 BW = roicolor(A,low,high) selects a region of interest (ROI) of an
4512 image A returning a black and white image in a logical array (1 for
4513 pixels inside ROI and 0 outside ROI), which is formed by all pixels
4514 whose values lie within the colormap range specified by [LOW HIGH].
4516 BW = roicolor(A,v) selects a region of interest (ROI) formed by all
4517 pixels that match values in V.
4522 # name: <cell-element>
4526 Select a Region Of Interest of an image based on color.
4530 # name: <cell-element>
4537 # name: <cell-element>
4541 -- Function File: S = std2 (I)
4542 Returns the standard deviation for a 2d real type matrix. Uses
4545 See also: mean2, std
4551 # name: <cell-element>
4555 Returns the standard deviation for a 2d real type matrix.
4559 # name: <cell-element>
4566 # name: <cell-element>
4570 -- Function File: S = stdfilt (IM)
4571 -- Function File: S = stdfilt (IM, DOMAIN)
4572 -- Function File: S = stdfilt (IM, DOMAIN, PADDING, ...)
4573 Computes the local standard deviation in a neighbourhood around
4574 each pixel in an image.
4576 The standard deviation of the pixels of a neighbourhood is
4579 S = sqrt ((sum (X - MU).^2)/(N-1))
4581 where MU is the mean value of the pixels in the neighbourhood, N
4582 is the number of pixels in the neighbourhood. So, an unbiased
4585 The neighbourhood is defined by the DOMAIN binary mask. Elements
4586 of the mask with a non-zero value are considered part of the
4587 neighbourhood. By default a 3 by 3 matrix containing only non-zero
4590 At the border of the image, extrapolation is used. By default
4591 symmetric extrapolation is used, but any method supported by the
4592 `padarray' function can be used. Since extrapolation is used, one
4593 can expect a lower deviation near the image border.
4595 See also: std2, paddarray, entropyfilt
4601 # name: <cell-element>
4605 Computes the local standard deviation in a neighbourhood around each
4610 # name: <cell-element>
4617 # name: <cell-element>
4621 -- Function File: LOW_HIGH = stretchlim (I,TOL)
4622 -- Function File: LOW_HIGH = stretchlim (I)
4623 -- Function File: LOW_HIGH = stretchlim (RGB,TOL)
4624 -- Function File: LOW_HIGH = stretchlim (RGB)
4625 Finds limits to contrast stretch an image
4627 `LOW_HIGH=stretchlim(I,TOL)' returns a vector LOW_HIGH which
4628 contains a pair of intensities which can be used in `imadjust' to
4629 stretch the contrast of an image, first of them will be lower
4630 value (`imadjust' would assign 0 to it) and second is the upper
4631 bound. TOL specifies the fraction of the image to saturate at
4632 lower and upper limits. It can be a vector of length 2:
4633 `[LOW_FRACT, HIGH_FRACT]', or it can be a scalar, in that case
4634 `[LOW_FRACT, HIGH_FRACT]=[TOL, 1-TOL]'.
4636 TOL can't be larger than 0.50 and for TOL=0 then
4637 `LOW_HIGH=[min(I(:)), max(I(:))]'.
4639 `LOW_HIGH=stretchlim(I)' behaves as described but defaults TOL to
4642 `LOW_HIGH=stretchlim(RGB,TOL)' returns a 2-by-3 matrix in LOW_HIGH
4643 of lower and upper values to saturate for each plane of the RGB
4644 image in M-by-N-by-3 array RGB. TOL is a vector or a scalar, as
4645 described above, and the same fractions are applied for each plane.
4647 `LOW_HIGH=stretchlim(RGB)' uses `[0.01, 0.99]' as default value
4652 Values in LOW_HIGH are of type double and comprised between 0 and
4653 1 regardless class of input image.
4655 *Compatibility notes:*
4657 * int* and uint* types are still not implemented (waiting for
4658 support in Octave 2.1.58).
4660 * This function tries to find limits that are nearer to saturate
4661 requested interval. So, for instance, if you requested a 5%
4662 and it has to choose between discarding a 1% and a 7%, it
4663 will choose the later despite being more than requested. This
4664 should be test against MATLAB behaviour.
4672 # name: <cell-element>
4676 Finds limits to contrast stretch an image
4681 # name: <cell-element>
4688 # name: <cell-element>
4692 -- Function File: [ VALUE, OFFSET] = tiff_tag_read (FILE, TAG, IFD)
4693 Reads the values of TIFF file tags.
4695 FILE is a TIFF file and TAG is the tag number to read. If IFD is
4696 given, only the tag value from that IFD (Image File Directory)
4697 will be read. By default, reads only the first IFD.
4699 VALUE is the read value from TAG. OFFSET will be `1' if VALUE is a
4702 See also: imread, imfinfo, readexif
4708 # name: <cell-element>
4712 Reads the values of TIFF file tags.
4716 # name: <cell-element>
4723 # name: <cell-element>
4727 -- Function File: B = uintlut (A,LUT)
4728 Computes matrix B by using A as an index to lookup table LUT.
4730 B = uintlut(A, LUT) calculates a matrix B by using LUT as a lookup
4731 table indexed by values in A.
4733 B class is the same as LUT.
4738 # name: <cell-element>
4742 Computes matrix B by using A as an index to lookup table LUT.