| cristy | 6e0b3bc | 2014-10-19 17:51:42 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % V V IIIII SSSSS IIIII OOO N N % |
| 7 | % V V I SS I O O NN N % |
| 8 | % V V I SSS I O O N N N % |
| 9 | % V V I SS I O O N NN % |
| 10 | % V IIIII SSSSS IIIII OOO N N % |
| 11 | % % |
| 12 | % % |
| 13 | % MagickCore Computer Vision Methods % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % Cristy % |
| 17 | % September 2014 % |
| 18 | % % |
| 19 | % % |
| 20 | % Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization % |
| 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % |
| 37 | */ |
| 38 | |
| 39 | #include "MagickCore/studio.h" |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 40 | #include "MagickCore/artifact.h" |
| cristy | 6e0b3bc | 2014-10-19 17:51:42 +0000 | [diff] [blame] | 41 | #include "MagickCore/blob.h" |
| 42 | #include "MagickCore/cache-view.h" |
| 43 | #include "MagickCore/color.h" |
| 44 | #include "MagickCore/color-private.h" |
| 45 | #include "MagickCore/colorspace.h" |
| 46 | #include "MagickCore/constitute.h" |
| 47 | #include "MagickCore/decorate.h" |
| 48 | #include "MagickCore/distort.h" |
| 49 | #include "MagickCore/draw.h" |
| 50 | #include "MagickCore/enhance.h" |
| 51 | #include "MagickCore/exception.h" |
| 52 | #include "MagickCore/exception-private.h" |
| 53 | #include "MagickCore/effect.h" |
| 54 | #include "MagickCore/gem.h" |
| 55 | #include "MagickCore/geometry.h" |
| 56 | #include "MagickCore/image-private.h" |
| 57 | #include "MagickCore/list.h" |
| 58 | #include "MagickCore/log.h" |
| 59 | #include "MagickCore/matrix.h" |
| 60 | #include "MagickCore/memory_.h" |
| 61 | #include "MagickCore/memory-private.h" |
| 62 | #include "MagickCore/monitor.h" |
| 63 | #include "MagickCore/monitor-private.h" |
| 64 | #include "MagickCore/montage.h" |
| 65 | #include "MagickCore/morphology.h" |
| 66 | #include "MagickCore/morphology-private.h" |
| 67 | #include "MagickCore/opencl-private.h" |
| 68 | #include "MagickCore/paint.h" |
| 69 | #include "MagickCore/pixel-accessor.h" |
| 70 | #include "MagickCore/pixel-private.h" |
| 71 | #include "MagickCore/property.h" |
| 72 | #include "MagickCore/quantum.h" |
| 73 | #include "MagickCore/resource_.h" |
| 74 | #include "MagickCore/signature-private.h" |
| 75 | #include "MagickCore/string_.h" |
| 76 | #include "MagickCore/thread-private.h" |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 77 | #include "MagickCore/token.h" |
| cristy | 6e0b3bc | 2014-10-19 17:51:42 +0000 | [diff] [blame] | 78 | #include "MagickCore/vision.h" |
| 79 | |
| 80 | /* |
| 81 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 82 | % % |
| 83 | % % |
| 84 | % % |
| 85 | % C o n n e c t e d C o m p o n e n t s I m a g e % |
| 86 | % % |
| 87 | % % |
| 88 | % % |
| 89 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 90 | % |
| 91 | % ConnectedComponentsImage() returns the connected-components of the image |
| 92 | % uniquely labeled. Choose from 4 or 8-way connectivity. |
| 93 | % |
| 94 | % The format of the ConnectedComponentsImage method is: |
| 95 | % |
| 96 | % Image *ConnectedComponentsImage(const Image *image, |
| 97 | % const size_t connectivity,ExceptionInfo *exception) |
| 98 | % |
| 99 | % A description of each parameter follows: |
| 100 | % |
| 101 | % o image: the image. |
| 102 | % |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 103 | % o connectivity: how many neighbors to visit, choose from 4 or 8. |
| cristy | 6e0b3bc | 2014-10-19 17:51:42 +0000 | [diff] [blame] | 104 | % |
| 105 | % o exception: return any errors or warnings in this structure. |
| 106 | % |
| 107 | */ |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 108 | |
| 109 | typedef struct _CCObject |
| 110 | { |
| 111 | ssize_t |
| 112 | id; |
| 113 | |
| 114 | RectangleInfo |
| 115 | bounding_box; |
| 116 | |
| 117 | PointInfo |
| 118 | centroid; |
| 119 | |
| 120 | ssize_t |
| 121 | area; |
| 122 | } CCObject; |
| 123 | |
| 124 | static int CCObjectCompare(const void *x,const void *y) |
| 125 | { |
| 126 | CCObject |
| 127 | *p, |
| 128 | *q; |
| 129 | |
| 130 | p=(CCObject *) x; |
| 131 | q=(CCObject *) y; |
| 132 | return((int) (q->area-(ssize_t) p->area)); |
| 133 | } |
| 134 | |
| 135 | static MagickBooleanType ConnectedComponentsStatistics(const Image *image, |
| 136 | const size_t number_objects,ExceptionInfo *exception) |
| 137 | { |
| 138 | CacheView |
| 139 | *image_view; |
| 140 | |
| 141 | CCObject |
| 142 | *object; |
| 143 | |
| 144 | MagickBooleanType |
| 145 | status; |
| 146 | |
| 147 | register ssize_t |
| 148 | i; |
| 149 | |
| 150 | ssize_t |
| 151 | y; |
| 152 | |
| 153 | object=(CCObject *) AcquireQuantumMemory(number_objects,sizeof(*object)); |
| 154 | if (object == (CCObject *) NULL) |
| 155 | { |
| 156 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 157 | ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); |
| 158 | return(MagickFalse); |
| 159 | } |
| 160 | (void) ResetMagickMemory(object,0,number_objects*sizeof(*object)); |
| 161 | for (i=0; i < (ssize_t) number_objects; i++) |
| 162 | { |
| 163 | object[i].id=i; |
| 164 | object[i].bounding_box.x=(ssize_t) image->columns; |
| 165 | object[i].bounding_box.y=(ssize_t) image->rows; |
| 166 | } |
| 167 | (void) fprintf(stdout,"Objects (id: bounding-box centroid area):\n"); |
| 168 | status=MagickTrue; |
| 169 | image_view=AcquireVirtualCacheView(image,exception); |
| 170 | for (y=0; y < (ssize_t) image->rows; y++) |
| 171 | { |
| 172 | register const Quantum |
| 173 | *restrict p; |
| 174 | |
| 175 | register ssize_t |
| 176 | x; |
| 177 | |
| 178 | if (status == MagickFalse) |
| 179 | continue; |
| 180 | p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception); |
| 181 | if (p == (const Quantum *) NULL) |
| 182 | { |
| 183 | status=MagickFalse; |
| 184 | continue; |
| 185 | } |
| 186 | for (x=0; x < (ssize_t) image->columns; x++) |
| 187 | { |
| 188 | i=(ssize_t) *p; |
| 189 | if (x < object[i].bounding_box.x) |
| 190 | object[i].bounding_box.x=x; |
| 191 | if (x > (ssize_t) object[i].bounding_box.width) |
| 192 | object[i].bounding_box.width=(size_t) x; |
| 193 | if (y < object[i].bounding_box.y) |
| 194 | object[i].bounding_box.y=y; |
| 195 | if (y > (ssize_t) object[i].bounding_box.height) |
| 196 | object[i].bounding_box.height=(size_t) y; |
| 197 | object[i].area++; |
| 198 | p+=GetPixelChannels(image); |
| 199 | } |
| 200 | } |
| 201 | for (i=0; i < (ssize_t) number_objects; i++) |
| 202 | { |
| 203 | object[i].bounding_box.width-=(object[i].bounding_box.x-1); |
| 204 | object[i].bounding_box.height-=(object[i].bounding_box.y-1); |
| 205 | } |
| 206 | for (i=0; i < (ssize_t) number_objects; i++) |
| 207 | { |
| 208 | for (y=0; y < (ssize_t) object[i].bounding_box.height; y++) |
| 209 | { |
| 210 | register const Quantum |
| 211 | *restrict p; |
| 212 | |
| 213 | register ssize_t |
| 214 | x; |
| 215 | |
| 216 | if (status == MagickFalse) |
| 217 | continue; |
| 218 | p=GetCacheViewVirtualPixels(image_view,object[i].bounding_box.x, |
| 219 | object[i].bounding_box.y+y,object[i].bounding_box.width,1,exception); |
| 220 | if (p == (const Quantum *) NULL) |
| 221 | { |
| 222 | status=MagickFalse; |
| 223 | continue; |
| 224 | } |
| 225 | for (x=0; x < (ssize_t) object[i].bounding_box.width; x++) |
| 226 | { |
| 227 | if ((ssize_t) *p == i) |
| 228 | { |
| 229 | object[i].centroid.x+=x; |
| 230 | object[i].centroid.y+=y; |
| 231 | } |
| 232 | p++; |
| 233 | } |
| 234 | } |
| 235 | object[i].centroid.x=(double) object[i].bounding_box.x+object[i].centroid.x/ |
| 236 | object[i].area; |
| 237 | object[i].centroid.y=(double) object[i].bounding_box.y+object[i].centroid.y/ |
| 238 | object[i].area; |
| 239 | } |
| 240 | image_view=DestroyCacheView(image_view); |
| 241 | qsort((void *) object,number_objects,sizeof(*object),CCObjectCompare); |
| 242 | for (i=0; i < (ssize_t) number_objects; i++) |
| 243 | { |
| 244 | if (status == MagickFalse) |
| 245 | break; |
| 246 | (void) fprintf(stdout, |
| 247 | " %.20g: %.20gx%.20g%+.20g%+.20g %+.1f,%+.1f %.20g\n",(double) |
| 248 | object[i].id,(double) object[i].bounding_box.width,(double) |
| 249 | object[i].bounding_box.height,(double) object[i].bounding_box.x, |
| 250 | (double) object[i].bounding_box.y,object[i].centroid.x, |
| 251 | object[i].centroid.y,(double) object[i].area); |
| 252 | } |
| 253 | object=(CCObject *) RelinquishMagickMemory(object); |
| 254 | return(status); |
| 255 | } |
| 256 | |
| cristy | 6e0b3bc | 2014-10-19 17:51:42 +0000 | [diff] [blame] | 257 | MagickExport Image *ConnectedComponentsImage(const Image *image, |
| 258 | const size_t connectivity,ExceptionInfo *exception) |
| 259 | { |
| 260 | #define ConnectedComponentsImageTag "ConnectedComponents/Image" |
| 261 | |
| 262 | CacheView |
| 263 | *image_view, |
| 264 | *component_view; |
| 265 | |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 266 | const char |
| 267 | *artifact; |
| 268 | |
| cristy | 6e0b3bc | 2014-10-19 17:51:42 +0000 | [diff] [blame] | 269 | Image |
| 270 | *component_image; |
| 271 | |
| 272 | MagickBooleanType |
| 273 | status; |
| 274 | |
| 275 | MagickOffsetType |
| 276 | progress; |
| 277 | |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 278 | MatrixInfo |
| 279 | *equivalences; |
| 280 | |
| 281 | size_t |
| 282 | size; |
| 283 | |
| cristy | 6e0b3bc | 2014-10-19 17:51:42 +0000 | [diff] [blame] | 284 | ssize_t |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 285 | n, |
| cristy | 6e0b3bc | 2014-10-19 17:51:42 +0000 | [diff] [blame] | 286 | y; |
| 287 | |
| 288 | /* |
| 289 | Initialize connected components image attributes. |
| 290 | */ |
| 291 | assert(image != (Image *) NULL); |
| 292 | assert(image->signature == MagickSignature); |
| 293 | if (image->debug != MagickFalse) |
| 294 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 295 | assert(exception != (ExceptionInfo *) NULL); |
| 296 | assert(exception->signature == MagickSignature); |
| 297 | component_image=CloneImage(image,image->columns,image->rows,MagickTrue, |
| 298 | exception); |
| 299 | if (component_image == (Image *) NULL) |
| 300 | return((Image *) NULL); |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 301 | component_image->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 302 | component_image->colorspace=GRAYColorspace; |
| cristy | 6e0b3bc | 2014-10-19 17:51:42 +0000 | [diff] [blame] | 303 | if (SetImageStorageClass(component_image,DirectClass,exception) == MagickFalse) |
| 304 | { |
| 305 | component_image=DestroyImage(component_image); |
| 306 | return((Image *) NULL); |
| 307 | } |
| 308 | /* |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 309 | Initialize connected components equivalences. |
| 310 | */ |
| 311 | size=image->columns*image->rows; |
| 312 | if (image->columns != (size/image->rows)) |
| 313 | { |
| 314 | component_image=DestroyImage(component_image); |
| 315 | ThrowImageException(ResourceLimitError,"MemoryAllocationFailed"); |
| 316 | } |
| 317 | equivalences=AcquireMatrixInfo(size,1,sizeof(ssize_t),exception); |
| 318 | if (equivalences == (MatrixInfo *) NULL) |
| 319 | { |
| 320 | component_image=DestroyImage(component_image); |
| 321 | return((Image *) NULL); |
| 322 | } |
| 323 | for (n=0; n < (ssize_t) (image->columns*image->rows); n++) |
| 324 | status=SetMatrixElement(equivalences,n,0,&n); |
| 325 | /* |
| 326 | Find connected components. |
| cristy | 6e0b3bc | 2014-10-19 17:51:42 +0000 | [diff] [blame] | 327 | */ |
| 328 | status=MagickTrue; |
| 329 | progress=0; |
| 330 | image_view=AcquireVirtualCacheView(image,exception); |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 331 | for (n=0; n < (ssize_t) (connectivity > 4 ? 4 : 2); n++) |
| 332 | { |
| 333 | ssize_t |
| 334 | connect4[2][2] = { { -1, 0 }, { 0, -1 } }, |
| 335 | connect8[4][2] = { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 } }, |
| 336 | dx, |
| 337 | dy; |
| 338 | |
| 339 | if (status == MagickFalse) |
| 340 | continue; |
| 341 | dy=connectivity > 4 ? connect8[n][0] : connect4[n][0]; |
| 342 | dx=connectivity > 4 ? connect8[n][1] : connect4[n][1]; |
| 343 | for (y=0; y < (ssize_t) image->rows; y++) |
| 344 | { |
| 345 | register const Quantum |
| 346 | *restrict p; |
| 347 | |
| 348 | register ssize_t |
| 349 | x; |
| 350 | |
| 351 | if (status == MagickFalse) |
| 352 | continue; |
| 353 | p=GetCacheViewVirtualPixels(image_view,0,y-1,image->columns,3,exception); |
| 354 | if (p == (const Quantum *) NULL) |
| 355 | { |
| 356 | status=MagickFalse; |
| 357 | continue; |
| 358 | } |
| cristy | 00f8eb4 | 2014-10-25 13:46:10 +0000 | [diff] [blame] | 359 | p+=image->columns*GetPixelChannels(image); |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 360 | for (x=0; x < (ssize_t) image->columns; x++) |
| 361 | { |
| 362 | PixelInfo |
| 363 | pixel, |
| 364 | target; |
| 365 | |
| 366 | ssize_t |
| 367 | neighbor_offset, |
| 368 | object, |
| cristy | 00f8eb4 | 2014-10-25 13:46:10 +0000 | [diff] [blame] | 369 | offset, |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 370 | ox, |
| 371 | oy, |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 372 | root; |
| 373 | |
| 374 | /* |
| 375 | Is neighbor an authentic pixel and a different color than the pixel? |
| 376 | */ |
| cristy | 00f8eb4 | 2014-10-25 13:46:10 +0000 | [diff] [blame] | 377 | GetPixelInfoPixel(image,p,&pixel); |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 378 | neighbor_offset=dy*(image->columns*GetPixelChannels(image))+dx* |
| 379 | GetPixelChannels(image); |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 380 | GetPixelInfoPixel(image,p+neighbor_offset,&target); |
| 381 | if (((x+dx) < 0) || ((x+dx) >= (ssize_t) image->columns) || |
| 382 | ((y+dy) < 0) || ((y+dy) >= (ssize_t) image->rows) || |
| 383 | (IsFuzzyEquivalencePixelInfo(&pixel,&target) == MagickFalse)) |
| 384 | { |
| 385 | p+=GetPixelChannels(image); |
| 386 | continue; |
| 387 | } |
| 388 | /* |
| 389 | Resolve this equivalence. |
| 390 | */ |
| cristy | 00f8eb4 | 2014-10-25 13:46:10 +0000 | [diff] [blame] | 391 | offset=y*image->columns+x; |
| 392 | neighbor_offset=dy*image->columns+dx; |
| 393 | ox=offset; |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 394 | status=GetMatrixElement(equivalences,ox,0,&object); |
| 395 | while (object != ox) { |
| 396 | ox=object; |
| 397 | status=GetMatrixElement(equivalences,ox,0,&object); |
| 398 | } |
| cristy | 00f8eb4 | 2014-10-25 13:46:10 +0000 | [diff] [blame] | 399 | oy=offset+neighbor_offset; |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 400 | status=GetMatrixElement(equivalences,oy,0,&object); |
| 401 | while (object != oy) { |
| 402 | oy=object; |
| 403 | status=GetMatrixElement(equivalences,oy,0,&object); |
| 404 | } |
| 405 | if (ox < oy) |
| 406 | { |
| 407 | status=SetMatrixElement(equivalences,oy,0,&ox); |
| 408 | root=ox; |
| 409 | } |
| 410 | else |
| 411 | { |
| 412 | status=SetMatrixElement(equivalences,ox,0,&oy); |
| 413 | root=oy; |
| 414 | } |
| cristy | 00f8eb4 | 2014-10-25 13:46:10 +0000 | [diff] [blame] | 415 | ox=offset; |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 416 | status=GetMatrixElement(equivalences,ox,0,&object); |
| 417 | while (object != root) { |
| 418 | status=GetMatrixElement(equivalences,ox,0,&object); |
| 419 | status=SetMatrixElement(equivalences,ox,0,&root); |
| 420 | } |
| cristy | 00f8eb4 | 2014-10-25 13:46:10 +0000 | [diff] [blame] | 421 | oy=offset+neighbor_offset; |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 422 | status=GetMatrixElement(equivalences,oy,0,&object); |
| 423 | while (object != root) { |
| 424 | status=GetMatrixElement(equivalences,oy,0,&object); |
| 425 | status=SetMatrixElement(equivalences,oy,0,&root); |
| 426 | } |
| 427 | status=SetMatrixElement(equivalences,y*image->columns+x,0,&root); |
| 428 | p+=GetPixelChannels(image); |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | image_view=DestroyCacheView(image_view); |
| 433 | /* |
| 434 | Label connected components. |
| 435 | */ |
| 436 | n=0; |
| cristy | 6e0b3bc | 2014-10-19 17:51:42 +0000 | [diff] [blame] | 437 | component_view=AcquireAuthenticCacheView(component_image,exception); |
| cristy | 6e0b3bc | 2014-10-19 17:51:42 +0000 | [diff] [blame] | 438 | for (y=0; y < (ssize_t) component_image->rows; y++) |
| 439 | { |
| 440 | register Quantum |
| 441 | *restrict q; |
| 442 | |
| 443 | register ssize_t |
| 444 | x; |
| 445 | |
| 446 | if (status == MagickFalse) |
| 447 | continue; |
| 448 | q=QueueCacheViewAuthenticPixels(component_view,0,y,component_image->columns, |
| 449 | 1,exception); |
| 450 | if (q == (Quantum *) NULL) |
| 451 | { |
| 452 | status=MagickFalse; |
| 453 | continue; |
| 454 | } |
| 455 | for (x=0; x < (ssize_t) component_image->columns; x++) |
| 456 | { |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 457 | ssize_t |
| 458 | object, |
| 459 | offset; |
| 460 | |
| 461 | offset=y*image->columns+x; |
| 462 | status=GetMatrixElement(equivalences,offset,0,&object); |
| 463 | if (object == offset) |
| 464 | { |
| 465 | object=n++; |
| 466 | status=SetMatrixElement(equivalences,offset,0,&object); |
| 467 | } |
| 468 | else |
| 469 | { |
| 470 | status=GetMatrixElement(equivalences,object,0,&object); |
| 471 | status=SetMatrixElement(equivalences,offset,0,&object); |
| 472 | } |
| 473 | *q=(Quantum) (object > (ssize_t) QuantumRange ? (ssize_t) QuantumRange : |
| 474 | object); |
| 475 | q+=GetPixelChannels(component_image); |
| cristy | 6e0b3bc | 2014-10-19 17:51:42 +0000 | [diff] [blame] | 476 | } |
| 477 | if (SyncCacheViewAuthenticPixels(component_view,exception) == MagickFalse) |
| 478 | status=MagickFalse; |
| 479 | if (image->progress_monitor != (MagickProgressMonitor) NULL) |
| 480 | { |
| 481 | MagickBooleanType |
| 482 | proceed; |
| 483 | |
| cristy | 6e0b3bc | 2014-10-19 17:51:42 +0000 | [diff] [blame] | 484 | proceed=SetImageProgress(image,ConnectedComponentsImageTag,progress++, |
| 485 | image->rows); |
| 486 | if (proceed == MagickFalse) |
| 487 | status=MagickFalse; |
| 488 | } |
| 489 | } |
| 490 | component_view=DestroyCacheView(component_view); |
| cristy | 016b764 | 2014-10-25 13:09:57 +0000 | [diff] [blame] | 491 | equivalences=DestroyMatrixInfo(equivalences); |
| 492 | artifact=GetImageArtifact(image,"connected-components:verbose"); |
| 493 | if (IsStringTrue(artifact)) |
| 494 | status=ConnectedComponentsStatistics(component_image,(size_t) n,exception); |
| cristy | 6e0b3bc | 2014-10-19 17:51:42 +0000 | [diff] [blame] | 495 | if (status == MagickFalse) |
| 496 | component_image=DestroyImage(component_image); |
| 497 | return(component_image); |
| 498 | } |