0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 function resultMap = drawDisk(bgMap,center,radius,value)
0019
0020 if isstruct(bgMap)
0021 bg = bgMap.data;
0022 else
0023 bg = bgMap;
0024 end
0025
0026
0027 [xx,yy] = meshgrid(-radius:radius);
0028 disk = (xx.^2 + yy.^2 <= radius^2);
0029
0030
0031 tb = center(1) - radius; td = 1;
0032 if (tb < 1)
0033 td = 2 - tb;
0034 tb = 1;
0035 end
0036
0037
0038 bb = center(1) + radius; bd = size(disk,2);
0039 if (bb > size(bg,1))
0040 bd = bd - (bb - size(bg,1));
0041 bb = size(bg,1);
0042 end
0043
0044
0045 lb = center(2) - radius; ld = 1;
0046 if (lb < 1)
0047 ld = 2 - lb;
0048 lb = 1;
0049 end
0050
0051
0052 rb = center(2) + radius; rd = size(disk,2);
0053 if (rb > size(bg,2))
0054 rd = rd - (rb - size(bg,2));
0055 rb = size(bg,2);
0056 end
0057
0058
0059 result = bg;
0060 cutRes = result(tb:bb,lb:rb);
0061 cutDisk = disk(td:bd,ld:rd);
0062 cutRes(cutDisk) = value;
0063 result(tb:bb,lb:rb) = cutRes;
0064
0065 if isstruct(bgMap)
0066 resultMap = bgMap;
0067 resultMap.data = result;
0068 resultMap.label = [resultMap.label ' disk'];
0069 else
0070 resultMap = result;
0071 end