This is a static copy of a profile reportHome
strel>MakeDiskStrel (202 calls, 9.703 sec)
Generated 05-Nov-2014 07:53:19 using cpu time.
subfunction in file /usr1/opt/matlab/7.13/toolbox/images/images/strel.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
965 | se.decomposition(q) = strel('p... | 606 | 2.614 s | 26.9% |  |
987 | se.decomposition(end+1) = stre... | 202 | 2.233 s | 23.0% |  |
986 | se.decomposition(end+1) = stre... | 202 | 1.943 s | 20.0% |  |
972 | nhood = imdilate(1, se.decompo... | 202 | 1.252 s | 12.9% |  |
991 | nhood = imdilate(nhood, se.dec... | 202 | 0.961 s | 9.9% |  |
All other lines | | | 0.701 s | 7.2% |  |
Totals | | | 9.703 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
strel>strel.strel | subfunction | 1414 | 7.280 s | 75.0% |  |
imdilate | function | 404 | 2.193 s | 22.6% |  |
Self time (built-ins, overhead, etc.) | | | 0.230 s | 2.4% |  |
Totals | | | 9.703 s | 100% | |
Code Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 109 |
Non-code lines (comments, blank lines) | 63 |
Code lines (lines that can run) | 46 |
Code lines that did run | 35 |
Code lines that did not run | 11 |
Coverage (did run/can run) | 76.09 % |
Function listing
time calls line
891 function se = MakeDiskStrel(r,n)
892
202 893 if (r < 3)
894 % Radius is too small to use decomposition, so force n=0.
895 n = 0;
896 end
897
0.13 202 898 se = strel;
899
0.01 202 900 if (n == 0)
901 % Use simple Euclidean distance formula to find the disk neighborhood. No
902 % decomposition.
903 [xx,yy] = meshgrid(-r:r);
904 nhood = xx.^2 + yy.^2 <= r^2;
905
0.01 202 906 else
907 % Reference for radial decomposition of disks: Rolf Adams, "Radial
908 % Decomposition of Discs and Spheres," CVGIP: Graphical Models and
909 % Image Processing, vol. 55, no. 5, September 1993, pp. 325-332.
910 %
911 % The specific decomposition technique used here is radial
912 % decomposition using periodic lines. The reference is: Ronald
913 % Jones and Pierre Soille, "Periodic lines: Definition, cascades, and
914 % application to granulometries," Pattern Recognition Letters,
915 % vol. 17, 1996, pp. 1057-1063.
916
917 % Determine the set of "basis" vectors to be used for the
918 % decomposition. The rows of v will be used as offset vectors for
919 % periodic line strels.
202 920 switch n
202 921 case 4
202 922 v = [ 1 0
923 1 1
924 0 1
925 -1 1];
926
927 case 6
928 v = [ 1 0
929 1 2
930 2 1
931 0 1
932 -1 2
933 -2 1];
934
935 case 8
936 v = [ 1 0
937 2 1
938 1 1
939 1 2
940 0 1
941 -1 2
942 -1 1
943 -2 1];
944
945 otherwise
946 % This error should have been caught already in ParseInputs.
947 error(message('images:getheight:invalidN'));
948 end
949
950 % Determine k, which is the desired radial extent of the periodic
951 % line strels. For the origin of this formula, see the second
952 % paragraph on page 328 of the Rolf Adams paper.
202 953 theta = pi/(2*n);
202 954 k = 2*r/(cot(theta) + 1/sin(theta));
955
956 % For each periodic line strel, determine the repetition parameter,
957 % rp. The use of floor() in the computation means that the resulting
958 % strel will be a little small, but we will compensate for this
959 % below.
0.01 202 960 for q = 1:n
0.01 808 961 rp = floor(k / norm(v(q,:)));
808 962 if (q == 1)
0.49 202 963 se.decomposition = strel('periodicline', rp, v(q,:));
606 964 else
2.61 606 965 se.decomposition(q) = strel('periodicline', rp, v(q,:));
0.02 606 966 end
808 967 end
968
969 % Now dilate the strels in the decomposition together to see how
970 % close we came to the desired disk radius.
971
1.25 202 972 nhood = imdilate(1, se.decomposition, 'full');
202 973 nhood = nhood > 0;
202 974 [rd,cd] = find(nhood); %#ok<NASGU>
202 975 M = size(nhood,1);
202 976 rd = rd - floor((M+1)/2);
202 977 max_horiz_radius = max(rd(:));
202 978 radial_difference = r - max_horiz_radius;
979
980 % Now we are going to add additional vertical and horizontal line
981 % strels to compensate for the fact that the strel resulting from the
982 % above decomposition tends to be smaller than the desired size.
202 983 len = 2*(radial_difference-1) + 1;
202 984 if (len >= 3)
985 % Add horizontal and vertical line strels.
1.94 202 986 se.decomposition(end+1) = strel('line',len,0);
2.23 202 987 se.decomposition(end+1) = strel('line',len,90);
988
989 % Update the computed neighborhood to reflect the additional strels in
990 % the decomposition.
0.96 202 991 nhood = imdilate(nhood, se.decomposition(end-1:end), 'full');
202 992 nhood = nhood > 0;
202 993 end
202 994 end
995
0.02 202 996 se.nhood = nhood;
202 997 se.height = zeros(size(nhood));
998
202 999 end
Other subfunctions in this file are not included in this listing.