├── .gitignore
├── C
└── devernay_1.0
│ ├── COPYING
│ ├── Makefile
│ ├── README.txt
│ ├── devernay
│ ├── devernay.c
│ ├── devernay.h
│ ├── devernay_cmd.c
│ ├── image.asc
│ ├── image.pgm
│ ├── image_out.pdf
│ ├── image_out.svg
│ ├── image_out.txt
│ ├── io.c
│ └── io.h
├── LICENSE
├── README.md
├── apply_tophat.py
├── compare.py
├── data
├── 50SQE_2018_12_10_0_012.jpeg
├── 50SQE_2018_12_10_0_012.json
├── 50SQE_2018_12_10_0_012.pgm
└── gt.npz
├── hough_devernay.py
├── interpolated_shapes.zip
├── iso_th_devernay.py
├── results
├── HCT
│ ├── output
│ │ └── detection_mask_zoom_0_tophat_0_autoth.png
│ └── score
│ │ ├── best_f1_zoom_0_tophat_0_autoth.json
│ │ ├── best_prec_zoom_0_tophat_0_autoth.json
│ │ └── best_rec_zoom_0_tophat_0_autoth.json
├── edges
│ ├── h_15_l_5_sig_0_zoom_0_tophat_0.pdf
│ ├── h_15_l_5_sig_0_zoom_0_tophat_0.txt
│ ├── h_41_l_20.5_sig_0_zoom_0_tophat_0.pdf
│ └── h_41_l_20.5_sig_0_zoom_0_tophat_0.txt
├── iso_th
│ └── output
│ │ └── detection_mask_zoom_0_tophat_0_autoth.png
└── tmp
│ └── im_tophat_False_zoom_False.jpeg
└── utils.py
/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__
2 | __pycache__/*
3 |
--------------------------------------------------------------------------------
/C/devernay_1.0/COPYING:
--------------------------------------------------------------------------------
1 | GNU AFFERO GENERAL PUBLIC LICENSE
2 | Version 3, 19 November 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU Affero General Public License is a free, copyleft license for
11 | software and other kinds of works, specifically designed to ensure
12 | cooperation with the community in the case of network server software.
13 |
14 | The licenses for most software and other practical works are designed
15 | to take away your freedom to share and change the works. By contrast,
16 | our General Public Licenses are intended to guarantee your freedom to
17 | share and change all versions of a program--to make sure it remains free
18 | software for all its users.
19 |
20 | When we speak of free software, we are referring to freedom, not
21 | price. Our General Public Licenses are designed to make sure that you
22 | have the freedom to distribute copies of free software (and charge for
23 | them if you wish), that you receive source code or can get it if you
24 | want it, that you can change the software or use pieces of it in new
25 | free programs, and that you know you can do these things.
26 |
27 | Developers that use our General Public Licenses protect your rights
28 | with two steps: (1) assert copyright on the software, and (2) offer
29 | you this License which gives you legal permission to copy, distribute
30 | and/or modify the software.
31 |
32 | A secondary benefit of defending all users' freedom is that
33 | improvements made in alternate versions of the program, if they
34 | receive widespread use, become available for other developers to
35 | incorporate. Many developers of free software are heartened and
36 | encouraged by the resulting cooperation. However, in the case of
37 | software used on network servers, this result may fail to come about.
38 | The GNU General Public License permits making a modified version and
39 | letting the public access it on a server without ever releasing its
40 | source code to the public.
41 |
42 | The GNU Affero General Public License is designed specifically to
43 | ensure that, in such cases, the modified source code becomes available
44 | to the community. It requires the operator of a network server to
45 | provide the source code of the modified version running there to the
46 | users of that server. Therefore, public use of a modified version, on
47 | a publicly accessible server, gives the public access to the source
48 | code of the modified version.
49 |
50 | An older license, called the Affero General Public License and
51 | published by Affero, was designed to accomplish similar goals. This is
52 | a different license, not a version of the Affero GPL, but Affero has
53 | released a new version of the Affero GPL which permits relicensing under
54 | this license.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | TERMS AND CONDITIONS
60 |
61 | 0. Definitions.
62 |
63 | "This License" refers to version 3 of the GNU Affero General Public License.
64 |
65 | "Copyright" also means copyright-like laws that apply to other kinds of
66 | works, such as semiconductor masks.
67 |
68 | "The Program" refers to any copyrightable work licensed under this
69 | License. Each licensee is addressed as "you". "Licensees" and
70 | "recipients" may be individuals or organizations.
71 |
72 | To "modify" a work means to copy from or adapt all or part of the work
73 | in a fashion requiring copyright permission, other than the making of an
74 | exact copy. The resulting work is called a "modified version" of the
75 | earlier work or a work "based on" the earlier work.
76 |
77 | A "covered work" means either the unmodified Program or a work based
78 | on the Program.
79 |
80 | To "propagate" a work means to do anything with it that, without
81 | permission, would make you directly or secondarily liable for
82 | infringement under applicable copyright law, except executing it on a
83 | computer or modifying a private copy. Propagation includes copying,
84 | distribution (with or without modification), making available to the
85 | public, and in some countries other activities as well.
86 |
87 | To "convey" a work means any kind of propagation that enables other
88 | parties to make or receive copies. Mere interaction with a user through
89 | a computer network, with no transfer of a copy, is not conveying.
90 |
91 | An interactive user interface displays "Appropriate Legal Notices"
92 | to the extent that it includes a convenient and prominently visible
93 | feature that (1) displays an appropriate copyright notice, and (2)
94 | tells the user that there is no warranty for the work (except to the
95 | extent that warranties are provided), that licensees may convey the
96 | work under this License, and how to view a copy of this License. If
97 | the interface presents a list of user commands or options, such as a
98 | menu, a prominent item in the list meets this criterion.
99 |
100 | 1. Source Code.
101 |
102 | The "source code" for a work means the preferred form of the work
103 | for making modifications to it. "Object code" means any non-source
104 | form of a work.
105 |
106 | A "Standard Interface" means an interface that either is an official
107 | standard defined by a recognized standards body, or, in the case of
108 | interfaces specified for a particular programming language, one that
109 | is widely used among developers working in that language.
110 |
111 | The "System Libraries" of an executable work include anything, other
112 | than the work as a whole, that (a) is included in the normal form of
113 | packaging a Major Component, but which is not part of that Major
114 | Component, and (b) serves only to enable use of the work with that
115 | Major Component, or to implement a Standard Interface for which an
116 | implementation is available to the public in source code form. A
117 | "Major Component", in this context, means a major essential component
118 | (kernel, window system, and so on) of the specific operating system
119 | (if any) on which the executable work runs, or a compiler used to
120 | produce the work, or an object code interpreter used to run it.
121 |
122 | The "Corresponding Source" for a work in object code form means all
123 | the source code needed to generate, install, and (for an executable
124 | work) run the object code and to modify the work, including scripts to
125 | control those activities. However, it does not include the work's
126 | System Libraries, or general-purpose tools or generally available free
127 | programs which are used unmodified in performing those activities but
128 | which are not part of the work. For example, Corresponding Source
129 | includes interface definition files associated with source files for
130 | the work, and the source code for shared libraries and dynamically
131 | linked subprograms that the work is specifically designed to require,
132 | such as by intimate data communication or control flow between those
133 | subprograms and other parts of the work.
134 |
135 | The Corresponding Source need not include anything that users
136 | can regenerate automatically from other parts of the Corresponding
137 | Source.
138 |
139 | The Corresponding Source for a work in source code form is that
140 | same work.
141 |
142 | 2. Basic Permissions.
143 |
144 | All rights granted under this License are granted for the term of
145 | copyright on the Program, and are irrevocable provided the stated
146 | conditions are met. This License explicitly affirms your unlimited
147 | permission to run the unmodified Program. The output from running a
148 | covered work is covered by this License only if the output, given its
149 | content, constitutes a covered work. This License acknowledges your
150 | rights of fair use or other equivalent, as provided by copyright law.
151 |
152 | You may make, run and propagate covered works that you do not
153 | convey, without conditions so long as your license otherwise remains
154 | in force. You may convey covered works to others for the sole purpose
155 | of having them make modifications exclusively for you, or provide you
156 | with facilities for running those works, provided that you comply with
157 | the terms of this License in conveying all material for which you do
158 | not control copyright. Those thus making or running the covered works
159 | for you must do so exclusively on your behalf, under your direction
160 | and control, on terms that prohibit them from making any copies of
161 | your copyrighted material outside their relationship with you.
162 |
163 | Conveying under any other circumstances is permitted solely under
164 | the conditions stated below. Sublicensing is not allowed; section 10
165 | makes it unnecessary.
166 |
167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168 |
169 | No covered work shall be deemed part of an effective technological
170 | measure under any applicable law fulfilling obligations under article
171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172 | similar laws prohibiting or restricting circumvention of such
173 | measures.
174 |
175 | When you convey a covered work, you waive any legal power to forbid
176 | circumvention of technological measures to the extent such circumvention
177 | is effected by exercising rights under this License with respect to
178 | the covered work, and you disclaim any intention to limit operation or
179 | modification of the work as a means of enforcing, against the work's
180 | users, your or third parties' legal rights to forbid circumvention of
181 | technological measures.
182 |
183 | 4. Conveying Verbatim Copies.
184 |
185 | You may convey verbatim copies of the Program's source code as you
186 | receive it, in any medium, provided that you conspicuously and
187 | appropriately publish on each copy an appropriate copyright notice;
188 | keep intact all notices stating that this License and any
189 | non-permissive terms added in accord with section 7 apply to the code;
190 | keep intact all notices of the absence of any warranty; and give all
191 | recipients a copy of this License along with the Program.
192 |
193 | You may charge any price or no price for each copy that you convey,
194 | and you may offer support or warranty protection for a fee.
195 |
196 | 5. Conveying Modified Source Versions.
197 |
198 | You may convey a work based on the Program, or the modifications to
199 | produce it from the Program, in the form of source code under the
200 | terms of section 4, provided that you also meet all of these conditions:
201 |
202 | a) The work must carry prominent notices stating that you modified
203 | it, and giving a relevant date.
204 |
205 | b) The work must carry prominent notices stating that it is
206 | released under this License and any conditions added under section
207 | 7. This requirement modifies the requirement in section 4 to
208 | "keep intact all notices".
209 |
210 | c) You must license the entire work, as a whole, under this
211 | License to anyone who comes into possession of a copy. This
212 | License will therefore apply, along with any applicable section 7
213 | additional terms, to the whole of the work, and all its parts,
214 | regardless of how they are packaged. This License gives no
215 | permission to license the work in any other way, but it does not
216 | invalidate such permission if you have separately received it.
217 |
218 | d) If the work has interactive user interfaces, each must display
219 | Appropriate Legal Notices; however, if the Program has interactive
220 | interfaces that do not display Appropriate Legal Notices, your
221 | work need not make them do so.
222 |
223 | A compilation of a covered work with other separate and independent
224 | works, which are not by their nature extensions of the covered work,
225 | and which are not combined with it such as to form a larger program,
226 | in or on a volume of a storage or distribution medium, is called an
227 | "aggregate" if the compilation and its resulting copyright are not
228 | used to limit the access or legal rights of the compilation's users
229 | beyond what the individual works permit. Inclusion of a covered work
230 | in an aggregate does not cause this License to apply to the other
231 | parts of the aggregate.
232 |
233 | 6. Conveying Non-Source Forms.
234 |
235 | You may convey a covered work in object code form under the terms
236 | of sections 4 and 5, provided that you also convey the
237 | machine-readable Corresponding Source under the terms of this License,
238 | in one of these ways:
239 |
240 | a) Convey the object code in, or embodied in, a physical product
241 | (including a physical distribution medium), accompanied by the
242 | Corresponding Source fixed on a durable physical medium
243 | customarily used for software interchange.
244 |
245 | b) Convey the object code in, or embodied in, a physical product
246 | (including a physical distribution medium), accompanied by a
247 | written offer, valid for at least three years and valid for as
248 | long as you offer spare parts or customer support for that product
249 | model, to give anyone who possesses the object code either (1) a
250 | copy of the Corresponding Source for all the software in the
251 | product that is covered by this License, on a durable physical
252 | medium customarily used for software interchange, for a price no
253 | more than your reasonable cost of physically performing this
254 | conveying of source, or (2) access to copy the
255 | Corresponding Source from a network server at no charge.
256 |
257 | c) Convey individual copies of the object code with a copy of the
258 | written offer to provide the Corresponding Source. This
259 | alternative is allowed only occasionally and noncommercially, and
260 | only if you received the object code with such an offer, in accord
261 | with subsection 6b.
262 |
263 | d) Convey the object code by offering access from a designated
264 | place (gratis or for a charge), and offer equivalent access to the
265 | Corresponding Source in the same way through the same place at no
266 | further charge. You need not require recipients to copy the
267 | Corresponding Source along with the object code. If the place to
268 | copy the object code is a network server, the Corresponding Source
269 | may be on a different server (operated by you or a third party)
270 | that supports equivalent copying facilities, provided you maintain
271 | clear directions next to the object code saying where to find the
272 | Corresponding Source. Regardless of what server hosts the
273 | Corresponding Source, you remain obligated to ensure that it is
274 | available for as long as needed to satisfy these requirements.
275 |
276 | e) Convey the object code using peer-to-peer transmission, provided
277 | you inform other peers where the object code and Corresponding
278 | Source of the work are being offered to the general public at no
279 | charge under subsection 6d.
280 |
281 | A separable portion of the object code, whose source code is excluded
282 | from the Corresponding Source as a System Library, need not be
283 | included in conveying the object code work.
284 |
285 | A "User Product" is either (1) a "consumer product", which means any
286 | tangible personal property which is normally used for personal, family,
287 | or household purposes, or (2) anything designed or sold for incorporation
288 | into a dwelling. In determining whether a product is a consumer product,
289 | doubtful cases shall be resolved in favor of coverage. For a particular
290 | product received by a particular user, "normally used" refers to a
291 | typical or common use of that class of product, regardless of the status
292 | of the particular user or of the way in which the particular user
293 | actually uses, or expects or is expected to use, the product. A product
294 | is a consumer product regardless of whether the product has substantial
295 | commercial, industrial or non-consumer uses, unless such uses represent
296 | the only significant mode of use of the product.
297 |
298 | "Installation Information" for a User Product means any methods,
299 | procedures, authorization keys, or other information required to install
300 | and execute modified versions of a covered work in that User Product from
301 | a modified version of its Corresponding Source. The information must
302 | suffice to ensure that the continued functioning of the modified object
303 | code is in no case prevented or interfered with solely because
304 | modification has been made.
305 |
306 | If you convey an object code work under this section in, or with, or
307 | specifically for use in, a User Product, and the conveying occurs as
308 | part of a transaction in which the right of possession and use of the
309 | User Product is transferred to the recipient in perpetuity or for a
310 | fixed term (regardless of how the transaction is characterized), the
311 | Corresponding Source conveyed under this section must be accompanied
312 | by the Installation Information. But this requirement does not apply
313 | if neither you nor any third party retains the ability to install
314 | modified object code on the User Product (for example, the work has
315 | been installed in ROM).
316 |
317 | The requirement to provide Installation Information does not include a
318 | requirement to continue to provide support service, warranty, or updates
319 | for a work that has been modified or installed by the recipient, or for
320 | the User Product in which it has been modified or installed. Access to a
321 | network may be denied when the modification itself materially and
322 | adversely affects the operation of the network or violates the rules and
323 | protocols for communication across the network.
324 |
325 | Corresponding Source conveyed, and Installation Information provided,
326 | in accord with this section must be in a format that is publicly
327 | documented (and with an implementation available to the public in
328 | source code form), and must require no special password or key for
329 | unpacking, reading or copying.
330 |
331 | 7. Additional Terms.
332 |
333 | "Additional permissions" are terms that supplement the terms of this
334 | License by making exceptions from one or more of its conditions.
335 | Additional permissions that are applicable to the entire Program shall
336 | be treated as though they were included in this License, to the extent
337 | that they are valid under applicable law. If additional permissions
338 | apply only to part of the Program, that part may be used separately
339 | under those permissions, but the entire Program remains governed by
340 | this License without regard to the additional permissions.
341 |
342 | When you convey a copy of a covered work, you may at your option
343 | remove any additional permissions from that copy, or from any part of
344 | it. (Additional permissions may be written to require their own
345 | removal in certain cases when you modify the work.) You may place
346 | additional permissions on material, added by you to a covered work,
347 | for which you have or can give appropriate copyright permission.
348 |
349 | Notwithstanding any other provision of this License, for material you
350 | add to a covered work, you may (if authorized by the copyright holders of
351 | that material) supplement the terms of this License with terms:
352 |
353 | a) Disclaiming warranty or limiting liability differently from the
354 | terms of sections 15 and 16 of this License; or
355 |
356 | b) Requiring preservation of specified reasonable legal notices or
357 | author attributions in that material or in the Appropriate Legal
358 | Notices displayed by works containing it; or
359 |
360 | c) Prohibiting misrepresentation of the origin of that material, or
361 | requiring that modified versions of such material be marked in
362 | reasonable ways as different from the original version; or
363 |
364 | d) Limiting the use for publicity purposes of names of licensors or
365 | authors of the material; or
366 |
367 | e) Declining to grant rights under trademark law for use of some
368 | trade names, trademarks, or service marks; or
369 |
370 | f) Requiring indemnification of licensors and authors of that
371 | material by anyone who conveys the material (or modified versions of
372 | it) with contractual assumptions of liability to the recipient, for
373 | any liability that these contractual assumptions directly impose on
374 | those licensors and authors.
375 |
376 | All other non-permissive additional terms are considered "further
377 | restrictions" within the meaning of section 10. If the Program as you
378 | received it, or any part of it, contains a notice stating that it is
379 | governed by this License along with a term that is a further
380 | restriction, you may remove that term. If a license document contains
381 | a further restriction but permits relicensing or conveying under this
382 | License, you may add to a covered work material governed by the terms
383 | of that license document, provided that the further restriction does
384 | not survive such relicensing or conveying.
385 |
386 | If you add terms to a covered work in accord with this section, you
387 | must place, in the relevant source files, a statement of the
388 | additional terms that apply to those files, or a notice indicating
389 | where to find the applicable terms.
390 |
391 | Additional terms, permissive or non-permissive, may be stated in the
392 | form of a separately written license, or stated as exceptions;
393 | the above requirements apply either way.
394 |
395 | 8. Termination.
396 |
397 | You may not propagate or modify a covered work except as expressly
398 | provided under this License. Any attempt otherwise to propagate or
399 | modify it is void, and will automatically terminate your rights under
400 | this License (including any patent licenses granted under the third
401 | paragraph of section 11).
402 |
403 | However, if you cease all violation of this License, then your
404 | license from a particular copyright holder is reinstated (a)
405 | provisionally, unless and until the copyright holder explicitly and
406 | finally terminates your license, and (b) permanently, if the copyright
407 | holder fails to notify you of the violation by some reasonable means
408 | prior to 60 days after the cessation.
409 |
410 | Moreover, your license from a particular copyright holder is
411 | reinstated permanently if the copyright holder notifies you of the
412 | violation by some reasonable means, this is the first time you have
413 | received notice of violation of this License (for any work) from that
414 | copyright holder, and you cure the violation prior to 30 days after
415 | your receipt of the notice.
416 |
417 | Termination of your rights under this section does not terminate the
418 | licenses of parties who have received copies or rights from you under
419 | this License. If your rights have been terminated and not permanently
420 | reinstated, you do not qualify to receive new licenses for the same
421 | material under section 10.
422 |
423 | 9. Acceptance Not Required for Having Copies.
424 |
425 | You are not required to accept this License in order to receive or
426 | run a copy of the Program. Ancillary propagation of a covered work
427 | occurring solely as a consequence of using peer-to-peer transmission
428 | to receive a copy likewise does not require acceptance. However,
429 | nothing other than this License grants you permission to propagate or
430 | modify any covered work. These actions infringe copyright if you do
431 | not accept this License. Therefore, by modifying or propagating a
432 | covered work, you indicate your acceptance of this License to do so.
433 |
434 | 10. Automatic Licensing of Downstream Recipients.
435 |
436 | Each time you convey a covered work, the recipient automatically
437 | receives a license from the original licensors, to run, modify and
438 | propagate that work, subject to this License. You are not responsible
439 | for enforcing compliance by third parties with this License.
440 |
441 | An "entity transaction" is a transaction transferring control of an
442 | organization, or substantially all assets of one, or subdividing an
443 | organization, or merging organizations. If propagation of a covered
444 | work results from an entity transaction, each party to that
445 | transaction who receives a copy of the work also receives whatever
446 | licenses to the work the party's predecessor in interest had or could
447 | give under the previous paragraph, plus a right to possession of the
448 | Corresponding Source of the work from the predecessor in interest, if
449 | the predecessor has it or can get it with reasonable efforts.
450 |
451 | You may not impose any further restrictions on the exercise of the
452 | rights granted or affirmed under this License. For example, you may
453 | not impose a license fee, royalty, or other charge for exercise of
454 | rights granted under this License, and you may not initiate litigation
455 | (including a cross-claim or counterclaim in a lawsuit) alleging that
456 | any patent claim is infringed by making, using, selling, offering for
457 | sale, or importing the Program or any portion of it.
458 |
459 | 11. Patents.
460 |
461 | A "contributor" is a copyright holder who authorizes use under this
462 | License of the Program or a work on which the Program is based. The
463 | work thus licensed is called the contributor's "contributor version".
464 |
465 | A contributor's "essential patent claims" are all patent claims
466 | owned or controlled by the contributor, whether already acquired or
467 | hereafter acquired, that would be infringed by some manner, permitted
468 | by this License, of making, using, or selling its contributor version,
469 | but do not include claims that would be infringed only as a
470 | consequence of further modification of the contributor version. For
471 | purposes of this definition, "control" includes the right to grant
472 | patent sublicenses in a manner consistent with the requirements of
473 | this License.
474 |
475 | Each contributor grants you a non-exclusive, worldwide, royalty-free
476 | patent license under the contributor's essential patent claims, to
477 | make, use, sell, offer for sale, import and otherwise run, modify and
478 | propagate the contents of its contributor version.
479 |
480 | In the following three paragraphs, a "patent license" is any express
481 | agreement or commitment, however denominated, not to enforce a patent
482 | (such as an express permission to practice a patent or covenant not to
483 | sue for patent infringement). To "grant" such a patent license to a
484 | party means to make such an agreement or commitment not to enforce a
485 | patent against the party.
486 |
487 | If you convey a covered work, knowingly relying on a patent license,
488 | and the Corresponding Source of the work is not available for anyone
489 | to copy, free of charge and under the terms of this License, through a
490 | publicly available network server or other readily accessible means,
491 | then you must either (1) cause the Corresponding Source to be so
492 | available, or (2) arrange to deprive yourself of the benefit of the
493 | patent license for this particular work, or (3) arrange, in a manner
494 | consistent with the requirements of this License, to extend the patent
495 | license to downstream recipients. "Knowingly relying" means you have
496 | actual knowledge that, but for the patent license, your conveying the
497 | covered work in a country, or your recipient's use of the covered work
498 | in a country, would infringe one or more identifiable patents in that
499 | country that you have reason to believe are valid.
500 |
501 | If, pursuant to or in connection with a single transaction or
502 | arrangement, you convey, or propagate by procuring conveyance of, a
503 | covered work, and grant a patent license to some of the parties
504 | receiving the covered work authorizing them to use, propagate, modify
505 | or convey a specific copy of the covered work, then the patent license
506 | you grant is automatically extended to all recipients of the covered
507 | work and works based on it.
508 |
509 | A patent license is "discriminatory" if it does not include within
510 | the scope of its coverage, prohibits the exercise of, or is
511 | conditioned on the non-exercise of one or more of the rights that are
512 | specifically granted under this License. You may not convey a covered
513 | work if you are a party to an arrangement with a third party that is
514 | in the business of distributing software, under which you make payment
515 | to the third party based on the extent of your activity of conveying
516 | the work, and under which the third party grants, to any of the
517 | parties who would receive the covered work from you, a discriminatory
518 | patent license (a) in connection with copies of the covered work
519 | conveyed by you (or copies made from those copies), or (b) primarily
520 | for and in connection with specific products or compilations that
521 | contain the covered work, unless you entered into that arrangement,
522 | or that patent license was granted, prior to 28 March 2007.
523 |
524 | Nothing in this License shall be construed as excluding or limiting
525 | any implied license or other defenses to infringement that may
526 | otherwise be available to you under applicable patent law.
527 |
528 | 12. No Surrender of Others' Freedom.
529 |
530 | If conditions are imposed on you (whether by court order, agreement or
531 | otherwise) that contradict the conditions of this License, they do not
532 | excuse you from the conditions of this License. If you cannot convey a
533 | covered work so as to satisfy simultaneously your obligations under this
534 | License and any other pertinent obligations, then as a consequence you may
535 | not convey it at all. For example, if you agree to terms that obligate you
536 | to collect a royalty for further conveying from those to whom you convey
537 | the Program, the only way you could satisfy both those terms and this
538 | License would be to refrain entirely from conveying the Program.
539 |
540 | 13. Remote Network Interaction; Use with the GNU General Public License.
541 |
542 | Notwithstanding any other provision of this License, if you modify the
543 | Program, your modified version must prominently offer all users
544 | interacting with it remotely through a computer network (if your version
545 | supports such interaction) an opportunity to receive the Corresponding
546 | Source of your version by providing access to the Corresponding Source
547 | from a network server at no charge, through some standard or customary
548 | means of facilitating copying of software. This Corresponding Source
549 | shall include the Corresponding Source for any work covered by version 3
550 | of the GNU General Public License that is incorporated pursuant to the
551 | following paragraph.
552 |
553 | Notwithstanding any other provision of this License, you have
554 | permission to link or combine any covered work with a work licensed
555 | under version 3 of the GNU General Public License into a single
556 | combined work, and to convey the resulting work. The terms of this
557 | License will continue to apply to the part which is the covered work,
558 | but the work with which it is combined will remain governed by version
559 | 3 of the GNU General Public License.
560 |
561 | 14. Revised Versions of this License.
562 |
563 | The Free Software Foundation may publish revised and/or new versions of
564 | the GNU Affero General Public License from time to time. Such new versions
565 | will be similar in spirit to the present version, but may differ in detail to
566 | address new problems or concerns.
567 |
568 | Each version is given a distinguishing version number. If the
569 | Program specifies that a certain numbered version of the GNU Affero General
570 | Public License "or any later version" applies to it, you have the
571 | option of following the terms and conditions either of that numbered
572 | version or of any later version published by the Free Software
573 | Foundation. If the Program does not specify a version number of the
574 | GNU Affero General Public License, you may choose any version ever published
575 | by the Free Software Foundation.
576 |
577 | If the Program specifies that a proxy can decide which future
578 | versions of the GNU Affero General Public License can be used, that proxy's
579 | public statement of acceptance of a version permanently authorizes you
580 | to choose that version for the Program.
581 |
582 | Later license versions may give you additional or different
583 | permissions. However, no additional obligations are imposed on any
584 | author or copyright holder as a result of your choosing to follow a
585 | later version.
586 |
587 | 15. Disclaimer of Warranty.
588 |
589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597 |
598 | 16. Limitation of Liability.
599 |
600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608 | SUCH DAMAGES.
609 |
610 | 17. Interpretation of Sections 15 and 16.
611 |
612 | If the disclaimer of warranty and limitation of liability provided
613 | above cannot be given local legal effect according to their terms,
614 | reviewing courts shall apply local law that most closely approximates
615 | an absolute waiver of all civil liability in connection with the
616 | Program, unless a warranty or assumption of liability accompanies a
617 | copy of the Program in return for a fee.
618 |
619 | END OF TERMS AND CONDITIONS
620 |
621 | How to Apply These Terms to Your New Programs
622 |
623 | If you develop a new program, and you want it to be of the greatest
624 | possible use to the public, the best way to achieve this is to make it
625 | free software which everyone can redistribute and change under these terms.
626 |
627 | To do so, attach the following notices to the program. It is safest
628 | to attach them to the start of each source file to most effectively
629 | state the exclusion of warranty; and each file should have at least
630 | the "copyright" line and a pointer to where the full notice is found.
631 |
632 |
633 | Copyright (C)
634 |
635 | This program is free software: you can redistribute it and/or modify
636 | it under the terms of the GNU Affero General Public License as published by
637 | the Free Software Foundation, either version 3 of the License, or
638 | (at your option) any later version.
639 |
640 | This program is distributed in the hope that it will be useful,
641 | but WITHOUT ANY WARRANTY; without even the implied warranty of
642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643 | GNU Affero General Public License for more details.
644 |
645 | You should have received a copy of the GNU Affero General Public License
646 | along with this program. If not, see .
647 |
648 | Also add information on how to contact you by electronic and paper mail.
649 |
650 | If your software can interact with users remotely through a computer
651 | network, you should also make sure that it provides a way for users to
652 | get its source. For example, if your program is a web application, its
653 | interface could display a "Source" link that leads users to an archive
654 | of the code. There are many ways you could offer source, and different
655 | solutions will be better for different programs; see section 13 for the
656 | specific requirements.
657 |
658 | You should also get your employer (if you work as a programmer) or school,
659 | if any, to sign a "copyright disclaimer" for the program, if necessary.
660 | For more information on this, and how to apply and follow the GNU AGPL, see
661 | .
662 |
--------------------------------------------------------------------------------
/C/devernay_1.0/Makefile:
--------------------------------------------------------------------------------
1 | devernay: devernay_cmd.c io.c io.h devernay.c devernay.h
2 | $(CC) -O3 -o devernay devernay_cmd.c io.c devernay.c -lm
3 |
4 | test: devernay
5 | ./devernay image.pgm -t output.txt -p output.pdf -g output.svg
6 |
7 | clean:
8 | rm -f devernay output.txt output.pdf output.svg
9 |
--------------------------------------------------------------------------------
/C/devernay_1.0/README.txt:
--------------------------------------------------------------------------------
1 | The Canny/Devernay algorithm
2 | ============================
3 |
4 | Version 1.0 - October 10, 2017
5 | by Rafael Grompone von Gioi
6 | and Gregory Randall
7 |
8 |
9 | Introduction
10 | ------------
11 |
12 | This is an implementation of Canny/Devernay's sub-pixel edge detector. This
13 | code is part of the following publication and was subject to peer review:
14 |
15 | "A Sub-Pixel Edge Detector: an Implementation of the Canny/Devernay Algorithm"
16 | by Rafael Grompone von Gioi and Gregory Randall,
17 | Image Processing On Line, 2017. DOI:10.5201/ipol.2017.216
18 | http://dx.doi.org/10.5201/ipol.2017.216
19 |
20 |
21 | Files
22 | -----
23 |
24 | README.txt - This file
25 | COPYING - GNU AFFERO GENERAL PUBLIC LICENSE Version 3
26 | Makefile - Compilation instructions for 'make'
27 | devernay.c - Devernay module ANSI C89 code (peer reviewed)
28 | devernay.h - Devernay module ANSI C89 header (peer reviewed)
29 | devernay_cmd.c - Command line interface for Devernay, ANSI C89
30 | io.c - Input/Output functions for command interface, ANSI C89
31 | io.h - Input/Output functions header, ANSI C89
32 | image.pgm - Test image in PGM format
33 | image.asc - Test image in ASC format
34 | image_out.txt - Expected result for the test image as an TXT file
35 | image_out.pdf - Expected result for the test image as a PDF file
36 | image_out.svg - Expected result for the test image as a SVG file
37 |
38 | The files 'devernay.c' and 'devernay.h' were subject to peer review as part of
39 | the acceptance process of the IPOL article and are the official version of
40 | Devernay.
41 |
42 |
43 | Compiling
44 | ---------
45 |
46 | Devernay is an ANSI C89 Language program and can be used as a module to
47 | be called from a C language program or as an independent command.
48 |
49 | In the distribution is included a Makefile file with instructions to build the
50 | command line program 'devernay'. A C compiler must be installed on your system
51 | as well as the program 'make'. Devernay only uses the standard C library so it
52 | should compile in any ANSI C89 Language environment. In particular, it should
53 | compile in a Unix like system.
54 |
55 | The compiling instruction is just
56 |
57 | make
58 |
59 | from the directory where the source codes and the Makefile are located. If the
60 | compilation needs to be made manually, the usual command to do it is:
61 |
62 | cc -o devernay devernay_cmd.c io.c devernay.c -lm
63 |
64 | To verify a correct compilation you can apply Devernay to the test image
65 | 'image.pgm' and compare the result to the provided ones. This can be done by
66 | executing:
67 |
68 | make test
69 |
70 |
71 | Running the Command Line Interface
72 | ----------------------------------
73 |
74 | The simplest Devernay command execution is just
75 |
76 | devernay
77 |
78 | (use ./devernay if the command is not included in the current path). That
79 | should print Devernay version number and a description of the command line
80 | interface, including the available options. The input image formats handled are
81 | PGM (in its two versions, ASCII and Binary) and the ASC format (as defined by
82 | the CImg Library and as described below). A typical execution would be:
83 |
84 | devernay image.pgm -t output.txt
85 |
86 | That should give the result as an TXT file 'output.txt' which consists of two
87 | columns of real numbers in ASCII format (the numbers are separated by a
88 | space). Each row corresponds to a contour point, the first column gives the x
89 | coordinate and the second row gives the y coordinate. Contour points of
90 | consecutive rows are part of the same curve, they are chained. Each curve is
91 | ended by a row "-1 -1", which mark the end of the curve or chain. A new chain
92 | may start on the next row. Then end of the file indicates that no more curves
93 | are present. For closed curves, the first point of the curve is repeated again
94 | as the last point of the chain. The following is an example of output:
95 |
96 | 9 5.57116
97 | 10 5.73102
98 | 11 6.64051
99 | 11.9352 8
100 | 12.0939 9
101 | 11.9844 10
102 | 11.4029 11
103 | 10 12.0179
104 | 9 12.119
105 | 8 11.9399
106 | 6.62612 11
107 | 5.65646 10
108 | 5.51349 9
109 | 5.62126 8
110 | 7 6.54667
111 | 8 5.68361
112 | 9 5.57116
113 | -1 -1
114 | 2.09193 5
115 | 2.17282 4
116 | 3 2.7223
117 | 4 2.13559
118 | 5 1.99507
119 | -1 -1
120 |
121 | It corresponds to two curves, each one ended by a "-1 -1" row. The first one is
122 | a closed curve described by 16 points. Please note that the list has 17 points,
123 | but the first and last are the same, "9 5.57116", indicating a closed
124 | curve. The second curve is an open curve described by five points. Note that
125 | one of the two coordinates is always an integer. This is due the modified
126 | Devernay sub-pixel correction, in which the sub-pixel interpolation is always
127 | performed along the vertical or horizontal axis, but not both; thus, one of the
128 | two coordinates is not interpolated and remain an integer.
129 |
130 | For easy visualization of the result, the command line interface can also
131 | provide the output in PDF and SVG file formats:
132 |
133 | devernay image.pgm -p output.pdf
134 |
135 | will produce the PDF file 'output.pdf' and
136 |
137 | devernay image.pgm -g output.svg
138 |
139 | will produce the SVG file 'output.svg'. Using all these options will generate
140 | TXT, PDF and SVG outputs:
141 |
142 | devernay image.pgm -p output.pdf -t output.txt -g output.svg
143 |
144 | Note that the line width used in the PDF and SVG output is arbitrary. The
145 | default value is 1.3 (in pixel units) but can be modified with the -w
146 | option. By using a smaller value, the sub-pixel accuracy of the result is
147 | better appreciated:
148 |
149 | devernay image.pgm -p output.pdf -w 0.5
150 |
151 | The width value can be set to zero:
152 |
153 | devernay image.pgm -p output.pdf -g output.svg -w 0
154 |
155 | In this case, the PDF and SVG standards determine different behavior. In PDF,
156 | a zero width means that the software rendering the PDF will choose the smallest
157 | possible line width that can be rendered in the current device. This is useful
158 | to see details but it is not recommended for figures to be distributed as the
159 | rendering is device dependent. In SVG, however, line with zero width are not
160 | drawn.
161 |
162 | The Canny/Devernay algorithm depends on three parameters: sigma, th_low,
163 | th_high. The default value of these parameters is zero for the three of them.
164 | Their value can be modified individually using the -s, -l and -h options of the
165 | command line interface. For example:
166 |
167 | devernay image.pgm -p output.pdf -s 1 -l 5 -h 15
168 |
169 | will set the standard deviation of the Gaussian filtering to 1, the low
170 | gradient threshold to 5 and the high gradient threshold to 15.
171 |
172 |
173 | The ASC file format
174 | -------------------
175 |
176 | The ASC image file format was defined by the CImg Library (http://cimg.eu/). It
177 | is a simple ASCII format allowing to store 4D arrays of floating point values
178 | (and not just integer as in PGM). In addition, multiple channels and multiple
179 | frames are possible; the command line interface of Devernay, however, only
180 | handles a single gray level frame. The main reason to include this file format
181 | as a possible input is to be able to use floating point images in a simple
182 | way. As an example, the file 'image.asc' in this distribution contains the same
183 | image as 'image.pgm' but in ASC file format.
184 |
185 | To explain the ASC file format, the following is an example of a 6x6 floating
186 | point gray-level in ASC format:
187 |
188 | 6 6 1 1
189 | 0.0022 0.1119 0.9455 1.7084 0.9455 0.1119
190 | 0.1119 1.7270 5.8871 7.4892 5.8871 1.7270
191 | 0.9455 5.8871 9.6757 9.9586 9.6757 5.8888
192 | 1.7084 7.4892 9.9586 9.9999 9.9586 7.4934
193 | 0.9455 5.8871 9.6757 9.9586 9.6757 5.8888
194 | 0.1119 1.7270 5.8888 7.4934 5.8888 1.7271
195 |
196 | An ASC file consists of a simple header followed by the data, all written as
197 | numbers in ASCII format. The header is just four integer numbers separated by
198 | spaces and ending in a new line. The four numbers of the header correspond to
199 | the size of each of the 4 dimensions X, Y, Z and C and in that order: X is the
200 | width of the image; Y is the height of the image; Z is the number of frames; C
201 | is the number of channels. For single frame and single channel (as in the
202 | example above and as required by Devernay), Z=1 and C=1.
203 |
204 | The header is followed by the data written in standard ASCII floating point
205 | notation. Any format accepted by the standard C function scanf is valid; for
206 | example: 0, 692315, 0.34230295282, -30.3423, +45, 1e10, 5E4, 3.14e-34. The
207 | numbers should be separated by any combination of spaces, tabs, or end-of-line.
208 | The order of the numbers is important. The pixels have coordinates (x,y,z,c),
209 | with 0 <= x < X and 0 <= y < Y and 0 <= z < Z and 0 <= c < C. The pixel
210 | (x,y,z,c) will be stored at position x + y*X + z*X*Y + c*X*Y*Z. Thus, the first
211 | number following the header corresponds to pixel (0,0,0,0) which is the upper
212 | left pixel of the first channel of the first frame. The second value is the
213 | second pixel on the same row (1,0,0,0) and the following values complete the
214 | first row (up to X-1,0,0,0). Then comes the second row of the first channel of
215 | the first frame, from (0,1,0,0) to (X-1,1,0,0). Then the following rows and so
216 | on until the last row of the frame, (0,Y-1,0,0) to (X-1,Y-1,0,0). This would
217 | complete the image if only one frame and one channel are present (as required
218 | in Devernay and as in the example above).
219 |
220 | In multiple frame and multiple channel (Z>1 and/or C>1), the next values will
221 | store, in the same way, the first channel of the second frame. When all the
222 | frames are complete, the same procedure will be done for the values of the
223 | second channel, and so on.
224 |
225 |
226 | Copyright and License
227 | ---------------------
228 |
229 | Copyright (c) 2016-2017 Rafael Grompone von Gioi and Gregory Randall
230 |
231 | This program is free software: you can redistribute it and/or modify
232 | it under the terms of the GNU Affero General Public License as
233 | published by the Free Software Foundation, either version 3 of the
234 | License, or (at your option) any later version.
235 |
236 | This program is distributed in the hope that it will be useful,
237 | but WITHOUT ANY WARRANTY; without even the implied warranty of
238 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
239 | GNU Affero General Public License for more details.
240 |
241 | You should have received a copy of the GNU Affero General Public License
242 | along with this program. If not, see .
243 |
244 |
245 | Thanks
246 | ------
247 |
248 | We would be grateful to receive any comment, especially about errors, bugs,
249 | or strange results.
250 |
--------------------------------------------------------------------------------
/C/devernay_1.0/devernay:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anttad/SubpixelCircleDetection/912252d4a305d71f800ed39b3ce87946251cb675/C/devernay_1.0/devernay
--------------------------------------------------------------------------------
/C/devernay_1.0/devernay.c:
--------------------------------------------------------------------------------
1 | /*----------------------------------------------------------------------------
2 |
3 | Implementation of Canny/Devernay's sub-pixel edge detector. This code is part
4 | of the following publication and was subject to peer review:
5 |
6 | "A Sub-Pixel Edge Detector: an Implementation of the Canny/Devernay
7 | Algorithm" by Rafael Grompone von Gioi and Gregory Randall,
8 | Image Processing On Line, 2017. DOI:10.5201/ipol.2017.216
9 | http://dx.doi.org/10.5201/ipol.2017.216
10 |
11 | Copyright (c) 2016-2017 rafael grompone von gioi ,
12 | Gregory Randall
13 |
14 | This program is free software: you can redistribute it and/or modify
15 | it under the terms of the GNU Affero General Public License as
16 | published by the Free Software Foundation, either version 3 of the
17 | License, or (at your option) any later version.
18 |
19 | This program is distributed in the hope that it will be useful,
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | GNU Affero General Public License for more details.
23 |
24 | You should have received a copy of the GNU Affero General Public License
25 | along with this program. If not, see .
26 |
27 | ----------------------------------------------------------------------------*/
28 | #include
29 | #include
30 | #include
31 | #include
32 |
33 | /*----------------------------------------------------------------------------*/
34 | #ifndef FALSE
35 | #define FALSE 0
36 | #endif /* !FALSE */
37 |
38 | #ifndef TRUE
39 | #define TRUE 1
40 | #endif /* !TRUE */
41 |
42 | /*----------------------------------------------------------------------------*/
43 | /* PI */
44 | #ifndef M_PI
45 | #define M_PI 3.14159265358979323846
46 | #endif /* !M_PI */
47 |
48 | /*----------------------------------------------------------------------------*/
49 | /* fatal error, print a message to standard error and exit
50 | */
51 | static void error(char * msg)
52 | {
53 | fprintf(stderr,"error: %s\n",msg);
54 | exit(EXIT_FAILURE);
55 | }
56 |
57 | /*----------------------------------------------------------------------------*/
58 | /* memory allocation, print an error and exit if fail
59 | */
60 | static void * xmalloc(size_t size)
61 | {
62 | void * p;
63 | if( size == 0 ) error("xmalloc: zero size");
64 | p = malloc(size);
65 | if( p == NULL ) error("xmalloc: out of memory");
66 | return p;
67 | }
68 |
69 | /*----------------------------------------------------------------------------*/
70 | /* compute a > b considering the rounding errors due to the representation
71 | of double numbers
72 | */
73 | static int greater(double a, double b)
74 | {
75 | if( a <= b ) return FALSE; /* trivial case, return as soon as possible */
76 |
77 | if( (a-b) < 1000 * DBL_EPSILON ) return FALSE;
78 |
79 | return TRUE; /* greater */
80 | }
81 |
82 | /*----------------------------------------------------------------------------*/
83 | /* Euclidean distance between x1,y1 and x2,y2
84 | */
85 | static double dist(double x1, double y1, double x2, double y2)
86 | {
87 | return sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) );
88 | }
89 |
90 | /*----------------------------------------------------------------------------*/
91 | /* compute a Gaussian kernel of length n, standard deviation sigma,
92 | and centered at value mean.
93 |
94 | for example, if mean=0.5, the Gaussian will be centered in the middle point
95 | between values kernel[0] and kernel[1].
96 |
97 | kernel must be allocated to a size n.
98 | */
99 | static void gaussian_kernel(double * kernel, int n, double sigma, double mean)
100 | {
101 | double sum = 0.0;
102 | double val;
103 | int i;
104 |
105 | /* check input */
106 | if( kernel == NULL ) error("gaussian_kernel: kernel not allocated");
107 | if( sigma <= 0.0 ) error("gaussian_kernel: sigma must be positive");
108 |
109 | /* compute Gaussian kernel */
110 | for(i=0; i 0.0 ) for(i=0; i=nx2) j -= nx2;
172 | if( j >= X ) j = nx2-1-j;
173 |
174 | val += image[j+y*X] * kernel[i];
175 | }
176 | tmp[x+y*X] = val;
177 | }
178 |
179 | /* y axis convolution */
180 | for(x=0; x=ny2) j -= ny2;
191 | if( j >= Y ) j = ny2-1-j;
192 |
193 | val += tmp[x+j*X] * kernel[i];
194 | }
195 | out[x+y*X] = val;
196 | }
197 |
198 | /* free memory */
199 | free( (void *) kernel );
200 | free( (void *) tmp );
201 |
202 | return out;
203 | }
204 |
205 | /*----------------------------------------------------------------------------*/
206 | /* return a score for chaining pixels 'from' to 'to', favoring closet point:
207 | = 0.0 invalid chaining
208 | > 0.0 valid forward chaining; the larger the value, the better the chaining
209 | < 0.0 valid backward chaining; the smaller the value, the better the chaining
210 |
211 | input:
212 | from, to the two pixel IDs to evaluate their potential chaining
213 | Ex[i], Ey[i] the sub-pixel position of point i, if i is an edge point;
214 | they take values -1,-1 if i is not an edge point
215 | Gx[i], Gy[i] the image gradient at pixel i
216 | X, Y the size of the image
217 | */
218 | static double chain( int from, int to, double * Ex, double * Ey,
219 | double * Gx, double * Gy, int X, int Y )
220 | {
221 | double dx,dy;
222 |
223 | /* check input */
224 | if( Ex == NULL || Ey == NULL || Gx == NULL || Gy == NULL )
225 | error("chain: invalid input");
226 | if( from < 0 || to < 0 || from >= X*Y || to >= X*Y )
227 | error("chain: one of the points is out the image");
228 |
229 | /* check that the points are different and valid edge points,
230 | otherwise return invalid chaining */
231 | if( from == to ) return 0.0; /* same pixel, not a valid chaining */
232 | if( Ex[from] < 0.0 || Ey[from] < 0.0 || Ex[to] < 0.0 || Ey[to] < 0.0 )
233 | return 0.0; /* one of them is not an edge point, not a valid chaining */
234 |
235 | /* in a good chaining, the gradient should be roughly orthogonal
236 | to the line joining the two points to be chained:
237 |
238 | Gx,Gy
239 | | ------> dx,dy
240 | | thus
241 | from x-------x to ---> Gy,-Gx (orthogonal to the gradient)
242 |
243 | when Gy * dx - Gx * dy > 0, it corresponds to a forward chaining,
244 | when Gy * dx - Gx * dy < 0, it corresponds to a backward chaining.
245 | (this choice is arbitrary)
246 |
247 | first check that the gradient at both points to be chained agree
248 | in one direction, otherwise return invalid chaining.
249 | */
250 | dx = Ex[to] - Ex[from];
251 | dy = Ey[to] - Ey[from];
252 | if( (Gy[from] * dx - Gx[from] * dy) * (Gy[to] * dx - Gx[to] * dy) <= 0.0 )
253 | return 0.0; /* incompatible gradient angles, not a valid chaining */
254 |
255 | /* return the chaining score: positive for forward chaining,
256 | negative for backwards. the score is the inverse of the distance
257 | to the chaining point, to give preference to closer points */
258 | if( (Gy[from] * dx - Gx[from] * dy) >= 0.0 )
259 | return 1.0 / dist(Ex[from],Ey[from],Ex[to],Ey[to]); /* forward chaining */
260 | else
261 | return -1.0 / dist(Ex[from],Ey[from],Ex[to],Ey[to]); /* backward chaining */
262 | }
263 |
264 | /*----------------------------------------------------------------------------*/
265 | /* compute the image gradient, giving its x and y components as well as the
266 | modulus. Gx, Gy, and modG must be already allocated.
267 | */
268 | static void compute_gradient( double * Gx, double * Gy, double * modG,
269 | double * image, int X, int Y )
270 | {
271 | int x,y;
272 |
273 | /* check input */
274 | if( Gx == NULL || Gy == NULL || modG == NULL || image == NULL )
275 | error("compute_gradient: invalid input");
276 |
277 | /* approximate image gradient using centered differences */
278 | for(x=1; x<(X-1); x++)
279 | for(y=1; y<(Y-1); y++)
280 | {
281 | Gx[x+y*X] = image[(x+1)+y*X] - image[(x-1)+y*X];
282 | Gy[x+y*X] = image[x+(y+1)*X] - image[x+(y-1)*X];
283 | modG[x+y*X] = sqrt( Gx[x+y*X] * Gx[x+y*X] + Gy[x+y*X] * Gy[x+y*X] );
284 | }
285 | }
286 |
287 | /*----------------------------------------------------------------------------*/
288 | /* compute sub-pixel edge points using adapted Canny and Devernay methods.
289 |
290 | input: Gx, Gy, and modG are the x and y components and modulus of the image
291 | gradient, respectively. X,Y is the image size.
292 |
293 | output: Ex and Ey will have the x and y sub-pixel coordinates of the edge
294 | points found, or -1 and -1 when not an edge point. Ex and Ey must be
295 | already allocated.
296 |
297 | a modified Canny non maximal suppression [1] is used to select edge points,
298 | and a modified Devernay sub-pixel correction [2] is used to improve the
299 | position accuracy. in both cases, the modification boils down to using only
300 | vertical or horizontal non maximal suppression and sub-pixel correction.
301 | no threshold is used on the gradient.
302 |
303 | [1] J.F. Canny, "A computational approach to edge detection",
304 | IEEE Transactions on Pattern Analysis and Machine Intelligence,
305 | vol.8, no.6, pp.679-698, 1986.
306 |
307 | [2] F. Devernay, "A Non-Maxima Suppression Method for Edge Detection
308 | with Sub-Pixel Accuracy", Rapport de recherche 2724, INRIA, Nov. 1995.
309 |
310 | the reason for this modification is that Devernay correction is inconsistent
311 | for some configurations at 45, 225, -45 or -225 degree. in edges that should
312 | go exactly in the middle of a pixels like (5 pixels drawn):
313 |
314 | ___
315 | |
316 | ___|
317 | |
318 | ___|
319 | |
320 | ___|
321 | |
322 | ___|
323 |
324 | the correction terms of both sides of the perfect edge are not compatible,
325 | leading to edge points with "oscillations" like:
326 |
327 | .
328 | .
329 |
330 | .
331 | .
332 |
333 | .
334 | .
335 |
336 | but the Devernay correction works very well and is very consistent when used
337 | to interpolate only along horizontal or vertical direction. this modified
338 | version requires that a pixel, to be an edge point, must be a local maximum
339 | horizontally or vertically, depending on the gradient orientation: if the
340 | x component of the gradient is larger than the y component, Gx > Gy, this
341 | means that the gradient is roughly horizontal and a horizontal maximum is
342 | required to be an edge point.
343 | */
344 | static void compute_edge_points( double * Ex, double * Ey, double * modG,
345 | double * Gx, double * Gy, int X, int Y )
346 | {
347 | int x,y,i;
348 |
349 | /* check input */
350 | if( Ex == NULL || Ey == NULL || modG == NULL || Gx == NULL || Gy == NULL )
351 | error("compute_edge_points: invalid input");
352 |
353 | /* initialize Ex and Ey as non-edge points for all pixels */
354 | for(i=0; i= |Gy|),
372 | => a "horizontal" (H) edge found
373 | else, if local vertical maxima of the gradient modulus and the
374 | gradient direction is more vertical (|Gx| <= |Gy|),
375 | => a "vertical" (V) edge found */
376 | /* it can happen that two neighbor pixels have equal value and are both
377 | maxima, for example when the edge is exactly between both pixels. in
378 | such cases, as an arbitrary convention, the edge is marked on the
379 | left one when an horizontal max or below when a vertical max. for
380 | this the conditions are L < mod >= R and D < mod >= U,
381 | respectively. the comparisons are done using the function greater()
382 | instead of the operators > or >= so numbers differing only due to
383 | rounding errors are considered equal */
384 | if( greater(mod,L) && !greater(R,mod) && gx >= gy ) Dx = 1; /* H */
385 | else if( greater(mod,D) && !greater(U,mod) && gx <= gy ) Dy = 1; /* V */
386 |
387 | /* Devernay sub-pixel correction [2]
388 |
389 | the edge point position is selected as the one of the maximum of a
390 | quadratic interpolation of the magnitude of the gradient along a
391 | unidimensional direction. the pixel must be a local maximum. so we
392 | have the values:
393 | . b
394 | a . |
395 | x = -1, |Gx| = a | | . c
396 | x = 0, |Gx| = b | | |
397 | x = 1, |Gx| = c ------------------> x
398 | -1 0 1
399 |
400 | the x position of the maximum of the parabola passing through
401 | (-1,a), (0,b), and (1,c) is
402 |
403 | offset = (a - c) / 2(a - 2b + c)
404 |
405 | and because b >= a and b >= c, -0.5 <= offset <= 0.5
406 | */
407 | if( Dx > 0 || Dy > 0 )
408 | {
409 | /* offset value is in [-0.5, 0.5] */
410 | double a = modG[ x-Dx + (y-Dy) * X ];
411 | double b = modG[ x + y * X ];
412 | double c = modG[ x+Dx + (y+Dy) * X ];
413 | double offset = 0.5 * (a - c) / (a - b - b + c);
414 |
415 | /* store edge point */
416 | Ex[x+y*X] = x + offset * Dx;
417 | Ey[x+y*X] = y + offset * Dy;
418 | }
419 | }
420 | }
421 |
422 | /*----------------------------------------------------------------------------*/
423 | /* chain edge points
424 |
425 | input: Ex and Ey are the sub-pixel coordinates when an edge point is present
426 | or -1,-1 otherwise. Gx, Gy and modG are the x and y components and the
427 | modulus of the image gradient, respectively. X,Y is the image size.
428 |
429 | output: next and prev will contain the number of next and previous edge
430 | points in the chain. when not chained in one of the directions, the
431 | corresponding value is set to -1. next and prev must be allocated
432 | before calling.
433 | */
434 | static void chain_edge_points( int * next, int * prev, double * Ex, double * Ey,
435 | double * Gx, double * Gy, int X, int Y )
436 | {
437 | int x,y,i,j,alt;
438 |
439 | /* check input */
440 | if( next==NULL || prev==NULL || Ex==NULL || Ey==NULL || Gx==NULL || Gy==NULL )
441 | error("chain_edge_points: invalid input");
442 |
443 | /* initialize next and prev as non linked */
444 | for(i=0; i= 0.0 && Ey[x+y*X] >= 0.0 ) /* must be an edge point */
450 | {
451 | int from = x+y*X; /* edge point to be chained */
452 | double fwd_s = 0.0; /* score of best forward chaining */
453 | double bck_s = 0.0; /* score of best backward chaining */
454 | int fwd = -1; /* edge point of best forward chaining */
455 | int bck = -1; /* edge point of best backward chaining */
456 |
457 | /* try all neighbors two pixels apart or less.
458 |
459 | looking for candidates for chaining two pixels apart, in most
460 | such cases, is enough to obtain good chains of edge points that
461 | accurately describes the edge.
462 | */
463 | for(i=-2; i<=2; i++)
464 | for(j=-2; j<=2; j++)
465 | {
466 | int to = x+i + (y+j)*X; /* candidate edge point to be chained */
467 | double s = chain(from,to,Ex,Ey,Gx,Gy,X,Y); /* score from-to */
468 |
469 | if( s > fwd_s ) /* a better forward chaining found */
470 | {
471 | fwd_s = s; /* set the new best forward chaining */
472 | fwd = to;
473 | }
474 | if( s < bck_s ) /* a better backward chaining found */
475 | {
476 | bck_s = s; /* set the new best backward chaining */
477 | bck = to;
478 | }
479 | }
480 |
481 | /* before making the new chain, check whether the target was
482 | already chained and in that case, whether the alternative
483 | chaining is better than the proposed one.
484 |
485 | x alt x alt
486 | \ /
487 | \ /
488 | from x---------x fwd bck x---------x from
489 |
490 | we know that the best forward chain starting at from is from-fwd.
491 | but it is possible that there is an alternative chaining arriving
492 | at fwd that is better, such that alt-fwd is to be preferred to
493 | from-fwd. an analogous situation is possible in backward chaining,
494 | where an alternative link bck-alt may be better than bck-from.
495 |
496 | before making the new link, check if fwd/bck are already chained,
497 | and in such case compare the scores of the proposed chaining to
498 | the existing one, and keep only the best of the two.
499 |
500 | there is an undesirable aspect of this procedure: the result may
501 | depend on the order of exploration. consider the following
502 | configuration:
503 |
504 | a x-------x b
505 | /
506 | /
507 | c x---x d with score(a-b) < score(c-b) < score(c-d)
508 | or equivalently ||a-b|| > ||b-c|| > ||c-d||
509 |
510 | let us consider two possible orders of exploration.
511 |
512 | order: a,b,c
513 | we will first chain a-b when exploring a. when analyzing the
514 | backward links of b, we will prefer c-b, and a-b will be unlinked.
515 | finally, when exploring c, c-d will be preferred and c-b will be
516 | unlinked. the result is just the chaining c-d.
517 |
518 | order: c,b,a
519 | we will first chain c-d when exploring c. then, when exploring
520 | the backward connections of b, c-b will be the preferred link;
521 | but because c-d exists already and has a better score, c-b
522 | cannot be linked. finally, when exploring a, the link a-b will
523 | be created because there is no better backward linking of b.
524 | the result is two chainings: c-d and a-b.
525 |
526 | we did not found yet a simple algorithm to solve this problem. by
527 | simple, we mean an algorithm without two passes or the need to
528 | re-evaluate the chaining of points where one link is cut.
529 |
530 | for most edge points, there is only one possible chaining and this
531 | problem does not arise. but it does happen and a better solution
532 | is desirable.
533 | */
534 | if( fwd >= 0 && next[from] != fwd &&
535 | ((alt=prev[fwd]) < 0 || chain(alt,fwd,Ex,Ey,Gx,Gy,X,Y) < fwd_s) )
536 | {
537 | if( next[from] >= 0 ) /* remove previous from-x link if one */
538 | prev[next[from]] = -1; /* only prev requires explicit reset */
539 | next[from] = fwd; /* set next of from-fwd link */
540 | if( alt >= 0 ) /* remove alt-fwd link if one */
541 | next[alt] = -1; /* only next requires explicit reset */
542 | prev[fwd] = from; /* set prev of from-fwd link */
543 | }
544 | if( bck >= 0 && prev[from] != bck &&
545 | ((alt=next[bck]) < 0 || chain(alt,bck,Ex,Ey,Gx,Gy,X,Y) > bck_s ) )
546 | {
547 | if( alt >= 0 ) /* remove bck-alt link if one */
548 | prev[alt] = -1; /* only prev requires explicit reset */
549 | next[bck] = from; /* set next of bck-from link */
550 | if( prev[from] >= 0 ) /* remove previous x-from link if one */
551 | next[prev[from]] = -1; /* only next requires explicit reset */
552 | prev[from] = bck; /* set prev of bck-from link */
553 | }
554 | }
555 | }
556 |
557 | /*----------------------------------------------------------------------------*/
558 | /* apply Canny thresholding with hysteresis
559 |
560 | next and prev contain the number of next and previous edge points in the
561 | chain or -1 when not chained. modG is modulus of the image gradient. X,Y is
562 | the image size. th_h and th_l are the high and low thresholds, respectively.
563 |
564 | this function modifies next and prev, removing chains not satisfying the
565 | thresholds.
566 | */
567 | static void thresholds_with_hysteresis( int * next, int * prev,
568 | double * modG, int X, int Y,
569 | double th_h, double th_l )
570 | {
571 | int * valid;
572 | int i,j,k;
573 |
574 | /* check input */
575 | if( next == NULL || prev == NULL || modG == NULL )
576 | error("thresholds_with_hysteresis: invalid input");
577 |
578 | /* get memory */
579 | valid = (int *) xmalloc( X * Y * sizeof(int) );
580 | for(i=0; i=0 or next[i]>=0 implies an edge point */
584 | if( (prev[i] >= 0 || next[i] >= 0) && !valid[i] && modG[i] >= th_h )
585 | {
586 | valid[i] = TRUE; /* mark as valid the new point */
587 |
588 | /* follow the chain of edge points forwards */
589 | for(j=i; j>=0 && (k=next[j])>=0 && !valid[k]; j=next[j])
590 | if( modG[k] < th_l )
591 | {
592 | next[j] = -1; /* cut the chain when the point is below th_l */
593 | prev[k] = -1; /* j must be assigned to next[j] and not k,
594 | so the loop is chained in this case */
595 | }
596 | else
597 | valid[k] = TRUE; /* otherwise mark the new point as valid */
598 |
599 | /* follow the chain of edge points backwards */
600 | for(j=i; j>=0 && (k=prev[j])>=0 && !valid[k]; j=prev[j])
601 | if( modG[k] < th_l )
602 | {
603 | prev[j] = -1; /* cut the chain when the point is below th_l */
604 | next[k] = -1; /* j must be assigned to prev[j] and not k,
605 | so the loop is chained in this case */
606 | }
607 | else
608 | valid[k] = TRUE; /* otherwise mark the new point as valid */
609 | }
610 |
611 | /* remove any remaining non-valid chained point */
612 | for(i=0; i=0 or next[i]>=0 implies edge point */
613 | if( (prev[i] >= 0 || next[i] >= 0) && !valid[i] )
614 | prev[i] = next[i] = -1;
615 |
616 | /* free memory */
617 | free( (void *) valid );
618 | }
619 |
620 | /*----------------------------------------------------------------------------*/
621 | /* create a list of chained edge points composed of 3 lists
622 | x, y and curve_limits; it also computes N (the number of edge points) and
623 | M (the number of curves).
624 |
625 | x[i] and y[i] (0<=i=0 or next[i]>=0 implies an edge point */
671 | if( prev[i] >= 0 || next[i] >= 0 )
672 | {
673 | /* a new chain found, set chain starting index to the current point
674 | and then increase the curve counter */
675 | (*curve_limits)[*M] = *N;
676 | ++(*M);
677 |
678 | /* set k to the beginning of the chain, or to i if closed curve */
679 | for(k=i; (n=prev[k])>=0 && n!=i; k=n);
680 |
681 | /* follow the chain of edge points starting on k */
682 | do
683 | {
684 | /* store the current point coordinates in the output lists */
685 | (*x)[*N] = Ex[k];
686 | (*y)[*N] = Ey[k];
687 | ++(*N);
688 |
689 | n = next[k]; /* save the id of the next point in the chain */
690 |
691 | next[k] = -1; /* unlink chains from k so it is not used again */
692 | prev[k] = -1;
693 |
694 | /* for closed curves, the initial point is included again as
695 | the last point of the chain. actually, testing if the first
696 | and last points are equal is the only way to know that it is
697 | a closed curve.
698 |
699 | to understand that this code actually repeats the first point,
700 | consider a closed chain as follows: a--b
701 | | |
702 | d--c
703 |
704 | let us say that the algorithm starts by point a. it will store
705 | the coordinates of point a and then unlink a-b. then, will store
706 | point b and unlink b-c, and so on. but the link d-a is still
707 | there. (point a is no longer pointing backwards to d, because
708 | both links are removed at each step. but d is indeed still
709 | pointing to a.) so it will arrive at point a again and store its
710 | coordinates again as last point. there, it cannot continue
711 | because the link a-b was removed, there would be no next point,
712 | k would be -1 and the curve is finished.
713 | */
714 |
715 | k = n; /* set the current point to the next in the chain */
716 | }
717 | while( k >= 0 ); /* continue while there is a next point in the chain */
718 | }
719 | (*curve_limits)[*M] = *N; /* store end of the last chain */
720 | }
721 |
722 | /*----------------------------------------------------------------------------*/
723 | /* chained, sub-pixel edge detector. based on a modified Canny non-maximal
724 | suppression and a modified Devernay sub-pixel correction.
725 |
726 | input:
727 |
728 | image : the input image
729 | X,Y : the size of the input image
730 | sigma : standard deviation sigma for the Gaussian filtering
731 | (if sigma=0 no filtering is performed)
732 | th_h : high gradient threshold in Canny's hysteresis
733 | th_l : low gradient threshold in Canny's hysteresis
734 |
735 | output:
736 |
737 | x,y : lists of sub-pixel coordinates of edge points
738 | curve_limits : the limits of each curve in lists x and y
739 | N : number of edge points
740 | M : number of curves
741 |
742 | the input is a XxY graylevel image given as a pointer to an array of doubles
743 | such that image[x+y*X] is the value at coordinates x,y
744 | (for 0 <= x < X and 0 <= y < Y).
745 |
746 | the output are the chained edge points given as 3 allocated lists: x, y and
747 | curve_limits. also the numbers N (size of lists x and y) and M (number of
748 | curves).
749 |
750 | x[i] and y[i] (0<=i,
12 | Gregory Randall
13 |
14 | This program is free software: you can redistribute it and/or modify
15 | it under the terms of the GNU Affero General Public License as
16 | published by the Free Software Foundation, either version 3 of the
17 | License, or (at your option) any later version.
18 |
19 | This program is distributed in the hope that it will be useful,
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | GNU Affero General Public License for more details.
23 |
24 | You should have received a copy of the GNU Affero General Public License
25 | along with this program. If not, see .
26 |
27 | ----------------------------------------------------------------------------*/
28 | #ifndef DEVERNAY_HEADER
29 | #define DEVERNAY_HEADER
30 |
31 | /*----------------------------------------------------------------------------*/
32 | #define DEVERNAY_VERSION "1.0 (October 10, 2017)"
33 |
34 | /*----------------------------------------------------------------------------*/
35 | /* chained, sub-pixel edge detector. based on a modified Canny non-maximal
36 | suppression and a modified Devernay sub-pixel correction.
37 |
38 | input:
39 |
40 | image : the input image
41 | X,Y : the size of the input image
42 | sigma : standard deviation sigma for the Gaussian filtering
43 | (if sigma=0 no filtering is performed)
44 | th_h : high gradient threshold in Canny's hysteresis
45 | th_l : low gradient threshold in Canny's hysteresis
46 |
47 | output:
48 |
49 | x,y : lists of sub-pixel coordinates of edge points
50 | curve_limits : the limits of each curve in lists x and y
51 | N : number of edge points
52 | M : number of curves
53 |
54 | the input is a XxY graylevel image given as a pointer to an array of doubles
55 | such that image[x+y*X] is the value at coordinates x,y
56 | (for 0 <= x < X and 0 <= y < Y).
57 |
58 | the output are the chained edge points given as 3 allocated lists: x, y and
59 | curve_limits. also the numbers N (size of lists x and y) and M (number of
60 | curves).
61 |
62 | x[i] and y[i] (0<=i,
6 | Gregory Randall
7 |
8 | This program is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU Affero General Public License as
10 | published by the Free Software Foundation, either version 3 of the
11 | License, or (at your option) any later version.
12 |
13 | This program is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU Affero General Public License for more details.
17 |
18 | You should have received a copy of the GNU Affero General Public License
19 | along with this program. If not, see .
20 |
21 | ----------------------------------------------------------------------------*/
22 | #include
23 | #include
24 | #include
25 | #include "io.h"
26 | #include "devernay.h"
27 |
28 | /*----------------------------------------------------------------------------*/
29 | /* print usage and exit
30 | */
31 | static void usage(void)
32 | {
33 | fprintf(stderr,"devernay %s\n",DEVERNAY_VERSION);
34 | fprintf(stderr,"Copyright (c) 2016-2017 ");
35 | fprintf(stderr,"Rafael Grompone von Gioi and Gregory Randall\n\n");
36 | fprintf(stderr,"usage: devernay [-s S] [-h H] [-l L] [-w W] [-t T] ");
37 | fprintf(stderr,"[-p P] [-g G]\n\n");
38 | fprintf(stderr,"image PGM or ASC file formats are handled\n");
39 | fprintf(stderr,"-s S set the blur standard deviation ");
40 | fprintf(stderr,"(default S=0.0 -> no blurring)\n");
41 | fprintf(stderr,"-h H set high threshold (default H=0.0)\n");
42 | fprintf(stderr,"-l L set low threshold (default L=0.0)\n");
43 | fprintf(stderr,"-w W set line width in PDF and SVG to W (default W=1.3)\n");
44 | fprintf(stderr,"-t T write TXT output to file T\n");
45 | fprintf(stderr,"-p P write PDF output to file P\n");
46 | fprintf(stderr,"-g G write SVG output to file G\n\n");
47 | fprintf(stderr,"examples: devernay image.pgm -p output.pdf\n");
48 | fprintf(stderr," devernay image.pgm -t output.txt -p output.pdf ");
49 | fprintf(stderr,"-g output.svg\n");
50 | fprintf(stderr," devernay image.pgm -p output.pdf ");
51 | fprintf(stderr,"-s 1.0 -l 5.0 -h 15.0 -w 0.5\n");
52 |
53 | exit(EXIT_FAILURE);
54 | }
55 |
56 | /*----------------------------------------------------------------------------*/
57 | /* get an optional parameter from arguments
58 |
59 | if found, the value is returned and it is removed from the list of arguments.
60 | adapted from pick_option by Enric Meinhardt-Llopis.
61 |
62 | example: if arguments are "command -p 123 input.txt",
63 | char * p = get_option(&argc,&argv,"-p","0");
64 | will give "123" in p and leave arguments as "command input.txt"
65 | */
66 | static char * get_option(int * argc, char *** argv, char * opt, char * def)
67 | {
68 | int i,j;
69 |
70 | for(i=0; i<(*argc-1); i++) /* last argument cannot have an optional value */
71 | if( strcmp( (*argv)[i], opt ) == 0 ) /* option opt found */
72 | {
73 | char * r = (*argv)[i+1]; /* save the optional value to return */
74 | for(j=i; j < (*argc-2); j++) /* shift arguments to remove opt+value */
75 | (*argv)[j] = (*argv)[j+2];
76 | *argc -= 2; /* decrease the number of arguments in 2, opt+value */
77 | return r; /* return the value found for option opt */
78 | }
79 | return def; /* option not found, return the default value */
80 | }
81 |
82 | /*----------------------------------------------------------------------------*/
83 | /* main */
84 | /*----------------------------------------------------------------------------*/
85 | int main(int argc, char ** argv)
86 | {
87 | double * image; /* image of size X,Y */
88 | double * x; /* x[n] y[n] coordinates of result contour point n */
89 | double * y;
90 | int * curve_limits; /* limits of the curves in the x[] and y[] */
91 | int X,Y,N,M; /* result: N contour points, forming M curves */
92 | char * txt_out = get_option(&argc,&argv,"-t",NULL); /* txt filename */
93 | char * pdf_out = get_option(&argc,&argv,"-p",NULL); /* pdf filename */
94 | char * svg_out = get_option(&argc,&argv,"-g",NULL); /* svg filename */
95 | double S = atof(get_option(&argc,&argv,"-s","0.0")); /* default sigma=0 */
96 | double H = atof(get_option(&argc,&argv,"-h","0.0")); /* default th_h=0 */
97 | double L = atof(get_option(&argc,&argv,"-l","0.0")); /* default th_l=0 */
98 | double W = atof(get_option(&argc,&argv,"-w","1.3")); /* default W=1.3 */
99 |
100 | /* read input */
101 | if( argc != 2 ) usage();
102 | image = read_image(argv[1],&X,&Y);
103 |
104 | /* call Canny/Devernay algorithm */
105 | devernay(&x, &y, &N, &curve_limits, &M, image, X, Y, S, H, L);
106 |
107 | /* write required outputs, TXT and/or PDF */
108 | if( txt_out != NULL ) write_curves_txt(x,y,curve_limits,M,txt_out);
109 | if( pdf_out != NULL ) write_curves_pdf(x,y,curve_limits,M,pdf_out,X,Y,W);
110 | if( svg_out != NULL ) write_curves_svg(x,y,curve_limits,M,svg_out,X,Y,W);
111 |
112 | /* free memory */
113 | free( (void *) image );
114 | free( (void *) curve_limits );
115 | free( (void *) x );
116 | free( (void *) y );
117 |
118 | return EXIT_SUCCESS;
119 | }
120 | /*----------------------------------------------------------------------------*/
121 |
--------------------------------------------------------------------------------
/C/devernay_1.0/image_out.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anttad/SubpixelCircleDetection/912252d4a305d71f800ed39b3ce87946251cb675/C/devernay_1.0/image_out.pdf
--------------------------------------------------------------------------------
/C/devernay_1.0/io.c:
--------------------------------------------------------------------------------
1 | /*----------------------------------------------------------------------------
2 |
3 | I/O functions: read PGM or ASC images and curve output to PDF or TXT files.
4 |
5 | Copyright (c) 2016-2017 rafael grompone von gioi ,
6 | Gregory Randall
7 |
8 | This program is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU Affero General Public License as
10 | published by the Free Software Foundation, either version 3 of the
11 | License, or (at your option) any later version.
12 |
13 | This program is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU Affero General Public License for more details.
17 |
18 | You should have received a copy of the GNU Affero General Public License
19 | along with this program. If not, see .
20 |
21 | ----------------------------------------------------------------------------*/
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | /*----------------------------------------------------------------------------*/
29 | #ifndef FALSE
30 | #define FALSE 0
31 | #endif /* !FALSE */
32 |
33 | #ifndef TRUE
34 | #define TRUE 1
35 | #endif /* !TRUE */
36 |
37 | /*----------------------------------------------------------------------------*/
38 | /* fatal error, print a message to standard error and exit
39 | */
40 | static void error(char * msg)
41 | {
42 | fprintf(stderr,"error: %s\n",msg);
43 | exit(EXIT_FAILURE);
44 | }
45 |
46 | /*----------------------------------------------------------------------------*/
47 | /* memory allocation, print an error and exit if fail
48 | */
49 | static void * xmalloc(size_t size)
50 | {
51 | void * p;
52 | if( size == 0 ) error("xmalloc input: zero size");
53 | p = malloc(size);
54 | if( p == NULL ) error("out of memory");
55 | return p;
56 | }
57 |
58 | /*----------------------------------------------------------------------------*/
59 | /* open file, print an error and exit if fail
60 | */
61 | static FILE * xfopen(const char * path, const char * mode)
62 | {
63 | FILE * f = fopen(path,mode);
64 | if( f == NULL )
65 | {
66 | fprintf(stderr,"error: unable to open file '%s'\n",path);
67 | exit(EXIT_FAILURE);
68 | }
69 | return f;
70 | }
71 |
72 | /*----------------------------------------------------------------------------*/
73 | /* close file, print an error and exit if fail
74 | */
75 | static int xfclose(FILE * f)
76 | {
77 | if( fclose(f) == EOF ) error("unable to close file");
78 | return 0;
79 | }
80 |
81 | /*----------------------------------------------------------------------------*/
82 | /* skip white characters and comments in a PGM file
83 | */
84 | static void skip_whites_and_comments(FILE * f)
85 | {
86 | int c;
87 | do
88 | {
89 | while(isspace(c=getc(f))); /* skip spaces */
90 | if(c=='#') /* skip comments */
91 | while( c!='\n' && c!='\r' && c!=EOF )
92 | c=getc(f);
93 | }
94 | while( c == '#' || isspace(c) );
95 | if( c != EOF && ungetc(c,f) == EOF )
96 | error("unable to 'ungetc' while reading PGM file.");
97 | }
98 |
99 | /*----------------------------------------------------------------------------*/
100 | /* read a number in ASCII from a PGM file
101 | */
102 | static int get_num(FILE * f)
103 | {
104 | int num,c;
105 |
106 | while(isspace(c=getc(f)));
107 | if(!isdigit(c)) error("corrupted PGM or PPM file.");
108 | num = c - '0';
109 | while( isdigit(c=getc(f)) ) num = 10 * num + c - '0';
110 | if( c != EOF && ungetc(c,f) == EOF )
111 | error("unable to 'ungetc' while reading PGM file.");
112 |
113 | return num;
114 | }
115 |
116 | /*----------------------------------------------------------------------------*/
117 | /* read a PGM image file
118 | */
119 | double * read_pgm_image(char * name, int * X, int * Y)
120 | {
121 | FILE * f;
122 | int i,n,depth,bin=FALSE;
123 | double * image;
124 |
125 | /* open file */
126 | f = xfopen(name,"rb"); /* open to read as a binary file (b option). otherwise,
127 | in some systems, it may behave differently */
128 |
129 | /* read header */
130 | if( getc(f) != 'P' ) error("not a PGM file!");
131 | if( (n=getc(f)) == '2' ) bin = FALSE;
132 | else if( n == '5' ) bin = TRUE;
133 | else error("not a PGM file!");
134 | skip_whites_and_comments(f);
135 | *X = get_num(f); /* X size */
136 | skip_whites_and_comments(f);
137 | *Y = get_num(f); /* Y size */
138 | skip_whites_and_comments(f);
139 | depth = get_num(f); /* pixel depth */
140 | if( depth < 0 ) error("pixel depth < 0, unrecognized PGM file");
141 | if( bin && depth > 255 ) error("pixel depth > 255, unrecognized PGM file");
142 | /* white before data */
143 | if(!isspace(getc(f))) error("corrupted PGM file.");
144 |
145 | /* get memory */
146 | image = (double *) xmalloc( *X * *Y * sizeof(double) );
147 |
148 | /* read data */
149 | for(i=0; i<(*X * *Y); i++)
150 | image[i] = (double) (bin ? getc(f) : get_num(f));
151 |
152 | /* close file */
153 | xfclose(f);
154 |
155 | /* return image */
156 | return image;
157 | }
158 |
159 | /*----------------------------------------------------------------------------*/
160 | /* read a 2D ASC format file
161 | */
162 | double * read_asc_file(char * name, int * X, int * Y)
163 | {
164 | FILE * f;
165 | int i,n,Z,C;
166 | double val;
167 | double * image;
168 |
169 | /* open file */
170 | f = xfopen(name,"rb"); /* open to read as a binary file (b option). otherwise,
171 | in some systems, it may behave differently */
172 |
173 | /* read header */
174 | n = fscanf(f,"%d%*c%d%*c%d%*c%d",X,Y,&Z,&C);
175 | if( n!=4 || *X<=0 || *Y<=0 || Z<=0 || C<=0 ) error("invalid ASC file");
176 |
177 | /* only gray level images are handled */
178 | if( Z!=1 || C!=1 ) error("only single channel ASC files are handled");
179 |
180 | /* get memory */
181 | image = (double *) xmalloc( *X * *Y * Z * C * sizeof(double) );
182 |
183 | /* read data */
184 | for(i=0; i<(*X * *Y * Z * C); i++)
185 | {
186 | n = fscanf(f,"%lf",&val);
187 | if( n!=1 ) error("invalid ASC file");
188 | image[i] = val;
189 | }
190 |
191 | /* close file */
192 | xfclose(f);
193 |
194 | return image;
195 | }
196 |
197 | /*----------------------------------------------------------------------------*/
198 | /* read an image from a file in ASC or PGM formats
199 | */
200 | double * read_image(char * name, int * X, int * Y)
201 | {
202 | int n = (int) strlen(name);
203 | char * ext = name+n-4;
204 |
205 | if( n>=4 && ( strcmp(ext,".asc")==0 || strcmp(ext,".ASC")==0) )
206 | return read_asc_file(name,X,Y);
207 |
208 | return read_pgm_image(name,X,Y);
209 | }
210 |
211 | /*----------------------------------------------------------------------------*/
212 | /* write curves into a PDF file. the output is PDF version 1.4 as described in
213 | "PDF Reference, third edition" by Adobe Systems Incorporated, 2001
214 | */
215 | void write_curves_pdf( double * x, double * y, int * curve_limits, int M,
216 | char * filename, int X, int Y, double width )
217 | {
218 | FILE * pdf;
219 | long start1,start2,start3,start4,start5,startxref,stream_len;
220 | int i,j,k;
221 |
222 | /* check input */
223 | if( filename == NULL ) error("invalid filename in write_curves_pdf");
224 | if( M > 0 && ( x == NULL || y == NULL || curve_limits == NULL ) )
225 | error("invalid curves data in write_curves_pdf");
226 | if( X <= 0 || Y <= 0 ) error("invalid image size in write_curves_pdf");
227 |
228 | /* open file */
229 | pdf = xfopen(filename,"wb"); /* open to write as a binary file (b option).
230 | otherwise, in some systems,
231 | it may behave differently */
232 |
233 | /* PDF header */
234 | fprintf(pdf,"%%PDF-1.4\n");
235 | /* The following PDF comment contains characters with ASCII codes greater
236 | than 128. This helps to classify the file as containing 8-bit binary data.
237 | See "PDF Reference" p.63. */
238 | fprintf(pdf,"%%%c%c%c%c\n",0xe2,0xe3,0xcf,0xd3);
239 |
240 | /* Catalog, Pages and Page objects */
241 | start1 = ftell(pdf);
242 | fprintf(pdf,"1 0 obj\n<>\n");
243 | fprintf(pdf,"endobj\n");
244 | start2 = ftell(pdf);
245 | fprintf(pdf,"2 0 obj\n<> /MediaBox [0 0 %d %d]>>\nendobj\n",X,Y);
247 | start3 = ftell(pdf);
248 | fprintf(pdf,"3 0 obj\n");
249 | fprintf(pdf,"<>\n");
250 | fprintf(pdf,"endobj\n");
251 |
252 | /* Contents object - graphic contents */
253 | start4 = ftell(pdf);
254 | fprintf(pdf,"4 0 obj\n<>\n"); /* indirect length in obj 5 */
255 | fprintf(pdf,"stream\n");
256 | stream_len = ftell(pdf);
257 | fprintf(pdf,"%.4f w\n",width); /* set line width */
258 | for(k=0; k>\n");
306 | fprintf(pdf,"startxref\n");
307 | fprintf(pdf,"%ld\n",startxref);
308 | fprintf(pdf,"%%%%EOF\n");
309 |
310 | /* close file */
311 | xfclose(pdf);
312 | }
313 |
314 | /*----------------------------------------------------------------------------*/
315 | /* write curves into a TXT file
316 | */
317 | void write_curves_txt( double * x, double * y, int * curve_limits, int M,
318 | char * filename )
319 | {
320 | FILE * txt;
321 | int i,k;
322 |
323 | /* check input */
324 | if( filename == NULL ) error("invalid filename in write_curves_txt");
325 | if( M > 0 && ( x == NULL || y == NULL || curve_limits == NULL ) )
326 | error("invalid curves data in write_curves_txt");
327 |
328 | /* open file */
329 | txt = xfopen(filename,"wb"); /* open to write as a binary file (b option).
330 | otherwise, in some systems,
331 | it may behave differently */
332 |
333 | /* write curves */
334 | for(k=0; k 0 && ( x == NULL || y == NULL || curve_limits == NULL ) )
357 | error("invalid curves data in write_curves_svg");
358 | if( X <= 0 || Y <= 0 ) error("invalid image size in write_curves_svg");
359 |
360 | /* open file */
361 | svg = xfopen(filename,"wb"); /* open to write as a binary file (b option).
362 | otherwise, in some systems,
363 | it may behave differently */
364 |
365 | /* write SVG header */
366 | fprintf(svg,"\n");
367 | fprintf(svg,"\n");
369 | fprintf(svg,"\n");
385 | xfclose(svg);
386 | }
387 | /*----------------------------------------------------------------------------*/
388 |
--------------------------------------------------------------------------------
/C/devernay_1.0/io.h:
--------------------------------------------------------------------------------
1 | /*----------------------------------------------------------------------------
2 |
3 | I/O functions: read PGM or ASC images and curve output to PDF or TXT files.
4 |
5 | Copyright (c) 2016-2017 rafael grompone von gioi ,
6 | Gregory Randall
7 |
8 | This program is free software: you can redistribute it and/or modify
9 | it under the terms of the GNU Affero General Public License as
10 | published by the Free Software Foundation, either version 3 of the
11 | License, or (at your option) any later version.
12 |
13 | This program is distributed in the hope that it will be useful,
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | GNU Affero General Public License for more details.
17 |
18 | You should have received a copy of the GNU Affero General Public License
19 | along with this program. If not, see .
20 |
21 | ----------------------------------------------------------------------------*/
22 | #ifndef IO_HEADER
23 | #define IO_HEADER
24 |
25 | /*----------------------------------------------------------------------------*/
26 | /* read a PGM image file
27 | */
28 | double * read_pgm_image(char * name, int * X, int * Y);
29 |
30 | /*----------------------------------------------------------------------------*/
31 | /* read a 2D ASC format file
32 | */
33 | double * read_asc_file(char * name, int * X, int * Y);
34 |
35 | /*----------------------------------------------------------------------------*/
36 | /* read an image from a file in ASC or PGM formats
37 | */
38 | double * read_image(char * name, int * X, int * Y);
39 |
40 | /*----------------------------------------------------------------------------*/
41 | /* write curves into a PDF file. the output is PDF version 1.4 as described in
42 | "PDF Reference, third edition" by Adobe Systems Incorporated, 2001
43 | */
44 | void write_curves_pdf( double * x, double * y, int * curve_limits, int M,
45 | char * filename, int X, int Y, double width );
46 |
47 | /*----------------------------------------------------------------------------*/
48 | /* write curves into a TXT file
49 | */
50 | void write_curves_txt( double * x, double * y, int * curve_limits, int M,
51 | char * filename );
52 |
53 | /*----------------------------------------------------------------------------*/
54 | /* write curves into a SVG file
55 | */
56 | void write_curves_svg( double * x, double * y, int * curve_limits, int M,
57 | char * filename, int X, int Y, double width );
58 |
59 | #endif /* !IO_HEADER */
60 | /*----------------------------------------------------------------------------*/
61 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Antoine Tadros
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SubpixelCircleDetection
2 | Code for ISPRS 2020 article "Circular-Shaped Object Detection in Low Resolution Satellite Images"
3 |
4 |
5 | (still formating the code)
6 |
7 |
8 | python code:
9 | `iso_th_devernay.py`: Isoperimetric thresholding with Canny-Devernay's edge extraction code
10 | `hough_devernay.py`: Isoperimetric thresholding with Canny-Devernay's edge extraction code
11 |
12 |
13 | The ELSDc code is available here : **https://github.com/viorik/ELSDc**
14 |
15 |
16 |
17 | The level-line extraction code is available in **interpolated_shapes.zip**
18 |
19 |
--------------------------------------------------------------------------------
/apply_tophat.py:
--------------------------------------------------------------------------------
1 | import tifffile
2 | import skimage.draw
3 | import imageio
4 | import numpy as np
5 | import scipy.ndimage
6 |
7 | def load_image(filepath, bands=['B02', 'B03', 'B04']):
8 | fim_np = []
9 | for band in bands:
10 | im_np = tifffile.imread(filepath.replace('(:band)', band))
11 | fim_np.append(im_np)
12 |
13 | fim_np = np.array(fim_np)
14 | fim_np = np.moveaxis(fim_np, 0, 2)
15 | return fim_np
16 |
17 | def minimum_of_directional_tophat_bottomhat(im_np, size, method='tophat'): # method='tophat', 'bottomhat'
18 | x = list(range(0, size)) + [size - 1] * size
19 | y = [0] * size + list(range(0, size))
20 |
21 | fims_np = []
22 | for i in range(len(x)):
23 | se_np = np.zeros((size, size), dtype=bool)
24 | rr, cc = skimage.draw.line(y[i], x[i], size - 1 - y[i], size - 1 - x[i])
25 | se_np[rr, cc] = True
26 |
27 |
28 | #imageio.imsave('tmp/' + str(i) + '.png', se_np.astype(float))
29 |
30 | filtered_np = np.zeros(im_np.shape)
31 | for j in range(im_np.shape[2]):
32 | if (method == 'tophat'):
33 | filtered_np[:,:,j] = im_np[:,:,j] - scipy.ndimage.grey_opening(im_np[:,:,j], size=(size,size), footprint=se_np)
34 | else:
35 | filtered_np[:,:,j] = scipy.ndimage.grey_closing(im_np[:,:,j], size=(size,size), footprint=se_np) - im_np[:,:,j]
36 | # tifffile.imsave('tmp/f_' + str(i) + '.tif', filtered_np)
37 | fims_np.append(filtered_np)
38 |
39 | fims_np = np.array(fims_np)
40 | fims_np = np.min(fims_np, axis=0)
41 |
42 | fims_grey_np = np.min(fims_np, axis=2)
43 | #tifffile.imsave('out_grey.tif', fims_np)
44 |
45 | return fims_np, fims_grey_np
46 |
47 | #im_np = load_image('data/2019-01-20_S2B_orbit_032_tile_50SNJ_L1C_band_(:band).tif')
48 | #fims_np, fims_grey_np = minimum_of_directional_tophat_bottomhat(im_np, 11)
49 | #tifffile.imsave('tophat_per_channel.tif', fims_np)
50 | #tifffile.imsave('tophat_per_channel_min_all_channels.tif', fims_grey_np)
--------------------------------------------------------------------------------
/compare.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import scipy.spatial.distance
3 |
4 | # listes [[x, y], [x, y], [x, y]...]
5 | def precision_recall(dets, gts, tolerance=3):
6 | dists = scipy.spatial.distance.cdist(dets, gts)
7 | idx = np.argsort(dists.flatten())
8 | ys = (idx / gts.shape[0]).astype(int)
9 | xs = (idx % gts.shape[0])
10 |
11 | affected_np = -np.ones(dets.shape[0], dtype=int)
12 | used_np = -np.ones(gts.shape[0], dtype=int)
13 | for i in range(ys.shape[0]):
14 | y = ys[i]
15 | x = xs[i]
16 | if (dists[y, x] > tolerance):
17 | break
18 | if (used_np[x] >= 0):
19 | continue
20 |
21 | affected_np[y] = x
22 | used_np[x] = y
23 |
24 | tp = np.sum(affected_np >= 0)
25 | precision = tp / dets.shape[0]
26 | recall = tp / gts.shape[0]
27 |
28 | return precision, recall
29 |
30 |
31 |
32 |
33 | #
34 | #gts = np.load('gt.npz')['points']
35 | #
36 | #
37 | #print (precision_recall(np.random.random((100,2)) * 500, gts))
--------------------------------------------------------------------------------
/data/50SQE_2018_12_10_0_012.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anttad/SubpixelCircleDetection/912252d4a305d71f800ed39b3ce87946251cb675/data/50SQE_2018_12_10_0_012.jpeg
--------------------------------------------------------------------------------
/data/50SQE_2018_12_10_0_012.json:
--------------------------------------------------------------------------------
1 | {"images":[{"id":1,"date_captured":"2019-07-04 13:09:17.924786","license":1,"coco_url":"","width":513,"file_name":"50SQE_2018_12_10_0_012.jpeg","height":513,"flickr_url":""}],"annotations":[{"id":1,"iscrowd":0,"category_id":1,"segmentation":[[247.0,338.5,246.5,338.0,246.0,337.5,245.0,337.5,244.5,337.0,244.5,336.0,244.0,335.5,243.5,335.0,244.0,334.5,244.5,334.0,244.5,333.0,245.0,332.5,246.0,332.5,246.5,332.0,247.0,331.5,247.5,332.0,248.0,332.5,249.0,332.5,249.5,333.0,249.5,334.0,250.0,334.5,250.5,335.0,250.0,335.5,249.5,336.0,249.5,337.0,249.0,337.5,248.0,337.5,247.5,338.0,247.0,338.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[244.0,332.0,7.0,7.0]},{"id":2,"iscrowd":0,"category_id":1,"segmentation":[[176.0,318.5,175.5,318.0,175.0,317.5,174.0,317.5,173.5,317.0,173.5,316.0,173.0,315.5,172.5,315.0,173.0,314.5,173.5,314.0,173.5,313.0,174.0,312.5,175.0,312.5,175.5,312.0,176.0,311.5,176.5,312.0,177.0,312.5,178.0,312.5,178.5,313.0,178.5,314.0,179.0,314.5,179.5,315.0,179.0,315.5,178.5,316.0,178.5,317.0,178.0,317.5,177.0,317.5,176.5,318.0,176.0,318.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[173.0,312.0,7.0,7.0]},{"id":3,"iscrowd":0,"category_id":1,"segmentation":[[175.0,309.5,174.5,309.0,174.0,308.5,173.0,308.5,172.5,308.0,172.5,307.0,172.0,306.5,171.5,306.0,172.0,305.5,172.5,305.0,172.5,304.0,173.0,303.5,174.0,303.5,174.5,303.0,175.0,302.5,175.5,303.0,176.0,303.5,177.0,303.5,177.5,304.0,177.5,305.0,178.0,305.5,178.5,306.0,178.0,306.5,177.5,307.0,177.5,308.0,177.0,308.5,176.0,308.5,175.5,309.0,175.0,309.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[172.0,303.0,7.0,7.0]},{"id":4,"iscrowd":0,"category_id":1,"segmentation":[[147.0,301.5,146.5,301.0,146.0,300.5,145.0,300.5,144.5,300.0,144.5,299.0,144.0,298.5,143.5,298.0,144.0,297.5,144.5,297.0,144.5,296.0,145.0,295.5,146.0,295.5,146.5,295.0,147.0,294.5,147.5,295.0,148.0,295.5,149.0,295.5,149.5,296.0,149.5,297.0,150.0,297.5,150.5,298.0,150.0,298.5,149.5,299.0,149.5,300.0,149.0,300.5,148.0,300.5,147.5,301.0,147.0,301.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[144.0,295.0,7.0,7.0]},{"id":5,"iscrowd":0,"category_id":1,"segmentation":[[297.0,362.5,296.5,362.0,296.0,361.5,295.0,361.5,294.5,361.0,294.5,360.0,294.0,359.5,293.5,359.0,294.0,358.5,294.5,358.0,294.5,357.0,295.0,356.5,296.0,356.5,296.5,356.0,297.0,355.5,297.5,356.0,298.0,356.5,299.0,356.5,299.5,357.0,299.5,358.0,300.0,358.5,300.5,359.0,300.0,359.5,299.5,360.0,299.5,361.0,299.0,361.5,298.0,361.5,297.5,362.0,297.0,362.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[294.0,356.0,7.0,7.0]},{"id":6,"iscrowd":0,"category_id":1,"segmentation":[[128.0,384.5,127.5,384.0,127.0,383.5,126.0,383.5,125.5,383.0,125.5,382.0,125.0,381.5,124.5,381.0,125.0,380.5,125.5,380.0,125.5,379.0,126.0,378.5,127.0,378.5,127.5,378.0,128.0,377.5,128.5,378.0,129.0,378.5,130.0,378.5,130.5,379.0,130.5,380.0,131.0,380.5,131.5,381.0,131.0,381.5,130.5,382.0,130.5,383.0,130.0,383.5,129.0,383.5,128.5,384.0,128.0,384.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[125.0,378.0,7.0,7.0]},{"id":7,"iscrowd":0,"category_id":1,"segmentation":[[175.0,291.5,174.5,291.0,174.0,290.5,173.0,290.5,172.5,290.0,172.5,289.0,172.0,288.5,171.5,288.0,172.0,287.5,172.5,287.0,172.5,286.0,173.0,285.5,174.0,285.5,174.5,285.0,175.0,284.5,175.5,285.0,176.0,285.5,177.0,285.5,177.5,286.0,177.5,287.0,178.0,287.5,178.5,288.0,178.0,288.5,177.5,289.0,177.5,290.0,177.0,290.5,176.0,290.5,175.5,291.0,175.0,291.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[172.0,285.0,7.0,7.0]},{"id":8,"iscrowd":0,"category_id":1,"segmentation":[[213.0,309.5,212.5,309.0,212.0,308.5,211.0,308.5,210.5,308.0,210.5,307.0,210.0,306.5,209.5,306.0,210.0,305.5,210.5,305.0,210.5,304.0,211.0,303.5,212.0,303.5,212.5,303.0,213.0,302.5,213.5,303.0,214.0,303.5,215.0,303.5,215.5,304.0,215.5,305.0,216.0,305.5,216.5,306.0,216.0,306.5,215.5,307.0,215.5,308.0,215.0,308.5,214.0,308.5,213.5,309.0,213.0,309.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[210.0,303.0,7.0,7.0]},{"id":9,"iscrowd":0,"category_id":1,"segmentation":[[184.0,291.5,183.5,291.0,183.0,290.5,182.0,290.5,181.5,290.0,181.5,289.0,181.0,288.5,180.5,288.0,181.0,287.5,181.5,287.0,181.5,286.0,182.0,285.5,183.0,285.5,183.5,285.0,184.0,284.5,184.5,285.0,185.0,285.5,186.0,285.5,186.5,286.0,186.5,287.0,187.0,287.5,187.5,288.0,187.0,288.5,186.5,289.0,186.5,290.0,186.0,290.5,185.0,290.5,184.5,291.0,184.0,291.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[181.0,285.0,7.0,7.0]},{"id":10,"iscrowd":0,"category_id":1,"segmentation":[[205.0,317.5,204.5,317.0,204.0,316.5,203.0,316.5,202.5,316.0,202.5,315.0,202.0,314.5,201.5,314.0,202.0,313.5,202.5,313.0,202.5,312.0,203.0,311.5,204.0,311.5,204.5,311.0,205.0,310.5,205.5,311.0,206.0,311.5,207.0,311.5,207.5,312.0,207.5,313.0,208.0,313.5,208.5,314.0,208.0,314.5,207.5,315.0,207.5,316.0,207.0,316.5,206.0,316.5,205.5,317.0,205.0,317.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[202.0,311.0,7.0,7.0]},{"id":11,"iscrowd":0,"category_id":1,"segmentation":[[223.0,290.5,222.5,290.0,222.0,289.5,221.0,289.5,220.5,289.0,220.5,288.0,220.0,287.5,219.5,287.0,220.0,286.5,220.5,286.0,220.5,285.0,221.0,284.5,222.0,284.5,222.5,284.0,223.0,283.5,223.5,284.0,224.0,284.5,225.0,284.5,225.5,285.0,225.5,286.0,226.0,286.5,226.5,287.0,226.0,287.5,225.5,288.0,225.5,289.0,225.0,289.5,224.0,289.5,223.5,290.0,223.0,290.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[220.0,284.0,7.0,7.0]},{"id":12,"iscrowd":0,"category_id":1,"segmentation":[[235.0,370.5,234.5,370.0,234.0,369.5,233.0,369.5,232.5,369.0,232.5,368.0,232.0,367.5,231.5,367.0,232.0,366.5,232.5,366.0,232.5,365.0,233.0,364.5,234.0,364.5,234.5,364.0,235.0,363.5,235.5,364.0,236.0,364.5,237.0,364.5,237.5,365.0,237.5,366.0,238.0,366.5,238.5,367.0,238.0,367.5,237.5,368.0,237.5,369.0,237.0,369.5,236.0,369.5,235.5,370.0,235.0,370.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[232.0,364.0,7.0,7.0]},{"id":13,"iscrowd":0,"category_id":1,"segmentation":[[223.0,306.5,222.5,306.0,222.0,305.5,221.0,305.5,220.5,305.0,220.5,304.0,220.0,303.5,219.5,303.0,220.0,302.5,220.5,302.0,220.5,301.0,221.0,300.5,222.0,300.5,222.5,300.0,223.0,299.5,223.5,300.0,224.0,300.5,225.0,300.5,225.5,301.0,225.5,302.0,226.0,302.5,226.5,303.0,226.0,303.5,225.5,304.0,225.5,305.0,225.0,305.5,224.0,305.5,223.5,306.0,223.0,306.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[220.0,300.0,7.0,7.0]},{"id":14,"iscrowd":0,"category_id":1,"segmentation":[[167.0,300.5,166.5,300.0,166.0,299.5,165.0,299.5,164.5,299.0,164.5,298.0,164.0,297.5,163.5,297.0,164.0,296.5,164.5,296.0,164.5,295.0,165.0,294.5,166.0,294.5,166.5,294.0,167.0,293.5,167.5,294.0,168.0,294.5,169.0,294.5,169.5,295.0,169.5,296.0,170.0,296.5,170.5,297.0,170.0,297.5,169.5,298.0,169.5,299.0,169.0,299.5,168.0,299.5,167.5,300.0,167.0,300.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[164.0,294.0,7.0,7.0]},{"id":15,"iscrowd":0,"category_id":1,"segmentation":[[128.0,393.5,127.5,393.0,127.0,392.5,126.0,392.5,125.5,392.0,125.5,391.0,125.0,390.5,124.5,390.0,125.0,389.5,125.5,389.0,125.5,388.0,126.0,387.5,127.0,387.5,127.5,387.0,128.0,386.5,128.5,387.0,129.0,387.5,130.0,387.5,130.5,388.0,130.5,389.0,131.0,389.5,131.5,390.0,131.0,390.5,130.5,391.0,130.5,392.0,130.0,392.5,129.0,392.5,128.5,393.0,128.0,393.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[125.0,387.0,7.0,7.0]},{"id":16,"iscrowd":0,"category_id":1,"segmentation":[[296.0,301.5,295.5,301.0,295.0,300.5,294.5,300.0,294.0,299.5,293.5,299.0,294.0,298.5,294.5,298.0,295.0,297.5,295.5,297.0,296.0,296.5,296.5,297.0,297.0,297.5,297.5,298.0,298.0,298.5,298.5,299.0,298.0,299.5,297.5,300.0,297.0,300.5,296.5,301.0,296.0,301.5]],"image_id":1,"height":513,"width":513,"area":13,"bbox":[294.0,297.0,5.0,5.0]},{"id":17,"iscrowd":0,"category_id":1,"segmentation":[[133.0,291.5,132.5,291.0,132.0,290.5,131.5,290.0,131.0,289.5,130.5,289.0,131.0,288.5,131.5,288.0,132.0,287.5,132.5,287.0,133.0,286.5,133.5,287.0,134.0,287.5,134.5,288.0,135.0,288.5,135.5,289.0,135.0,289.5,134.5,290.0,134.0,290.5,133.5,291.0,133.0,291.5]],"image_id":1,"height":513,"width":513,"area":13,"bbox":[131.0,287.0,5.0,5.0]},{"id":18,"iscrowd":0,"category_id":1,"segmentation":[[294.0,316.5,293.0,316.5,292.0,316.5,291.5,316.0,291.0,315.5,290.5,315.0,290.5,314.0,290.5,313.0,291.0,312.5,291.5,312.0,292.0,311.5,293.0,311.5,294.0,311.5,294.5,312.0,295.0,312.5,295.5,313.0,295.5,314.0,295.5,315.0,295.0,315.5,294.5,316.0,294.0,316.5]],"image_id":1,"height":513,"width":513,"area":21,"bbox":[291.0,312.0,5.0,5.0]},{"id":19,"iscrowd":0,"category_id":1,"segmentation":[[318.0,324.5,317.5,324.0,317.0,323.5,316.0,323.5,315.5,323.0,315.0,322.5,314.5,322.0,314.5,321.0,314.0,320.5,313.5,320.0,314.0,319.5,314.5,319.0,314.5,318.0,315.0,317.5,315.5,317.0,316.0,316.5,317.0,316.5,317.5,316.0,318.0,315.5,318.5,316.0,319.0,316.5,320.0,316.5,320.5,317.0,321.0,317.5,321.5,318.0,321.5,319.0,322.0,319.5,322.5,320.0,322.0,320.5,321.5,321.0,321.5,322.0,321.0,322.5,320.5,323.0,320.0,323.5,319.0,323.5,318.5,324.0,318.0,324.5]],"image_id":1,"height":513,"width":513,"area":49,"bbox":[314.0,316.0,9.0,9.0]},{"id":20,"iscrowd":0,"category_id":1,"segmentation":[[68.0,297.5,67.5,297.0,67.0,296.5,66.0,296.5,65.5,296.0,65.5,295.0,65.0,294.5,64.5,294.0,65.0,293.5,65.5,293.0,65.5,292.0,66.0,291.5,67.0,291.5,67.5,291.0,68.0,290.5,68.5,291.0,69.0,291.5,70.0,291.5,70.5,292.0,70.5,293.0,71.0,293.5,71.5,294.0,71.0,294.5,70.5,295.0,70.5,296.0,70.0,296.5,69.0,296.5,68.5,297.0,68.0,297.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[65.0,291.0,7.0,7.0]},{"id":21,"iscrowd":0,"category_id":1,"segmentation":[[223.0,298.5,222.5,298.0,222.0,297.5,221.0,297.5,220.5,297.0,220.5,296.0,220.0,295.5,219.5,295.0,220.0,294.5,220.5,294.0,220.5,293.0,221.0,292.5,222.0,292.5,222.5,292.0,223.0,291.5,223.5,292.0,224.0,292.5,225.0,292.5,225.5,293.0,225.5,294.0,226.0,294.5,226.5,295.0,226.0,295.5,225.5,296.0,225.5,297.0,225.0,297.5,224.0,297.5,223.5,298.0,223.0,298.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[220.0,292.0,7.0,7.0]},{"id":22,"iscrowd":0,"category_id":1,"segmentation":[[301.0,313.5,300.5,313.0,300.0,312.5,299.0,312.5,298.5,312.0,298.0,311.5,297.5,311.0,297.5,310.0,297.0,309.5,296.5,309.0,297.0,308.5,297.5,308.0,297.5,307.0,298.0,306.5,298.5,306.0,299.0,305.5,300.0,305.5,300.5,305.0,301.0,304.5,301.5,305.0,302.0,305.5,303.0,305.5,303.5,306.0,304.0,306.5,304.5,307.0,304.5,308.0,305.0,308.5,305.5,309.0,305.0,309.5,304.5,310.0,304.5,311.0,304.0,311.5,303.5,312.0,303.0,312.5,302.0,312.5,301.5,313.0,301.0,313.5]],"image_id":1,"height":513,"width":513,"area":49,"bbox":[297.0,305.0,9.0,9.0]},{"id":23,"iscrowd":0,"category_id":1,"segmentation":[[127.0,356.5,126.5,356.0,126.0,355.5,125.5,355.0,125.0,354.5,124.5,354.0,125.0,353.5,125.5,353.0,126.0,352.5,126.5,352.0,127.0,351.5,127.5,352.0,128.0,352.5,128.5,353.0,129.0,353.5,129.5,354.0,129.0,354.5,128.5,355.0,128.0,355.5,127.5,356.0,127.0,356.5]],"image_id":1,"height":513,"width":513,"area":13,"bbox":[125.0,352.0,5.0,5.0]},{"id":24,"iscrowd":0,"category_id":1,"segmentation":[[242.0,299.5,241.5,299.0,241.0,298.5,240.0,298.5,239.5,298.0,239.5,297.0,239.0,296.5,238.5,296.0,239.0,295.5,239.5,295.0,239.5,294.0,240.0,293.5,241.0,293.5,241.5,293.0,242.0,292.5,242.5,293.0,243.0,293.5,244.0,293.5,244.5,294.0,244.5,295.0,245.0,295.5,245.5,296.0,245.0,296.5,244.5,297.0,244.5,298.0,244.0,298.5,243.0,298.5,242.5,299.0,242.0,299.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[239.0,293.0,7.0,7.0]},{"id":25,"iscrowd":0,"category_id":1,"segmentation":[[242.0,291.5,241.5,291.0,241.0,290.5,240.0,290.5,239.5,290.0,239.5,289.0,239.0,288.5,238.5,288.0,239.0,287.5,239.5,287.0,239.5,286.0,240.0,285.5,241.0,285.5,241.5,285.0,242.0,284.5,242.5,285.0,243.0,285.5,244.0,285.5,244.5,286.0,244.5,287.0,245.0,287.5,245.5,288.0,245.0,288.5,244.5,289.0,244.5,290.0,244.0,290.5,243.0,290.5,242.5,291.0,242.0,291.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[239.0,285.0,7.0,7.0]},{"id":26,"iscrowd":0,"category_id":1,"segmentation":[[184.0,299.5,183.5,299.0,183.0,298.5,182.0,298.5,181.5,298.0,181.5,297.0,181.0,296.5,180.5,296.0,181.0,295.5,181.5,295.0,181.5,294.0,182.0,293.5,183.0,293.5,183.5,293.0,184.0,292.5,184.5,293.0,185.0,293.5,186.0,293.5,186.5,294.0,186.5,295.0,187.0,295.5,187.5,296.0,187.0,296.5,186.5,297.0,186.5,298.0,186.0,298.5,185.0,298.5,184.5,299.0,184.0,299.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[181.0,293.0,7.0,7.0]},{"id":27,"iscrowd":0,"category_id":1,"segmentation":[[298.0,322.5,297.5,322.0,297.0,321.5,296.0,321.5,295.5,321.0,295.5,320.0,295.0,319.5,294.5,319.0,295.0,318.5,295.5,318.0,295.5,317.0,296.0,316.5,297.0,316.5,297.5,316.0,298.0,315.5,298.5,316.0,299.0,316.5,300.0,316.5,300.5,317.0,300.5,318.0,301.0,318.5,301.5,319.0,301.0,319.5,300.5,320.0,300.5,321.0,300.0,321.5,299.0,321.5,298.5,322.0,298.0,322.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[295.0,316.0,7.0,7.0]},{"id":28,"iscrowd":0,"category_id":1,"segmentation":[[212.0,298.5,211.5,298.0,211.0,297.5,210.0,297.5,209.5,297.0,209.5,296.0,209.0,295.5,208.5,295.0,209.0,294.5,209.5,294.0,209.5,293.0,210.0,292.5,211.0,292.5,211.5,292.0,212.0,291.5,212.5,292.0,213.0,292.5,214.0,292.5,214.5,293.0,214.5,294.0,215.0,294.5,215.5,295.0,215.0,295.5,214.5,296.0,214.5,297.0,214.0,297.5,213.0,297.5,212.5,298.0,212.0,298.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[209.0,292.0,7.0,7.0]},{"id":29,"iscrowd":0,"category_id":1,"segmentation":[[204.0,291.5,203.5,291.0,203.0,290.5,202.0,290.5,201.5,290.0,201.5,289.0,201.0,288.5,200.5,288.0,201.0,287.5,201.5,287.0,201.5,286.0,202.0,285.5,203.0,285.5,203.5,285.0,204.0,284.5,204.5,285.0,205.0,285.5,206.0,285.5,206.5,286.0,206.5,287.0,207.0,287.5,207.5,288.0,207.0,288.5,206.5,289.0,206.5,290.0,206.0,290.5,205.0,290.5,204.5,291.0,204.0,291.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[201.0,285.0,7.0,7.0]},{"id":30,"iscrowd":0,"category_id":1,"segmentation":[[205.0,309.5,204.5,309.0,204.0,308.5,203.0,308.5,202.5,308.0,202.5,307.0,202.0,306.5,201.5,306.0,202.0,305.5,202.5,305.0,202.5,304.0,203.0,303.5,204.0,303.5,204.5,303.0,205.0,302.5,205.5,303.0,206.0,303.5,207.0,303.5,207.5,304.0,207.5,305.0,208.0,305.5,208.5,306.0,208.0,306.5,207.5,307.0,207.5,308.0,207.0,308.5,206.0,308.5,205.5,309.0,205.0,309.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[202.0,303.0,7.0,7.0]},{"id":31,"iscrowd":0,"category_id":1,"segmentation":[[120.0,373.5,119.5,373.0,119.0,372.5,118.0,372.5,117.5,372.0,117.5,371.0,117.0,370.5,116.5,370.0,117.0,369.5,117.5,369.0,117.5,368.0,118.0,367.5,119.0,367.5,119.5,367.0,120.0,366.5,120.5,367.0,121.0,367.5,122.0,367.5,122.5,368.0,122.5,369.0,123.0,369.5,123.5,370.0,123.0,370.5,122.5,371.0,122.5,372.0,122.0,372.5,121.0,372.5,120.5,373.0,120.0,373.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[117.0,367.0,7.0,7.0]},{"id":32,"iscrowd":0,"category_id":1,"segmentation":[[134.0,307.5,133.5,307.0,133.0,306.5,132.0,306.5,131.5,306.0,131.5,305.0,131.0,304.5,130.5,304.0,131.0,303.5,131.5,303.0,131.5,302.0,132.0,301.5,133.0,301.5,133.5,301.0,134.0,300.5,134.5,301.0,135.0,301.5,136.0,301.5,136.5,302.0,136.5,303.0,137.0,303.5,137.5,304.0,137.0,304.5,136.5,305.0,136.5,306.0,136.0,306.5,135.0,306.5,134.5,307.0,134.0,307.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[131.0,301.0,7.0,7.0]},{"id":33,"iscrowd":0,"category_id":1,"segmentation":[[68.0,305.5,67.5,305.0,67.0,304.5,66.0,304.5,65.5,304.0,65.5,303.0,65.0,302.5,64.5,302.0,65.0,301.5,65.5,301.0,65.5,300.0,66.0,299.5,67.0,299.5,67.5,299.0,68.0,298.5,68.5,299.0,69.0,299.5,70.0,299.5,70.5,300.0,70.5,301.0,71.0,301.5,71.5,302.0,71.0,302.5,70.5,303.0,70.5,304.0,70.0,304.5,69.0,304.5,68.5,305.0,68.0,305.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[65.0,299.0,7.0,7.0]},{"id":34,"iscrowd":0,"category_id":1,"segmentation":[[77.0,305.5,76.5,305.0,76.0,304.5,75.0,304.5,74.5,304.0,74.5,303.0,74.0,302.5,73.5,302.0,74.0,301.5,74.5,301.0,74.5,300.0,75.0,299.5,76.0,299.5,76.5,299.0,77.0,298.5,77.5,299.0,78.0,299.5,79.0,299.5,79.5,300.0,79.5,301.0,80.0,301.5,80.5,302.0,80.0,302.5,79.5,303.0,79.5,304.0,79.0,304.5,78.0,304.5,77.5,305.0,77.0,305.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[74.0,299.0,7.0,7.0]},{"id":35,"iscrowd":0,"category_id":1,"segmentation":[[193.0,299.5,192.5,299.0,192.0,298.5,191.0,298.5,190.5,298.0,190.5,297.0,190.0,296.5,189.5,296.0,190.0,295.5,190.5,295.0,190.5,294.0,191.0,293.5,192.0,293.5,192.5,293.0,193.0,292.5,193.5,293.0,194.0,293.5,195.0,293.5,195.5,294.0,195.5,295.0,196.0,295.5,196.5,296.0,196.0,296.5,195.5,297.0,195.5,298.0,195.0,298.5,194.0,298.5,193.5,299.0,193.0,299.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[190.0,293.0,7.0,7.0]},{"id":36,"iscrowd":0,"category_id":1,"segmentation":[[244.0,369.5,243.5,369.0,243.0,368.5,242.0,368.5,241.5,368.0,241.5,367.0,241.0,366.5,240.5,366.0,241.0,365.5,241.5,365.0,241.5,364.0,242.0,363.5,243.0,363.5,243.5,363.0,244.0,362.5,244.5,363.0,245.0,363.5,246.0,363.5,246.5,364.0,246.5,365.0,247.0,365.5,247.5,366.0,247.0,366.5,246.5,367.0,246.5,368.0,246.0,368.5,245.0,368.5,244.5,369.0,244.0,369.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[241.0,363.0,7.0,7.0]},{"id":37,"iscrowd":0,"category_id":1,"segmentation":[[320.0,336.5,319.5,336.0,319.0,335.5,318.0,335.5,317.5,335.0,317.0,334.5,316.5,334.0,316.5,333.0,316.0,332.5,315.5,332.0,316.0,331.5,316.5,331.0,316.5,330.0,317.0,329.5,317.5,329.0,318.0,328.5,319.0,328.5,319.5,328.0,320.0,327.5,320.5,328.0,321.0,328.5,322.0,328.5,322.5,329.0,323.0,329.5,323.5,330.0,323.5,331.0,324.0,331.5,324.5,332.0,324.0,332.5,323.5,333.0,323.5,334.0,323.0,334.5,322.5,335.0,322.0,335.5,321.0,335.5,320.5,336.0,320.0,336.5]],"image_id":1,"height":513,"width":513,"area":49,"bbox":[316.0,328.0,9.0,9.0]},{"id":38,"iscrowd":0,"category_id":1,"segmentation":[[187.0,362.5,186.5,362.0,186.0,361.5,185.0,361.5,184.5,361.0,184.0,360.5,183.5,360.0,183.5,359.0,183.0,358.5,182.5,358.0,183.0,357.5,183.5,357.0,183.5,356.0,184.0,355.5,184.5,355.0,185.0,354.5,186.0,354.5,186.5,354.0,187.0,353.5,187.5,354.0,188.0,354.5,189.0,354.5,189.5,355.0,190.0,355.5,190.5,356.0,190.5,357.0,191.0,357.5,191.5,358.0,191.0,358.5,190.5,359.0,190.5,360.0,190.0,360.5,189.5,361.0,189.0,361.5,188.0,361.5,187.5,362.0,187.0,362.5]],"image_id":1,"height":513,"width":513,"area":49,"bbox":[183.0,354.0,9.0,9.0]},{"id":39,"iscrowd":0,"category_id":1,"segmentation":[[183.0,352.5,182.5,352.0,182.0,351.5,181.0,351.5,180.5,351.0,180.5,350.0,180.0,349.5,179.5,349.0,180.0,348.5,180.5,348.0,180.5,347.0,181.0,346.5,182.0,346.5,182.5,346.0,183.0,345.5,183.5,346.0,184.0,346.5,185.0,346.5,185.5,347.0,185.5,348.0,186.0,348.5,186.5,349.0,186.0,349.5,185.5,350.0,185.5,351.0,185.0,351.5,184.0,351.5,183.5,352.0,183.0,352.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[180.0,346.0,7.0,7.0]},{"id":40,"iscrowd":0,"category_id":1,"segmentation":[[193.0,317.5,192.5,317.0,192.0,316.5,191.0,316.5,190.5,316.0,190.5,315.0,190.0,314.5,189.5,314.0,190.0,313.5,190.5,313.0,190.5,312.0,191.0,311.5,192.0,311.5,192.5,311.0,193.0,310.5,193.5,311.0,194.0,311.5,195.0,311.5,195.5,312.0,195.5,313.0,196.0,313.5,196.5,314.0,196.0,314.5,195.5,315.0,195.5,316.0,195.0,316.5,194.0,316.5,193.5,317.0,193.0,317.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[190.0,311.0,7.0,7.0]},{"id":41,"iscrowd":0,"category_id":1,"segmentation":[[294.0,337.5,293.5,337.0,293.0,336.5,292.0,336.5,291.5,336.0,291.5,335.0,291.0,334.5,290.5,334.0,291.0,333.5,291.5,333.0,291.5,332.0,292.0,331.5,293.0,331.5,293.5,331.0,294.0,330.5,294.5,331.0,295.0,331.5,296.0,331.5,296.5,332.0,296.5,333.0,297.0,333.5,297.5,334.0,297.0,334.5,296.5,335.0,296.5,336.0,296.0,336.5,295.0,336.5,294.5,337.0,294.0,337.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[291.0,331.0,7.0,7.0]},{"id":42,"iscrowd":0,"category_id":1,"segmentation":[[136.0,385.5,135.5,385.0,135.0,384.5,134.0,384.5,133.5,384.0,133.5,383.0,133.0,382.5,132.5,382.0,133.0,381.5,133.5,381.0,133.5,380.0,134.0,379.5,135.0,379.5,135.5,379.0,136.0,378.5,136.5,379.0,137.0,379.5,138.0,379.5,138.5,380.0,138.5,381.0,139.0,381.5,139.5,382.0,139.0,382.5,138.5,383.0,138.5,384.0,138.0,384.5,137.0,384.5,136.5,385.0,136.0,385.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[133.0,379.0,7.0,7.0]},{"id":43,"iscrowd":0,"category_id":1,"segmentation":[[155.0,301.5,154.5,301.0,154.0,300.5,153.0,300.5,152.5,300.0,152.5,299.0,152.0,298.5,151.5,298.0,152.0,297.5,152.5,297.0,152.5,296.0,153.0,295.5,154.0,295.5,154.5,295.0,155.0,294.5,155.5,295.0,156.0,295.5,157.0,295.5,157.5,296.0,157.5,297.0,158.0,297.5,158.5,298.0,158.0,298.5,157.5,299.0,157.5,300.0,157.0,300.5,156.0,300.5,155.5,301.0,155.0,301.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[152.0,295.0,7.0,7.0]},{"id":44,"iscrowd":0,"category_id":1,"segmentation":[[193.0,309.5,192.5,309.0,192.0,308.5,191.0,308.5,190.5,308.0,190.5,307.0,190.0,306.5,189.5,306.0,190.0,305.5,190.5,305.0,190.5,304.0,191.0,303.5,192.0,303.5,192.5,303.0,193.0,302.5,193.5,303.0,194.0,303.5,195.0,303.5,195.5,304.0,195.5,305.0,196.0,305.5,196.5,306.0,196.0,306.5,195.5,307.0,195.5,308.0,195.0,308.5,194.0,308.5,193.5,309.0,193.0,309.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[190.0,303.0,7.0,7.0]},{"id":45,"iscrowd":0,"category_id":1,"segmentation":[[213.0,317.5,212.5,317.0,212.0,316.5,211.0,316.5,210.5,316.0,210.5,315.0,210.0,314.5,209.5,314.0,210.0,313.5,210.5,313.0,210.5,312.0,211.0,311.5,212.0,311.5,212.5,311.0,213.0,310.5,213.5,311.0,214.0,311.5,215.0,311.5,215.5,312.0,215.5,313.0,216.0,313.5,216.5,314.0,216.0,314.5,215.5,315.0,215.5,316.0,215.0,316.5,214.0,316.5,213.5,317.0,213.0,317.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[210.0,311.0,7.0,7.0]},{"id":46,"iscrowd":0,"category_id":1,"segmentation":[[233.0,336.5,232.5,336.0,232.0,335.5,231.0,335.5,230.5,335.0,230.0,334.5,229.5,334.0,229.5,333.0,229.0,332.5,228.5,332.0,229.0,331.5,229.5,331.0,229.5,330.0,230.0,329.5,230.5,329.0,231.0,328.5,232.0,328.5,232.5,328.0,233.0,327.5,233.5,328.0,234.0,328.5,235.0,328.5,235.5,329.0,236.0,329.5,236.5,330.0,236.5,331.0,237.0,331.5,237.5,332.0,237.0,332.5,236.5,333.0,236.5,334.0,236.0,334.5,235.5,335.0,235.0,335.5,234.0,335.5,233.5,336.0,233.0,336.5]],"image_id":1,"height":513,"width":513,"area":49,"bbox":[229.0,328.0,9.0,9.0]},{"id":47,"iscrowd":0,"category_id":1,"segmentation":[[119.0,384.5,118.5,384.0,118.0,383.5,117.0,383.5,116.5,383.0,116.5,382.0,116.0,381.5,115.5,381.0,116.0,380.5,116.5,380.0,116.5,379.0,117.0,378.5,118.0,378.5,118.5,378.0,119.0,377.5,119.5,378.0,120.0,378.5,121.0,378.5,121.5,379.0,121.5,380.0,122.0,380.5,122.5,381.0,122.0,381.5,121.5,382.0,121.5,383.0,121.0,383.5,120.0,383.5,119.5,384.0,119.0,384.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[116.0,378.0,7.0,7.0]},{"id":48,"iscrowd":0,"category_id":1,"segmentation":[[310.0,334.5,309.5,334.0,309.0,333.5,308.0,333.5,307.5,333.0,307.5,332.0,307.0,331.5,306.5,331.0,307.0,330.5,307.5,330.0,307.5,329.0,308.0,328.5,309.0,328.5,309.5,328.0,310.0,327.5,310.5,328.0,311.0,328.5,312.0,328.5,312.5,329.0,312.5,330.0,313.0,330.5,313.5,331.0,313.0,331.5,312.5,332.0,312.5,333.0,312.0,333.5,311.0,333.5,310.5,334.0,310.0,334.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[307.0,328.0,7.0,7.0]},{"id":49,"iscrowd":0,"category_id":1,"segmentation":[[226.0,359.5,225.5,359.0,225.0,358.5,224.0,358.5,223.5,358.0,223.5,357.0,223.0,356.5,222.5,356.0,223.0,355.5,223.5,355.0,223.5,354.0,224.0,353.5,225.0,353.5,225.5,353.0,226.0,352.5,226.5,353.0,227.0,353.5,228.0,353.5,228.5,354.0,228.5,355.0,229.0,355.5,229.5,356.0,229.0,356.5,228.5,357.0,228.5,358.0,228.0,358.5,227.0,358.5,226.5,359.0,226.0,359.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[223.0,353.0,7.0,7.0]},{"id":50,"iscrowd":0,"category_id":1,"segmentation":[[247.0,330.5,246.5,330.0,246.0,329.5,245.0,329.5,244.5,329.0,244.5,328.0,244.0,327.5,243.5,327.0,244.0,326.5,244.5,326.0,244.5,325.0,245.0,324.5,246.0,324.5,246.5,324.0,247.0,323.5,247.5,324.0,248.0,324.5,249.0,324.5,249.5,325.0,249.5,326.0,250.0,326.5,250.5,327.0,250.0,327.5,249.5,328.0,249.5,329.0,249.0,329.5,248.0,329.5,247.5,330.0,247.0,330.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[244.0,324.0,7.0,7.0]},{"id":51,"iscrowd":0,"category_id":1,"segmentation":[[175.0,299.5,174.5,299.0,174.0,298.5,173.0,298.5,172.5,298.0,172.5,297.0,172.0,296.5,171.5,296.0,172.0,295.5,172.5,295.0,172.5,294.0,173.0,293.5,174.0,293.5,174.5,293.0,175.0,292.5,175.5,293.0,176.0,293.5,177.0,293.5,177.5,294.0,177.5,295.0,178.0,295.5,178.5,296.0,178.0,296.5,177.5,297.0,177.5,298.0,177.0,298.5,176.0,298.5,175.5,299.0,175.0,299.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[172.0,293.0,7.0,7.0]},{"id":52,"iscrowd":0,"category_id":1,"segmentation":[[204.0,344.5,203.5,344.0,203.0,343.5,202.0,343.5,201.5,343.0,201.5,342.0,201.0,341.5,200.5,341.0,201.0,340.5,201.5,340.0,201.5,339.0,202.0,338.5,203.0,338.5,203.5,338.0,204.0,337.5,204.5,338.0,205.0,338.5,206.0,338.5,206.5,339.0,206.5,340.0,207.0,340.5,207.5,341.0,207.0,341.5,206.5,342.0,206.5,343.0,206.0,343.5,205.0,343.5,204.5,344.0,204.0,344.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[201.0,338.0,7.0,7.0]},{"id":53,"iscrowd":0,"category_id":1,"segmentation":[[233.0,300.5,232.5,300.0,232.0,299.5,231.0,299.5,230.5,299.0,230.5,298.0,230.0,297.5,229.5,297.0,230.0,296.5,230.5,296.0,230.5,295.0,231.0,294.5,232.0,294.5,232.5,294.0,233.0,293.5,233.5,294.0,234.0,294.5,235.0,294.5,235.5,295.0,235.5,296.0,236.0,296.5,236.5,297.0,236.0,297.5,235.5,298.0,235.5,299.0,235.0,299.5,234.0,299.5,233.5,300.0,233.0,300.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[230.0,294.0,7.0,7.0]},{"id":54,"iscrowd":0,"category_id":1,"segmentation":[[321.0,356.5,320.5,356.0,320.0,355.5,319.0,355.5,318.5,355.0,318.0,354.5,317.5,354.0,317.5,353.0,317.0,352.5,316.5,352.0,317.0,351.5,317.5,351.0,317.5,350.0,318.0,349.5,318.5,349.0,319.0,348.5,320.0,348.5,320.5,348.0,321.0,347.5,321.5,348.0,322.0,348.5,323.0,348.5,323.5,349.0,324.0,349.5,324.5,350.0,324.5,351.0,325.0,351.5,325.5,352.0,325.0,352.5,324.5,353.0,324.5,354.0,324.0,354.5,323.5,355.0,323.0,355.5,322.0,355.5,321.5,356.0,321.0,356.5]],"image_id":1,"height":513,"width":513,"area":49,"bbox":[317.0,348.0,9.0,9.0]},{"id":55,"iscrowd":0,"category_id":1,"segmentation":[[185.0,317.5,184.5,317.0,184.0,316.5,183.0,316.5,182.5,316.0,182.5,315.0,182.0,314.5,181.5,314.0,182.0,313.5,182.5,313.0,182.5,312.0,183.0,311.5,184.0,311.5,184.5,311.0,185.0,310.5,185.5,311.0,186.0,311.5,187.0,311.5,187.5,312.0,187.5,313.0,188.0,313.5,188.5,314.0,188.0,314.5,187.5,315.0,187.5,316.0,187.0,316.5,186.0,316.5,185.5,317.0,185.0,317.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[182.0,311.0,7.0,7.0]},{"id":56,"iscrowd":0,"category_id":1,"segmentation":[[308.0,324.5,307.5,324.0,307.0,323.5,306.0,323.5,305.5,323.0,305.0,322.5,304.5,322.0,304.5,321.0,304.0,320.5,303.5,320.0,304.0,319.5,304.5,319.0,304.5,318.0,305.0,317.5,305.5,317.0,306.0,316.5,307.0,316.5,307.5,316.0,308.0,315.5,308.5,316.0,309.0,316.5,310.0,316.5,310.5,317.0,311.0,317.5,311.5,318.0,311.5,319.0,312.0,319.5,312.5,320.0,312.0,320.5,311.5,321.0,311.5,322.0,311.0,322.5,310.5,323.0,310.0,323.5,309.0,323.5,308.5,324.0,308.0,324.5]],"image_id":1,"height":513,"width":513,"area":49,"bbox":[304.0,316.0,9.0,9.0]},{"id":57,"iscrowd":0,"category_id":1,"segmentation":[[320.0,346.5,319.5,346.0,319.0,345.5,318.0,345.5,317.5,345.0,317.0,344.5,316.5,344.0,316.5,343.0,316.0,342.5,315.5,342.0,316.0,341.5,316.5,341.0,316.5,340.0,317.0,339.5,317.5,339.0,318.0,338.5,319.0,338.5,319.5,338.0,320.0,337.5,320.5,338.0,321.0,338.5,322.0,338.5,322.5,339.0,323.0,339.5,323.5,340.0,323.5,341.0,324.0,341.5,324.5,342.0,324.0,342.5,323.5,343.0,323.5,344.0,323.0,344.5,322.5,345.0,322.0,345.5,321.0,345.5,320.5,346.0,320.0,346.5]],"image_id":1,"height":513,"width":513,"area":49,"bbox":[316.0,338.0,9.0,9.0]},{"id":58,"iscrowd":0,"category_id":1,"segmentation":[[297.0,370.5,296.5,370.0,296.0,369.5,295.0,369.5,294.5,369.0,294.5,368.0,294.0,367.5,293.5,367.0,294.0,366.5,294.5,366.0,294.5,365.0,295.0,364.5,296.0,364.5,296.5,364.0,297.0,363.5,297.5,364.0,298.0,364.5,299.0,364.5,299.5,365.0,299.5,366.0,300.0,366.5,300.5,367.0,300.0,367.5,299.5,368.0,299.5,369.0,299.0,369.5,298.0,369.5,297.5,370.0,297.0,370.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[294.0,364.0,7.0,7.0]},{"id":59,"iscrowd":0,"category_id":1,"segmentation":[[243.0,359.5,242.5,359.0,242.0,358.5,241.0,358.5,240.5,358.0,240.5,357.0,240.0,356.5,239.5,356.0,240.0,355.5,240.5,355.0,240.5,354.0,241.0,353.5,242.0,353.5,242.5,353.0,243.0,352.5,243.5,353.0,244.0,353.5,245.0,353.5,245.5,354.0,245.5,355.0,246.0,355.5,246.5,356.0,246.0,356.5,245.5,357.0,245.5,358.0,245.0,358.5,244.0,358.5,243.5,359.0,243.0,359.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[240.0,353.0,7.0,7.0]},{"id":60,"iscrowd":0,"category_id":1,"segmentation":[[167.0,310.5,166.5,310.0,166.0,309.5,165.0,309.5,164.5,309.0,164.5,308.0,164.0,307.5,163.5,307.0,164.0,306.5,164.5,306.0,164.5,305.0,165.0,304.5,166.0,304.5,166.5,304.0,167.0,303.5,167.5,304.0,168.0,304.5,169.0,304.5,169.5,305.0,169.5,306.0,170.0,306.5,170.5,307.0,170.0,307.5,169.5,308.0,169.5,309.0,169.0,309.5,168.0,309.5,167.5,310.0,167.0,310.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[164.0,304.0,7.0,7.0]},{"id":61,"iscrowd":0,"category_id":1,"segmentation":[[204.0,299.5,203.5,299.0,203.0,298.5,202.0,298.5,201.5,298.0,201.5,297.0,201.0,296.5,200.5,296.0,201.0,295.5,201.5,295.0,201.5,294.0,202.0,293.5,203.0,293.5,203.5,293.0,204.0,292.5,204.5,293.0,205.0,293.5,206.0,293.5,206.5,294.0,206.5,295.0,207.0,295.5,207.5,296.0,207.0,296.5,206.5,297.0,206.5,298.0,206.0,298.5,205.0,298.5,204.5,299.0,204.0,299.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[201.0,293.0,7.0,7.0]},{"id":62,"iscrowd":0,"category_id":1,"segmentation":[[189.0,344.5,188.5,344.0,188.0,343.5,187.0,343.5,186.5,343.0,186.5,342.0,186.0,341.5,185.5,341.0,186.0,340.5,186.5,340.0,186.5,339.0,187.0,338.5,188.0,338.5,188.5,338.0,189.0,337.5,189.5,338.0,190.0,338.5,191.0,338.5,191.5,339.0,191.5,340.0,192.0,340.5,192.5,341.0,192.0,341.5,191.5,342.0,191.5,343.0,191.0,343.5,190.0,343.5,189.5,344.0,189.0,344.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[186.0,338.0,7.0,7.0]},{"id":63,"iscrowd":0,"category_id":1,"segmentation":[[258.0,335.5,257.5,335.0,257.0,334.5,256.0,334.5,255.5,334.0,255.5,333.0,255.0,332.5,254.5,332.0,255.0,331.5,255.5,331.0,255.5,330.0,256.0,329.5,257.0,329.5,257.5,329.0,258.0,328.5,258.5,329.0,259.0,329.5,260.0,329.5,260.5,330.0,260.5,331.0,261.0,331.5,261.5,332.0,261.0,332.5,260.5,333.0,260.5,334.0,260.0,334.5,259.0,334.5,258.5,335.0,258.0,335.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[255.0,329.0,7.0,7.0]},{"id":64,"iscrowd":0,"category_id":1,"segmentation":[[294.0,346.5,293.5,346.0,293.0,345.5,292.0,345.5,291.5,345.0,291.5,344.0,291.0,343.5,290.5,343.0,291.0,342.5,291.5,342.0,291.5,341.0,292.0,340.5,293.0,340.5,293.5,340.0,294.0,339.5,294.5,340.0,295.0,340.5,296.0,340.5,296.5,341.0,296.5,342.0,297.0,342.5,297.5,343.0,297.0,343.5,296.5,344.0,296.5,345.0,296.0,345.5,295.0,345.5,294.5,346.0,294.0,346.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[291.0,340.0,7.0,7.0]},{"id":65,"iscrowd":0,"category_id":1,"segmentation":[[120.0,365.5,119.5,365.0,119.0,364.5,118.0,364.5,117.5,364.0,117.5,363.0,117.0,362.5,116.5,362.0,117.0,361.5,117.5,361.0,117.5,360.0,118.0,359.5,119.0,359.5,119.5,359.0,120.0,358.5,120.5,359.0,121.0,359.5,122.0,359.5,122.5,360.0,122.5,361.0,123.0,361.5,123.5,362.0,123.0,362.5,122.5,363.0,122.5,364.0,122.0,364.5,121.0,364.5,120.5,365.0,120.0,365.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[117.0,359.0,7.0,7.0]},{"id":66,"iscrowd":0,"category_id":1,"segmentation":[[76.0,296.5,75.5,296.0,75.0,295.5,74.0,295.5,73.5,295.0,73.5,294.0,73.0,293.5,72.5,293.0,73.0,292.5,73.5,292.0,73.5,291.0,74.0,290.5,75.0,290.5,75.5,290.0,76.0,289.5,76.5,290.0,77.0,290.5,78.0,290.5,78.5,291.0,78.5,292.0,79.0,292.5,79.5,293.0,79.0,293.5,78.5,294.0,78.5,295.0,78.0,295.5,77.0,295.5,76.5,296.0,76.0,296.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[73.0,290.0,7.0,7.0]},{"id":67,"iscrowd":0,"category_id":1,"segmentation":[[147.0,309.5,146.5,309.0,146.0,308.5,145.0,308.5,144.5,308.0,144.5,307.0,144.0,306.5,143.5,306.0,144.0,305.5,144.5,305.0,144.5,304.0,145.0,303.5,146.0,303.5,146.5,303.0,147.0,302.5,147.5,303.0,148.0,303.5,149.0,303.5,149.5,304.0,149.5,305.0,150.0,305.5,150.5,306.0,150.0,306.5,149.5,307.0,149.5,308.0,149.0,308.5,148.0,308.5,147.5,309.0,147.0,309.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[144.0,303.0,7.0,7.0]},{"id":68,"iscrowd":0,"category_id":1,"segmentation":[[291.0,301.5,290.5,301.0,290.0,300.5,289.5,300.0,289.0,299.5,288.5,299.0,289.0,298.5,289.5,298.0,290.0,297.5,290.5,297.0,291.0,296.5,291.5,297.0,292.0,297.5,292.5,298.0,293.0,298.5,293.5,299.0,293.0,299.5,292.5,300.0,292.0,300.5,291.5,301.0,291.0,301.5]],"image_id":1,"height":513,"width":513,"area":13,"bbox":[289.0,297.0,5.0,5.0]},{"id":69,"iscrowd":0,"category_id":1,"segmentation":[[267.0,329.5,266.5,329.0,266.0,328.5,265.0,328.5,264.5,328.0,264.5,327.0,264.0,326.5,263.5,326.0,264.0,325.5,264.5,325.0,264.5,324.0,265.0,323.5,266.0,323.5,266.5,323.0,267.0,322.5,267.5,323.0,268.0,323.5,269.0,323.5,269.5,324.0,269.5,325.0,270.0,325.5,270.5,326.0,270.0,326.5,269.5,327.0,269.5,328.0,269.0,328.5,268.0,328.5,267.5,329.0,267.0,329.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[264.0,323.0,7.0,7.0]},{"id":70,"iscrowd":0,"category_id":1,"segmentation":[[267.0,338.5,266.5,338.0,266.0,337.5,265.0,337.5,264.5,337.0,264.5,336.0,264.0,335.5,263.5,335.0,264.0,334.5,264.5,334.0,264.5,333.0,265.0,332.5,266.0,332.5,266.5,332.0,267.0,331.5,267.5,332.0,268.0,332.5,269.0,332.5,269.5,333.0,269.5,334.0,270.0,334.5,270.5,335.0,270.0,335.5,269.5,336.0,269.5,337.0,269.0,337.5,268.0,337.5,267.5,338.0,267.0,338.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[264.0,332.0,7.0,7.0]},{"id":71,"iscrowd":0,"category_id":1,"segmentation":[[119.0,393.5,118.5,393.0,118.0,392.5,117.0,392.5,116.5,392.0,116.5,391.0,116.0,390.5,115.5,390.0,116.0,389.5,116.5,389.0,116.5,388.0,117.0,387.5,118.0,387.5,118.5,387.0,119.0,386.5,119.5,387.0,120.0,387.5,121.0,387.5,121.5,388.0,121.5,389.0,122.0,389.5,122.5,390.0,122.0,390.5,121.5,391.0,121.5,392.0,121.0,392.5,120.0,392.5,119.5,393.0,119.0,393.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[116.0,387.0,7.0,7.0]},{"id":72,"iscrowd":0,"category_id":1,"segmentation":[[127.0,362.5,126.5,362.0,126.0,361.5,125.5,361.0,125.0,360.5,124.5,360.0,125.0,359.5,125.5,359.0,126.0,358.5,126.5,358.0,127.0,357.5,127.5,358.0,128.0,358.5,128.5,359.0,129.0,359.5,129.5,360.0,129.0,360.5,128.5,361.0,128.0,361.5,127.5,362.0,127.0,362.5]],"image_id":1,"height":513,"width":513,"area":13,"bbox":[125.0,358.0,5.0,5.0]},{"id":73,"iscrowd":0,"category_id":1,"segmentation":[[297.0,378.5,296.5,378.0,296.0,377.5,295.0,377.5,294.5,377.0,294.5,376.0,294.0,375.5,293.5,375.0,294.0,374.5,294.5,374.0,294.5,373.0,295.0,372.5,296.0,372.5,296.5,372.0,297.0,371.5,297.5,372.0,298.0,372.5,299.0,372.5,299.5,373.0,299.5,374.0,300.0,374.5,300.5,375.0,300.0,375.5,299.5,376.0,299.5,377.0,299.0,377.5,298.0,377.5,297.5,378.0,297.0,378.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[294.0,372.0,7.0,7.0]},{"id":74,"iscrowd":0,"category_id":1,"segmentation":[[231.0,290.5,230.5,290.0,230.0,289.5,229.0,289.5,228.5,289.0,228.5,288.0,228.0,287.5,227.5,287.0,228.0,286.5,228.5,286.0,228.5,285.0,229.0,284.5,230.0,284.5,230.5,284.0,231.0,283.5,231.5,284.0,232.0,284.5,233.0,284.5,233.5,285.0,233.5,286.0,234.0,286.5,234.5,287.0,234.0,287.5,233.5,288.0,233.5,289.0,233.0,289.5,232.0,289.5,231.5,290.0,231.0,290.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[228.0,284.0,7.0,7.0]},{"id":75,"iscrowd":0,"category_id":1,"segmentation":[[294.0,310.5,293.0,310.5,292.0,310.5,291.5,310.0,291.0,309.5,290.5,309.0,290.5,308.0,290.5,307.0,291.0,306.5,291.5,306.0,292.0,305.5,293.0,305.5,294.0,305.5,294.5,306.0,295.0,306.5,295.5,307.0,295.5,308.0,295.5,309.0,295.0,309.5,294.5,310.0,294.0,310.5]],"image_id":1,"height":513,"width":513,"area":21,"bbox":[291.0,306.0,5.0,5.0]},{"id":76,"iscrowd":0,"category_id":1,"segmentation":[[206.0,329.5,205.5,329.0,205.0,328.5,204.0,328.5,203.5,328.0,203.0,327.5,202.5,327.0,202.5,326.0,202.0,325.5,201.5,325.0,202.0,324.5,202.5,324.0,202.5,323.0,203.0,322.5,203.5,322.0,204.0,321.5,205.0,321.5,205.5,321.0,206.0,320.5,206.5,321.0,207.0,321.5,208.0,321.5,208.5,322.0,209.0,322.5,209.5,323.0,209.5,324.0,210.0,324.5,210.5,325.0,210.0,325.5,209.5,326.0,209.5,327.0,209.0,327.5,208.5,328.0,208.0,328.5,207.0,328.5,206.5,329.0,206.0,329.5]],"image_id":1,"height":513,"width":513,"area":49,"bbox":[202.0,321.0,9.0,9.0]},{"id":77,"iscrowd":0,"category_id":1,"segmentation":[[258.0,327.5,257.5,327.0,257.0,326.5,256.0,326.5,255.5,326.0,255.5,325.0,255.0,324.5,254.5,324.0,255.0,323.5,255.5,323.0,255.5,322.0,256.0,321.5,257.0,321.5,257.5,321.0,258.0,320.5,258.5,321.0,259.0,321.5,260.0,321.5,260.5,322.0,260.5,323.0,261.0,323.5,261.5,324.0,261.0,324.5,260.5,325.0,260.5,326.0,260.0,326.5,259.0,326.5,258.5,327.0,258.0,327.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[255.0,321.0,7.0,7.0]},{"id":78,"iscrowd":0,"category_id":1,"segmentation":[[185.0,309.5,184.5,309.0,184.0,308.5,183.0,308.5,182.5,308.0,182.5,307.0,182.0,306.5,181.5,306.0,182.0,305.5,182.5,305.0,182.5,304.0,183.0,303.5,184.0,303.5,184.5,303.0,185.0,302.5,185.5,303.0,186.0,303.5,187.0,303.5,187.5,304.0,187.5,305.0,188.0,305.5,188.5,306.0,188.0,306.5,187.5,307.0,187.5,308.0,187.0,308.5,186.0,308.5,185.5,309.0,185.0,309.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[182.0,303.0,7.0,7.0]},{"id":79,"iscrowd":0,"category_id":1,"segmentation":[[125.0,291.5,124.5,291.0,124.0,290.5,123.5,290.0,123.0,289.5,122.5,289.0,123.0,288.5,123.5,288.0,124.0,287.5,124.5,287.0,125.0,286.5,125.5,287.0,126.0,287.5,126.5,288.0,127.0,288.5,127.5,289.0,127.0,289.5,126.5,290.0,126.0,290.5,125.5,291.0,125.0,291.5]],"image_id":1,"height":513,"width":513,"area":13,"bbox":[123.0,287.0,5.0,5.0]},{"id":80,"iscrowd":0,"category_id":1,"segmentation":[[223.0,337.5,222.5,337.0,222.0,336.5,221.0,336.5,220.5,336.0,220.0,335.5,219.5,335.0,219.5,334.0,219.0,333.5,218.5,333.0,219.0,332.5,219.5,332.0,219.5,331.0,220.0,330.5,220.5,330.0,221.0,329.5,222.0,329.5,222.5,329.0,223.0,328.5,223.5,329.0,224.0,329.5,225.0,329.5,225.5,330.0,226.0,330.5,226.5,331.0,226.5,332.0,227.0,332.5,227.5,333.0,227.0,333.5,226.5,334.0,226.5,335.0,226.0,335.5,225.5,336.0,225.0,336.5,224.0,336.5,223.5,337.0,223.0,337.5]],"image_id":1,"height":513,"width":513,"area":49,"bbox":[219.0,329.0,9.0,9.0]},{"id":81,"iscrowd":0,"category_id":1,"segmentation":[[216.0,329.5,215.5,329.0,215.0,328.5,214.0,328.5,213.5,328.0,213.0,327.5,212.5,327.0,212.5,326.0,212.0,325.5,211.5,325.0,212.0,324.5,212.5,324.0,212.5,323.0,213.0,322.5,213.5,322.0,214.0,321.5,215.0,321.5,215.5,321.0,216.0,320.5,216.5,321.0,217.0,321.5,218.0,321.5,218.5,322.0,219.0,322.5,219.5,323.0,219.5,324.0,220.0,324.5,220.5,325.0,220.0,325.5,219.5,326.0,219.5,327.0,219.0,327.5,218.5,328.0,218.0,328.5,217.0,328.5,216.5,329.0,216.0,329.5]],"image_id":1,"height":513,"width":513,"area":49,"bbox":[212.0,321.0,9.0,9.0]},{"id":82,"iscrowd":0,"category_id":1,"segmentation":[[120.0,356.5,119.5,356.0,119.0,355.5,118.0,355.5,117.5,355.0,117.5,354.0,117.0,353.5,116.5,353.0,117.0,352.5,117.5,352.0,117.5,351.0,118.0,350.5,119.0,350.5,119.5,350.0,120.0,349.5,120.5,350.0,121.0,350.5,122.0,350.5,122.5,351.0,122.5,352.0,123.0,352.5,123.5,353.0,123.0,353.5,122.5,354.0,122.5,355.0,122.0,355.5,121.0,355.5,120.5,356.0,120.0,356.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[117.0,350.0,7.0,7.0]},{"id":83,"iscrowd":0,"category_id":1,"segmentation":[[234.0,308.5,233.5,308.0,233.0,307.5,232.0,307.5,231.5,307.0,231.5,306.0,231.0,305.5,230.5,305.0,231.0,304.5,231.5,304.0,231.5,303.0,232.0,302.5,233.0,302.5,233.5,302.0,234.0,301.5,234.5,302.0,235.0,302.5,236.0,302.5,236.5,303.0,236.5,304.0,237.0,304.5,237.5,305.0,237.0,305.5,236.5,306.0,236.5,307.0,236.0,307.5,235.0,307.5,234.5,308.0,234.0,308.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[231.0,302.0,7.0,7.0]},{"id":84,"iscrowd":0,"category_id":1,"segmentation":[[181.0,344.5,180.5,344.0,180.0,343.5,179.0,343.5,178.5,343.0,178.5,342.0,178.0,341.5,177.5,341.0,178.0,340.5,178.5,340.0,178.5,339.0,179.0,338.5,180.0,338.5,180.5,338.0,181.0,337.5,181.5,338.0,182.0,338.5,183.0,338.5,183.5,339.0,183.5,340.0,184.0,340.5,184.5,341.0,184.0,341.5,183.5,342.0,183.5,343.0,183.0,343.5,182.0,343.5,181.5,344.0,181.0,344.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[178.0,338.0,7.0,7.0]},{"id":85,"iscrowd":0,"category_id":1,"segmentation":[[311.0,313.5,310.5,313.0,310.0,312.5,309.0,312.5,308.5,312.0,308.0,311.5,307.5,311.0,307.5,310.0,307.0,309.5,306.5,309.0,307.0,308.5,307.5,308.0,307.5,307.0,308.0,306.5,308.5,306.0,309.0,305.5,310.0,305.5,310.5,305.0,311.0,304.5,311.5,305.0,312.0,305.5,313.0,305.5,313.5,306.0,314.0,306.5,314.5,307.0,314.5,308.0,315.0,308.5,315.5,309.0,315.0,309.5,314.5,310.0,314.5,311.0,314.0,311.5,313.5,312.0,313.0,312.5,312.0,312.5,311.5,313.0,311.0,313.5]],"image_id":1,"height":513,"width":513,"area":49,"bbox":[307.0,305.0,9.0,9.0]},{"id":86,"iscrowd":0,"category_id":1,"segmentation":[[155.0,309.5,154.5,309.0,154.0,308.5,153.0,308.5,152.5,308.0,152.5,307.0,152.0,306.5,151.5,306.0,152.0,305.5,152.5,305.0,152.5,304.0,153.0,303.5,154.0,303.5,154.5,303.0,155.0,302.5,155.5,303.0,156.0,303.5,157.0,303.5,157.5,304.0,157.5,305.0,158.0,305.5,158.5,306.0,158.0,306.5,157.5,307.0,157.5,308.0,157.0,308.5,156.0,308.5,155.5,309.0,155.0,309.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[152.0,303.0,7.0,7.0]},{"id":87,"iscrowd":0,"category_id":1,"segmentation":[[196.0,344.5,195.5,344.0,195.0,343.5,194.0,343.5,193.5,343.0,193.5,342.0,193.0,341.5,192.5,341.0,193.0,340.5,193.5,340.0,193.5,339.0,194.0,338.5,195.0,338.5,195.5,338.0,196.0,337.5,196.5,338.0,197.0,338.5,198.0,338.5,198.5,339.0,198.5,340.0,199.0,340.5,199.5,341.0,199.0,341.5,198.5,342.0,198.5,343.0,198.0,343.5,197.0,343.5,196.5,344.0,196.0,344.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[193.0,338.0,7.0,7.0]},{"id":88,"iscrowd":0,"category_id":1,"segmentation":[[227.0,370.5,226.5,370.0,226.0,369.5,225.0,369.5,224.5,369.0,224.5,368.0,224.0,367.5,223.5,367.0,224.0,366.5,224.5,366.0,224.5,365.0,225.0,364.5,226.0,364.5,226.5,364.0,227.0,363.5,227.5,364.0,228.0,364.5,229.0,364.5,229.5,365.0,229.5,366.0,230.0,366.5,230.5,367.0,230.0,367.5,229.5,368.0,229.5,369.0,229.0,369.5,228.0,369.5,227.5,370.0,227.0,370.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[224.0,364.0,7.0,7.0]},{"id":89,"iscrowd":0,"category_id":1,"segmentation":[[212.0,290.5,211.5,290.0,211.0,289.5,210.0,289.5,209.5,289.0,209.5,288.0,209.0,287.5,208.5,287.0,209.0,286.5,209.5,286.0,209.5,285.0,210.0,284.5,211.0,284.5,211.5,284.0,212.0,283.5,212.5,284.0,213.0,284.5,214.0,284.5,214.5,285.0,214.5,286.0,215.0,286.5,215.5,287.0,215.0,287.5,214.5,288.0,214.5,289.0,214.0,289.5,213.0,289.5,212.5,290.0,212.0,290.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[209.0,284.0,7.0,7.0]},{"id":90,"iscrowd":0,"category_id":1,"segmentation":[[247.0,322.5,246.5,322.0,246.0,321.5,245.0,321.5,244.5,321.0,244.5,320.0,244.0,319.5,243.5,319.0,244.0,318.5,244.5,318.0,244.5,317.0,245.0,316.5,246.0,316.5,246.5,316.0,247.0,315.5,247.5,316.0,248.0,316.5,249.0,316.5,249.5,317.0,249.5,318.0,250.0,318.5,250.5,319.0,250.0,319.5,249.5,320.0,249.5,321.0,249.0,321.5,248.0,321.5,247.5,322.0,247.0,322.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[244.0,316.0,7.0,7.0]},{"id":91,"iscrowd":0,"category_id":1,"segmentation":[[192.0,290.5,191.5,290.0,191.0,289.5,190.0,289.5,189.5,289.0,189.5,288.0,189.0,287.5,188.5,287.0,189.0,286.5,189.5,286.0,189.5,285.0,190.0,284.5,191.0,284.5,191.5,284.0,192.0,283.5,192.5,284.0,193.0,284.5,194.0,284.5,194.5,285.0,194.5,286.0,195.0,286.5,195.5,287.0,195.0,287.5,194.5,288.0,194.5,289.0,194.0,289.5,193.0,289.5,192.5,290.0,192.0,290.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[189.0,284.0,7.0,7.0]},{"id":92,"iscrowd":0,"category_id":1,"segmentation":[[310.0,342.5,309.5,342.0,309.0,341.5,308.0,341.5,307.5,341.0,307.5,340.0,307.0,339.5,306.5,339.0,307.0,338.5,307.5,338.0,307.5,337.0,308.0,336.5,309.0,336.5,309.5,336.0,310.0,335.5,310.5,336.0,311.0,336.5,312.0,336.5,312.5,337.0,312.5,338.0,313.0,338.5,313.5,339.0,313.0,339.5,312.5,340.0,312.5,341.0,312.0,341.5,311.0,341.5,310.5,342.0,310.0,342.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[307.0,336.0,7.0,7.0]},{"id":93,"iscrowd":0,"category_id":1,"segmentation":[[311.0,350.5,310.5,350.0,310.0,349.5,309.0,349.5,308.5,349.0,308.5,348.0,308.0,347.5,307.5,347.0,308.0,346.5,308.5,346.0,308.5,345.0,309.0,344.5,310.0,344.5,310.5,344.0,311.0,343.5,311.5,344.0,312.0,344.5,313.0,344.5,313.5,345.0,313.5,346.0,314.0,346.5,314.5,347.0,314.0,347.5,313.5,348.0,313.5,349.0,313.0,349.5,312.0,349.5,311.5,350.0,311.0,350.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[308.0,344.0,7.0,7.0]},{"id":94,"iscrowd":0,"category_id":1,"segmentation":[[125.0,299.5,124.5,299.0,124.0,298.5,123.0,298.5,122.5,298.0,122.5,297.0,122.0,296.5,121.5,296.0,122.0,295.5,122.5,295.0,122.5,294.0,123.0,293.5,124.0,293.5,124.5,293.0,125.0,292.5,125.5,293.0,126.0,293.5,127.0,293.5,127.5,294.0,127.5,295.0,128.0,295.5,128.5,296.0,128.0,296.5,127.5,297.0,127.5,298.0,127.0,298.5,126.0,298.5,125.5,299.0,125.0,299.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[122.0,293.0,7.0,7.0]},{"id":95,"iscrowd":0,"category_id":1,"segmentation":[[126.0,307.5,125.5,307.0,125.0,306.5,124.0,306.5,123.5,306.0,123.5,305.0,123.0,304.5,122.5,304.0,123.0,303.5,123.5,303.0,123.5,302.0,124.0,301.5,125.0,301.5,125.5,301.0,126.0,300.5,126.5,301.0,127.0,301.5,128.0,301.5,128.5,302.0,128.5,303.0,129.0,303.5,129.5,304.0,129.0,304.5,128.5,305.0,128.5,306.0,128.0,306.5,127.0,306.5,126.5,307.0,126.0,307.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[123.0,301.0,7.0,7.0]},{"id":96,"iscrowd":0,"category_id":1,"segmentation":[[235.0,359.5,234.5,359.0,234.0,358.5,233.0,358.5,232.5,358.0,232.5,357.0,232.0,356.5,231.5,356.0,232.0,355.5,232.5,355.0,232.5,354.0,233.0,353.5,234.0,353.5,234.5,353.0,235.0,352.5,235.5,353.0,236.0,353.5,237.0,353.5,237.5,354.0,237.5,355.0,238.0,355.5,238.5,356.0,238.0,356.5,237.5,357.0,237.5,358.0,237.0,358.5,236.0,358.5,235.5,359.0,235.0,359.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[232.0,353.0,7.0,7.0]},{"id":97,"iscrowd":0,"category_id":1,"segmentation":[[166.0,291.5,165.5,291.0,165.0,290.5,164.0,290.5,163.5,290.0,163.5,289.0,163.0,288.5,162.5,288.0,163.0,287.5,163.5,287.0,163.5,286.0,164.0,285.5,165.0,285.5,165.5,285.0,166.0,284.5,166.5,285.0,167.0,285.5,168.0,285.5,168.5,286.0,168.5,287.0,169.0,287.5,169.5,288.0,169.0,288.5,168.5,289.0,168.5,290.0,168.0,290.5,167.0,290.5,166.5,291.0,166.0,291.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[163.0,285.0,7.0,7.0]},{"id":98,"iscrowd":0,"category_id":1,"segmentation":[[312.0,356.5,311.0,356.5,310.0,356.5,309.5,356.0,309.0,355.5,308.5,355.0,308.5,354.0,308.5,353.0,309.0,352.5,309.5,352.0,310.0,351.5,311.0,351.5,312.0,351.5,312.5,352.0,313.0,352.5,313.5,353.0,313.5,354.0,313.5,355.0,313.0,355.5,312.5,356.0,312.0,356.5]],"image_id":1,"height":513,"width":513,"area":21,"bbox":[309.0,352.0,5.0,5.0]},{"id":99,"iscrowd":0,"category_id":1,"segmentation":[[167.0,318.5,166.5,318.0,166.0,317.5,165.0,317.5,164.5,317.0,164.5,316.0,164.0,315.5,163.5,315.0,164.0,314.5,164.5,314.0,164.5,313.0,165.0,312.5,166.0,312.5,166.5,312.0,167.0,311.5,167.5,312.0,168.0,312.5,169.0,312.5,169.5,313.0,169.5,314.0,170.0,314.5,170.5,315.0,170.0,315.5,169.5,316.0,169.5,317.0,169.0,317.5,168.0,317.5,167.5,318.0,167.0,318.5]],"image_id":1,"height":513,"width":513,"area":29,"bbox":[164.0,312.0,7.0,7.0]}]}
--------------------------------------------------------------------------------
/data/50SQE_2018_12_10_0_012.pgm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anttad/SubpixelCircleDetection/912252d4a305d71f800ed39b3ce87946251cb675/data/50SQE_2018_12_10_0_012.pgm
--------------------------------------------------------------------------------
/data/gt.npz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/anttad/SubpixelCircleDetection/912252d4a305d71f800ed39b3ce87946251cb675/data/gt.npz
--------------------------------------------------------------------------------
/hough_devernay.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 |
4 |
5 |
6 |
7 | import os
8 | import numpy as np
9 | import cv2
10 | import json
11 | from skimage import color #, data
12 | from skimage.transform import hough_circle, hough_circle_peaks,hough_ellipse
13 | from skimage.feature import canny
14 | from skimage.draw import circle_perimeter, rectangle_perimeter,ellipse_perimeter,circle
15 | from skimage.util import img_as_ubyte
16 |
17 | import scipy.misc
18 | import scipy.ndimage
19 | import skimage.morphology
20 | from skimage.morphology import disk
21 | from skimage.viewer import ImageViewer
22 | from utils import *
23 |
24 | from skimage.draw import rectangle
25 |
26 | from skimage.morphology import binary_closing, binary_dilation, erosion, dilation
27 | from skimage.morphology import square
28 | import skimage.io
29 |
30 | import scipy.misc
31 | import scipy.ndimage
32 | from skimage.viewer import ImageViewer
33 | from skimage.color import rgb2gray
34 |
35 | import argparse
36 |
37 | from utils import *
38 |
39 | from skimage.filters import threshold_otsu
40 |
41 | from apply_tophat import minimum_of_directional_tophat_bottomhat
42 |
43 |
44 |
45 |
46 | """
47 | Formule pour calculer l'air d'un polygone connaissant les coordonnées de ses sommets. "shoelace forumula"
48 | """
49 | def PolyArea(x,y):
50 | return 0.5*np.abs(np.dot(x,np.roll(y,1))-np.dot(y,np.roll(x,1)))
51 |
52 |
53 | """
54 | A partir d'une liste de edge point obtenu par l'algorithme canny-devernay, renvoie
55 | l'image binaire des contours
56 | """
57 | def get_edge_map(txt,im_dim, width):
58 |
59 | coord = np.loadtxt(txt)
60 | coord = coord[coord[:,0]!=-1,:] # on élimine la délimitation
61 | A = np.uint(np.round(coord/width)) # on augmente la valeur des coordonnées par 2 et on arrondie pour pouvoir les plascer
62 |
63 | new_dim = ( int(im_dim[0]/width), int(im_dim[1]/width))
64 | edge_map = np.zeros(new_dim)
65 |
66 | y,x= tuple(A.T) # corrige l'inversion des coordonnées x et y
67 | edge_map[(x,y)]=1
68 |
69 | return edge_map
70 |
71 |
72 |
73 | """
74 | determine si un segment de contours est fermé
75 | """
76 | def is_closed(segment):
77 |
78 | x_o, y_o = segment[0,:]
79 | x_f, y_f = segment[-1,:]
80 |
81 | if (x_o == x_f) and (y_o == y_f):
82 | return True
83 | else:
84 | return False
85 |
86 | """
87 | renvoie la liste des contours fermés
88 | """
89 | def get_closed_contour_map(txt,im_dim, width):
90 |
91 | coord = np.loadtxt(txt)/width
92 | list_of_segment = np.split(coord,np.argwhere(coord[:,0]<0).reshape(-1))
93 | list_of_segment = [x[1:,:] if x[0,0] <0 else x for x in list_of_segment[:-1]] # le dernier terme de la liste ne sert à rien
94 |
95 |
96 | closed_edge_list = [ np.uint(np.round(segment)) for segment in list_of_segment if is_closed(segment)]
97 | #coord = coord[coord[:,0]!=-1,:] # on élimine la délimitation
98 | # on augmente la valeur des coordonnées par 2 et on arrondie pour pouvoir les placer
99 | # découpage des segments de contours
100 | new_dim = ( int(im_dim[0]/width), int(im_dim[1]/width))
101 |
102 | edge_map = np.zeros(new_dim)
103 |
104 | for seg in closed_edge_list:
105 | y,x= tuple(seg.T) # corrige l'inversion des coordonnées x et y
106 | edge_map[(x,y)]=1
107 | return edge_map
108 |
109 |
110 | def svg2png(in_svg, out_png, out_shape):
111 | import cairo
112 | import rsvg
113 | nrow, ncol = out_shape
114 | img = cairo.ImageSurface(cairo.FORMAT_ARGB32, ncol,nrow)
115 |
116 | ctx = cairo.Context(img)
117 |
118 | ## handle = rsvg.Handle(