Cody

# Problem 42616. Detect circles in images

Solution 773096

Submitted on 7 Nov 2015
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
%% I = imread(fullfile(matlabroot,'toolbox','images','imdata','circles.png')); [centers,radii] = detectcircles(I,[18 20],13); c = [119 222; 185 218; 124 116; 37 37; 178 184; 93 167; 37 72; 71 38; 93 132; 122 186; 97 96; 71 74; 151 204]; r = 19*ones(13,1); d1 = squeeze(sqrt(sum(bsxfun(@minus,centers,permute(c,str2num('3 2 1'))).^2,2))); d2 = squeeze(sqrt(sum(bsxfun(@minus,radii,permute(r,str2num('3 2 1'))).^2,2))); mask = d1<5 & d2<5; Re = mean(any(mask)); Pr = sum(any(mask))/size(mask,1); assert(Pr>=0.5) assert(Re>=0.75)

118 118 117 118 117 184 184 117 184 183 70 70 70 221 221 221 220 221 217 217 220 216 217 36 37 36 19 18 19 19 18 18 19 19 19 19 19 19 18

Assertion failed.

2   Fail
%% I = imread(fullfile(matlabroot,'toolbox','images','imdata','circlesBrightDark.png')); [centers,radii] = detectcircles(I,[32 64],6); c = [75 250; 100 100; 250 400; 300 120; 450 240; 330 370]; r = [35; 50; 60; 40; 50; 55]; d1 = squeeze(sqrt(sum(bsxfun(@minus,centers,permute(c,str2num('3 2 1'))).^2,2))); d2 = squeeze(sqrt(sum(bsxfun(@minus,radii,permute(r,str2num('3 2 1'))).^2,2))); mask = d1<5 & d2<5; Re = mean(any(mask)); Pr = sum(any(mask))/size(mask,1); assert(Pr>=0.5) assert(Re>=0.75)

298 298 298 297 298 298 118 118 118 118 117 119 40 39 41 40 40 40

Assertion failed.

3   Fail
%% I = imread(fullfile(matlabroot,'toolbox','images','imdata','coins.png')); [centers,radii] = detectcircles(I,[24 30],10); c = [236 174; 149 35; 56 50; 266 103; 217 71; 120 209; 110 85; 175 120; 96 146; 37 107]; r = [25; 29; 25; 24; 29; 29; 24; 29; 29; 29]; d1 = squeeze(sqrt(sum(bsxfun(@minus,centers,permute(c,str2num('3 2 1'))).^2,2))); d2 = squeeze(sqrt(sum(bsxfun(@minus,radii,permute(r,str2num('3 2 1'))).^2,2))); mask = d1<5 & d2<5; Re = mean(any(mask)); Pr = sum(any(mask))/size(mask,1); assert(Pr>=0.5) assert(Re>=0.75)

147 147 146 118 147 215 146 173 94 173 34 33 33 207 33 70 32 119 145 118 30 29 29 30 30 30 29 30 30 29

Assertion failed.

4   Fail
%% I = imread(fullfile(matlabroot,'toolbox','images','imdata','coloredChips.png')); [centers,radii] = detectcircles(I,[20 28],26); c = [83 177; 304 336; 420 88; 434 165; 244 166; 327 297; 273 53; 130 44; 271 281; 408 265; 312 192; 420 346; 146 199; 228 232; 329 135; 175 297; 366 224; 150 258; 217 107; 345 119; 445 68; 372 293; 150 342; 251 8; 259 217; 198 107]; r = [23; 24; 23; 23; 23; 23; 23; 23; 23; 23; 23; 24; 23; 23; 23; 24; 23; 24; 23; 23; 23; 24; 25; 23; 23; 25]; d1 = squeeze(sqrt(sum(bsxfun(@minus,centers,permute(c,str2num('3 2 1'))).^2,2))); d2 = squeeze(sqrt(sum(bsxfun(@minus,radii,permute(r,str2num('3 2 1'))).^2,2))); mask = d1<5 & d2<5; Re = mean(any(mask)); Pr = sum(any(mask))/size(mask,1); assert(Pr>=0.5) assert(Re>=0.75)

Columns 1 through 16 127 241 310 310 127 127 309 127 309 270 310 128 406 241 241 310 42 164 191 191 42 42 191 41 190 51 190 42 263 165 164 190 Columns 17 through 26 270 270 240 309 127 128 196 309 270 406 52 52 164 191 41 42 105 190 51 263 Columns 1 through 16 23 23 23 22 22 24 23 23 23 22 23 23 23 23 22 22 Columns 17 through 26 22 23 23 22 22 22 22 22 23 22

Assertion failed.

5   Fail
%% I = imread(fullfile(matlabroot,'toolbox','images','imdata','eight.tif')); [centers,radii] = detectcircles(I,[35 40],4); c = [198 189; 247 72; 62 141; 124 58]; r = [37; 37; 38; 37]; d1 = squeeze(sqrt(sum(bsxfun(@minus,centers,permute(c,str2num('3 2 1'))).^2,2))); d2 = squeeze(sqrt(sum(bsxfun(@minus,radii,permute(r,str2num('3 2 1'))).^2,2))); mask = d1<5 & d2<5; Re = mean(any(mask)); Pr = sum(any(mask))/size(mask,1); assert(Pr>=0.5) assert(Re>=0.75)

59 60 59 196 139 139 139 186 39 39 38 39

Assertion failed.

6   Pass

252 285 206

7   Fail
%% I = imread(fullfile(matlabroot,'toolbox','images','imdata','pillsetc.png')); [centers,radii] = detectcircles(I,[15 55],4); c = [103 240; 252 326; 119 130; 319 84]; r = [17; 17; 50; 37]; d1 = squeeze(sqrt(sum(bsxfun(@minus,centers,permute(c,str2num('3 2 1'))).^2,2))); d2 = squeeze(sqrt(sum(bsxfun(@minus,radii,permute(r,str2num('3 2 1'))).^2,2))); mask = d1<5 & d2<5; Re = mean(any(mask)); Pr = sum(any(mask))/size(mask,1); assert(Pr>=0.5) assert(Re>=0.75)

249 250 101 101 324 324 238 237 17 17 17 17

Assertion failed.

8   Pass

234 171 80

9   Pass