├── .gitignore
├── COPYING
├── README.md
├── RVElogoclearback-80.png
├── RhizoVisionExplorer-window.png
├── RhizoVisionExplorer.sln
├── RhizoVisionExplorer
├── MainUI.cpp
├── MainUI.h
├── RhizoVisionExplorer.json
├── RhizoVisionExplorer.rc
├── RhizoVisionExplorer.vcxproj
├── RhizoVisionExplorer.vcxproj.filters
├── RhizoVisionExplorer.vcxproj.user
├── common_types.h
├── demo.h
├── icons
│ ├── RVElogoclearback-150.png
│ ├── RVElogoclearback.png
│ └── rveicon.ico
├── main.cpp
├── moc_FeatureExtractorThread.cpp
├── moc_MainUI.cpp
├── qrc_resources.cpp
├── resource.h
├── resources.qrc
├── rootsegmentprop.cpp
├── rootsegmentprop.h
├── roottopology.cpp
└── roottopology.h
└── changelog.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Compiled Object files
5 | *.slo
6 | *.lo
7 | *.o
8 | *.obj
9 |
10 | # Precompiled Headers
11 | *.gch
12 | *.pch
13 |
14 | # Compiled Dynamic libraries
15 | *.so
16 | *.dylib
17 | *.dll
18 |
19 | # Fortran module files
20 | *.mod
21 | *.smod
22 |
23 | # Compiled Static libraries
24 | *.lai
25 | *.la
26 | *.a
27 | *.lib
28 |
29 | # Executables
30 | *.exe
31 | *.out
32 | *.app
33 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 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 General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #  RhizoVision Explorer
2 |
3 | RhizoVision Explorer is free and open-source software developed for estimating root traits from images acquired from a flatbed scanner or camera. Root images are expected to have a high contrast of roots with the background, homogenous lighting, and minimal overlapping of roots. The software is built in C++ for speed and stability, using QT for the graphical user interface and OpenCV for image processing. Traits extracted by RhizoVision Explorer have been extensively validated using a physical copper wire ground truth image set, thousands of simulated roots, and comparisons with other image analysis software. The default “Broken Roots” mode is meant for roots washed out from soil cores or pots that are disconnected and provides length, volume, branching frequency, among other features, with the ability to bin measurements based on diameter thresholds. The “Whole Root” mode extracts additional root system architecture features of more intact root systems, especially excavated root crowns or rhizoboxes, such as the convex hull, angles, and holes. The software supports multiple regions of interest, batch mode, and user-defined export of processed images with overlaid features for use in reports.
4 |
5 | #### Downloading
6 | The software binary can be downloaded [here](https://doi.org/10.5281/zenodo.3747697).
7 |
8 | The source code repository is located [here](https://github.com/rootphenomicslab/RhizoVisionExplorer).
9 |
10 | #### Running the Program
11 |
12 | The program opens a GUI where we specify the location of root images and output location to save the processed images and the extracted features. We can change the options that suit the input images and click the start button to start extracting the feature traits from the root images.
13 |
14 | 
15 |
16 | #### Pre-requisites for Running the Program
17 |
18 | This program needs an x86_64 processor. Any Intel or AMD processor may be used for running the program. If the CPU supports Intel AVX 2.0, the program runs faster for feature extraction.
19 |
20 | #### Compiling the Source
21 |
22 | The source code is compiled using Microsoft Visual Studio. The program depends on Qt 5.12.3, OpenCV 4.1 and [cvutil](https://github.com/rootphenomicslab/cvutil) 2.0.3 libraries for compiling the source.
23 |
24 | #### Copyright and License
25 |
26 | Copyright (C) 2021, Anand Seethepalli and Larry York
27 | Copyright (C) 2020, Courtesy of Noble Research Institute, LLC
28 |
29 | **RhizoVision Explorer**
30 |
31 | RhizoVision Explorer is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
32 |
33 | RhizoVision Explorer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
34 |
35 | You should have received a copy of the GNU General Public License along with RhizoVision Explorer; see the file COPYING. If not, see .
36 |
37 | #### Citing
38 | Please use the following citation when using the software.
39 |
40 | > Anand Seethepalli, & Larry York. RhizoVision Explorer - Interactive software for generalized root image analysis designed for everyone (Version 2.0.3). Zenodo. https://doi.org/10.5281/zenodo.3747697
41 |
42 | #### Authors
43 |
44 | Please send any comments/suggestions/improvements for the program to the authors:
45 |
46 | Anand Seethepalli
47 | anand.seethepalli@yahoo.co.in
48 |
49 | Larry York
50 | larry.york@gmail.com
51 |
52 |
--------------------------------------------------------------------------------
/RVElogoclearback-80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/predictivephenomics/RhizoVisionExplorer/42750c9d238153dd2d707267c70dcbe66e302083/RVElogoclearback-80.png
--------------------------------------------------------------------------------
/RhizoVisionExplorer-window.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/predictivephenomics/RhizoVisionExplorer/42750c9d238153dd2d707267c70dcbe66e302083/RhizoVisionExplorer-window.png
--------------------------------------------------------------------------------
/RhizoVisionExplorer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RhizoVisionExplorer", "RhizoVisionExplorer\RhizoVisionExplorer.vcxproj", "{868F0440-8F50-4AAC-AEF2-C9A0AEB2635E}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A147851C-C2B1-4F81-8DF1-71F4D8841EA4}"
9 | ProjectSection(SolutionItems) = preProject
10 | changelog.txt = changelog.txt
11 | LICENSE = LICENSE
12 | README.md = README.md
13 | RhizoVisionExplorer-window.png = RhizoVisionExplorer-window.png
14 | RVElogoclearback-150.png = RVElogoclearback-150.png
15 | EndProjectSection
16 | EndProject
17 | Global
18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
19 | Debug|x64 = Debug|x64
20 | Debug|x86 = Debug|x86
21 | Release|x64 = Release|x64
22 | Release|x86 = Release|x86
23 | EndGlobalSection
24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
25 | {868F0440-8F50-4AAC-AEF2-C9A0AEB2635E}.Debug|x64.ActiveCfg = Debug|x64
26 | {868F0440-8F50-4AAC-AEF2-C9A0AEB2635E}.Debug|x64.Build.0 = Debug|x64
27 | {868F0440-8F50-4AAC-AEF2-C9A0AEB2635E}.Debug|x86.ActiveCfg = Debug|x64
28 | {868F0440-8F50-4AAC-AEF2-C9A0AEB2635E}.Debug|x86.Build.0 = Debug|x64
29 | {868F0440-8F50-4AAC-AEF2-C9A0AEB2635E}.Release|x64.ActiveCfg = Release|x64
30 | {868F0440-8F50-4AAC-AEF2-C9A0AEB2635E}.Release|x64.Build.0 = Release|x64
31 | {868F0440-8F50-4AAC-AEF2-C9A0AEB2635E}.Release|x86.ActiveCfg = Release|Win32
32 | {868F0440-8F50-4AAC-AEF2-C9A0AEB2635E}.Release|x86.Build.0 = Release|Win32
33 | EndGlobalSection
34 | GlobalSection(SolutionProperties) = preSolution
35 | HideSolutionNode = FALSE
36 | EndGlobalSection
37 | EndGlobal
38 |
--------------------------------------------------------------------------------
/RhizoVisionExplorer/MainUI.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2021, Anand Seethepalli and Larry York
3 | Copyright (C) 2020, Courtesy of Noble Research Institute, LLC
4 |
5 | File: MainUI.h
6 |
7 | Authors:
8 | Anand Seethepalli (anand.seethepalli@yahoo.co.in)
9 | Larry York (larry.york@gmail.com)
10 |
11 | This file is part of RhizoVision Explorer.
12 |
13 | RhizoVision Explorer is free software: you can redistribute
14 | it and/or modify it under the terms of the GNU General Public
15 | License as published by the Free Software Foundation, either
16 | version 3 of the License, or (at your option) any later version.
17 |
18 | RhizoVision Explorer is distributed in the hope that it will
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
21 | PURPOSE. See the GNU General Public License for more details.
22 |
23 | You should have received a copy of the GNU General Public
24 | License along with RhizoVision Explorer; see the file COPYING.
25 | If not, see .
26 | */
27 |
28 | #pragma once
29 |
30 | #ifndef MAINUI_H
31 | #define MAINUI_H
32 |
33 | #include
34 | #include
35 |
36 | #include
37 | #include
38 | #include
39 | #include
40 |
41 | #include
42 | #include
43 | #include
44 |
45 | //#include "FeatureExtractorThread.h"
46 |
47 | #define RHIZOVISION_EXPLORER_VERSION "2.0.3"
48 |
49 | QT_BEGIN_NAMESPACE
50 | class QAction;
51 | class QDialogButtonBox;
52 | class QGroupBox;
53 | class QLabel;
54 | class QLineEdit;
55 | class QMenu;
56 | class QMenuBar;
57 | class QPushButton;
58 | class QTextEdit;
59 | class QCheckBox;
60 | class QProgressBar;
61 | class QVBoxLayout;
62 | class QStatusBar;
63 | class QSpinBox;
64 | class QDoubleSpinBox;
65 | class QSlider;
66 | class QComboBox;
67 | QT_END_NAMESPACE
68 |
69 | class MainUI;
70 |
71 | typedef struct
72 | {
73 | cv::Mat input;
74 | cv::Mat seg;
75 | cv::Mat processed;
76 | std::vector features;
77 | std::vector rootlengthhist;
78 | std::vector> roifeatures;
79 | std::vector> roirootlengthhist;
80 |
81 | cv::Mat rtdpoints; // To get length-diameter profile
82 |
83 | int rotation = 0;
84 |
85 | // UI option for type of root being processed
86 | // 0 = Whole root
87 | // 1 = Broken roots
88 | int roottype = 1;
89 |
90 | // UI option for threshold to be applied for segmentation
91 | int threshold = 200;
92 |
93 | // UI option for image color inversion
94 | bool invertimage = false;
95 |
96 | // UI options for line smoothing
97 | bool enablesmooththresh = false;
98 | double smooththresh = 2.0;
99 |
100 | // UI options for filtering noisy components
101 | bool keepLargest = true;
102 | bool filterbknoise = false;
103 | bool filterfgnoise = false;
104 | double maxcompsizebk = 1.0;
105 | double maxcompsizefg = 1.0;
106 |
107 | // UI option for root pruning
108 | bool enableRootPruning = false;
109 | int rootPruningThreshold = 1;
110 |
111 | // UI options for convert pixels to physical units
112 | bool pixelconv = false;
113 | double conversion = 1.0;
114 | int pixelspermm = 0; // 0 for DPI, 1 for Pixels per mm
115 |
116 | // UI options for diameter ranges
117 | std::vector dranges = { 2.0, 5.0 };
118 |
119 | // Setting to interactively change the image being shown
120 | int displayOutputIndex = 0;
121 |
122 | // UI options for displaying output options
123 | bool showConvexHull = true; // For whole root only
124 | bool showHoles = true; // For whole roots only
125 | bool showDistMap = false;
126 | bool showMedialAxis = true;
127 | int medialaxiswidth = 3;
128 | bool showMedialAxisDiameter = true;
129 | bool showContours = true;
130 | int contourwidth = 1;
131 |
132 |
133 | // Batch processing options
134 | bool batchmode = false;
135 | bool savesegmented = false;
136 | bool saveprocessed = false;
137 | QString segsuffix, prosuffix;
138 | QString featurecsvfile = "features.csv";
139 | QString metadatacsvfile = "metadata.csv";
140 |
141 | // Needed reporting progress in interactive mode.
142 | MainUI *ui;
143 | bool abortprocess = false;
144 |
145 | // Used for logging messages
146 | QString imagename;
147 | } feature_config;
148 |
149 | class CheckEnabler : public QWidget
150 | {
151 | Q_OBJECT;
152 |
153 | private:
154 | QCheckBox *cb;
155 | QLineEdit *edt;
156 | QLabel *lbl;
157 |
158 | QHBoxLayout *layout;
159 | std::vector widgets;
160 |
161 | public:
162 | CheckEnabler(QString text, QString lbl, bool integervalue = false, QWidget *parent = nullptr);
163 |
164 | bool checked() const { return cb->isChecked(); };
165 | void setChecked(bool on) { cb->setChecked(on); };
166 | double getValue() const { return edt->text().toDouble(); };
167 | void setValue(double val) { edt->setText(QString::number(val, 'g')); };
168 | void setValue(QString val) { edt->setText(val); };
169 | void setLabelText(QString text) { lbl->setText(text); };
170 |
171 | void addToLayout(QWidget *w) { layout->addWidget(w, 0, Qt::AlignLeft); widgets.push_back(w); this->update(); }
172 | //void setWhatsThis(const QString &msg) { QWidget::setWhatsThis(msg); }
173 |
174 | signals:
175 | void stateChanged();
176 | void textChanged();
177 | };
178 |
179 | class StringCheckEnabler : public QWidget
180 | {
181 | Q_OBJECT;
182 |
183 | private:
184 | QCheckBox *cb;
185 | QLineEdit *edt;
186 | QLabel *lbl;
187 |
188 | public:
189 | StringCheckEnabler(QString text, QString lbl, QWidget *parent = nullptr);
190 |
191 | bool checked() const { return cb->isChecked(); };
192 | void setChecked(bool on) { cb->setChecked(on); };
193 | QString getValue() const { return edt->text(); };
194 | void setValue(QString val) { edt->setText(val); };
195 |
196 | //void setWhatsThis(const QString &msg) { QWidget::setWhatsThis(msg); }
197 |
198 | signals:
199 | void stateChanged();
200 | void textChanged();
201 | };
202 |
203 | class MainUI : public QObject, public IPlugin
204 | {
205 | Q_OBJECT;
206 | Q_INTERFACES(IPlugin);
207 | Q_PLUGIN_METADATA(IID IPlugin_iid FILE "RhizoVisionExplorer.json");
208 |
209 | public:
210 | typedef void(*processfunc)(feature_config* config);
211 |
212 | MainUI();
213 | //~MainUI();
214 | void setprocessfunction(processfunc pfunc);
215 | void setHostWindow(cvutil::cvutilWindow *wnd);
216 |
217 | //private:
218 | //MainUI(std::shared_ptr fconfig);
219 | public slots:
220 | std::string getName();
221 | AppType getApplicationType();
222 | OutputType getOutputType();
223 | std::string getAlgorithmName();
224 | std::vector getParameters();
225 | QWidget *getPluginUI();
226 | void setImage(cv::Mat image, QString imagename = "");
227 | void execute();
228 | std::vector getOutputImages();
229 | int getDisplayIndex();
230 | void setDisplayIndex(int idx);
231 | std::vector getFeatures();
232 | std::vector getFeatures(int roiidx);
233 | void setBatchMode(bool on);
234 | int saveOutput(QString savloc, QString inputfilename);
235 | void saveMetadata(QString imgloc, QString savloc, QString filepath = "");
236 | void loadMetadata(QString filepath);
237 | int writeHeader(QString savloc, QString filename = "");
238 | std::vector getCSVColumnNames();
239 | int getProgressSteps();
240 | void abort();
241 | QChart *getChart();
242 |
243 | signals:
244 | void updateVisualOutput(cv::Mat m);
245 | void updateProgress(QString status);
246 |
247 | private:
248 | void createOptions();
249 | void createRangeControls();
250 | void updateRangeControls();
251 | void enablepixelconversion();
252 | void connectSignalstoSlots();
253 | //void enableinvertimage();
254 | //void enablesavesegmented();
255 | //void enablesaveprocessed();
256 | void updateconversion();
257 | void setTextWhatsThis();
258 | void spboxvaluechanged(QDoubleSpinBox *s, double k);
259 | void addrangerowclicked(double lastdrange = -1.0f);
260 | void removerangerowclicked();
261 | void colorizechart(QChart *chart, int size);
262 |
263 | private slots:
264 | void updatesegmentedoutput();
265 |
266 | private:
267 | QVBoxLayout *vlayout;
268 | QLabel *lbroottype, *lbdispoutput;
269 | QComboBox *roottype, *dispoutput, *pixelspermm;
270 | //QCheckBox *invertimage; //, *savesegmented, *saveprocessed; // , *convertunits;
271 | //QCheckBox *enableRootPruning;
272 | QPushButton *pbpreview;
273 | cv::Ptr f;
274 | QIcon rightarrow, downarrow;
275 |
276 | bool dispoutputupdating = false;
277 | bool executing = false; // Gaurd to prevent thread unsafe way to update config->displayOutputIndex.
278 | std::vector drangeview; // To synchronize diameter range view (UI) and the internal list (config->drange).
279 |
280 | StringCheckEnabler *saveseg, *savepro;
281 | CheckEnabler *convertunits, *linesmooth, *filterbknoisy, *filterfgnoisy, *enableRootPruning;
282 | QLabel *ranges;
283 | QLineEdit *featurefileedt, *metadatafileedt;
284 | QCheckBox *keepLargest;
285 |
286 | std::vector dranges;
287 | std::vector editmins;
288 | std::vector spboxes;
289 | QPushButton *addrangerow, *removerangerow;
290 |
291 | QLabel* thresh;
292 | QSlider *thresholdslider;
293 | QSpinBox *thresholdbox;
294 | QProgressBar *thresholdbar;
295 |
296 | QCheckBox *showConvexHull, *showHoles; // For whole root only
297 | QCheckBox *showDistMap, *showMedialAxisDiameter;
298 | CheckEnabler *showMedialAxis, *showContours;
299 |
300 | //int roottypeval = 0;
301 | std::shared_ptr config;
302 | processfunc pfunc;
303 |
304 | cvutilWindow* hostWindow = nullptr;
305 | QScrollArea *pluginuiarea = nullptr;
306 | QToolBox *pluginui = nullptr;
307 | };
308 |
309 | #endif // DIALOG_H
310 |
311 |
--------------------------------------------------------------------------------
/RhizoVisionExplorer/RhizoVisionExplorer.json:
--------------------------------------------------------------------------------
1 | { }
--------------------------------------------------------------------------------
/RhizoVisionExplorer/RhizoVisionExplorer.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/predictivephenomics/RhizoVisionExplorer/42750c9d238153dd2d707267c70dcbe66e302083/RhizoVisionExplorer/RhizoVisionExplorer.rc
--------------------------------------------------------------------------------
/RhizoVisionExplorer/RhizoVisionExplorer.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {868F0440-8F50-4AAC-AEF2-C9A0AEB2635E}
23 | Win32Proj
24 | RhizoVisionExplorer
25 | 8.1
26 |
27 |
28 |
29 | Application
30 | true
31 | v140
32 | Unicode
33 |
34 |
35 | Application
36 | false
37 | v140
38 | true
39 | Unicode
40 |
41 |
42 | Application
43 | true
44 | v140
45 | Unicode
46 |
47 |
48 | Application
49 | false
50 | v140
51 | true
52 | Unicode
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 | $(VC_IncludePath);$(WindowsSDK_IncludePath);C:\Users\aseethepalli\Documents\opencv\build\include;C:\Users\aseethepalli\Documents\pthreads-w32-2-9-1-release\Pre-built.2\include;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include;C:\Users\aseethepalli\Documents\Qt\5.9.1\msvc2015_64\include;C:\Program Files\Basler\pylon 5\Development\include;
76 |
77 |
78 | true
79 | $(VC_IncludePath);$(WindowsSDK_IncludePath);C:\Users\aseethepalli\Documents\opencv\build\include;C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\include;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include;C:\Users\aseethepalli\Documents\Qt\5.12.3\msvc2015_64\include;C:\Program Files\Basler\pylon 5\Development\include;C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\PluginManager\include;C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\RoiManager\include
80 | $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;C:\Users\aseethepalli\Documents\opencv\build\x64\vc14\lib;C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\lib;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64;C:\Users\aseethepalli\Documents\Qt\5.12.3\msvc2015_64\lib;C:\Program Files\Basler\pylon 5\Development\lib\x64;C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\PluginManager\lib;C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\RoiManager\lib
81 |
82 |
83 | false
84 | $(VC_IncludePath);$(WindowsSDK_IncludePath);C:\Users\aseethepalli\Documents\opencv\build\include;C:\Users\aseethepalli\Documents\pthreads-w32-2-9-1-release\Pre-built.2\include;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include;C:\Users\aseethepalli\Documents\Qt\5.9.1\msvc2015_64\include;C:\Program Files\Basler\pylon 5\Development\include;
85 |
86 |
87 | false
88 | $(VC_IncludePath);$(WindowsSDK_IncludePath);C:\Users\aseethepalli\Documents\opencv\build\include;C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\include;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include;C:\Users\aseethepalli\Documents\Qt\5.12.3\msvc2015_64\include;C:\Program Files\Basler\pylon 5\Development\include;C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\PluginManager\include;C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\RoiManager\include
89 | $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;C:\Users\aseethepalli\Documents\opencv\build\x64\vc14\lib;C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\lib;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64;C:\Users\aseethepalli\Documents\Qt\5.12.3\msvc2015_64\lib;C:\Program Files\Basler\pylon 5\Development\lib\x64;C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\PluginManager\lib;C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\RoiManager\lib
90 |
91 |
92 |
93 |
94 |
95 | Level3
96 | Disabled
97 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
98 |
99 |
100 | Console
101 | true
102 |
103 |
104 |
105 |
106 |
107 |
108 | Level3
109 | Disabled
110 | _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
111 |
112 |
113 |
114 |
115 | Console
116 | true
117 | cudart.lib;opencv_world410d.lib;cvutild.lib;Qt5Cored.lib;Qt5Widgetsd.lib;Qt5Chartsd.lib;Qt5Guid.lib;qtmaind.lib;PluginManagerd.lib;RoiManagerd.lib;%(AdditionalDependencies)
118 |
119 |
120 |
121 |
122 | 64
123 | Shared
124 |
125 |
126 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\bin\cvutild.dll" "$(TargetDir)" /Y
127 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\bin\opencv_ffmpeg410_64.dll" "$(TargetDir)" /Y
128 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\bin\opencv_world410d.dll" "$(TargetDir)" /Y
129 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\PluginManager\bin\PluginManagerd.dll" "$(TargetDir)" /Y
130 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\bin\Qt5Chartsd.dll" "$(TargetDir)" /Y
131 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\bin\Qt5Cored.dll" "$(TargetDir)" /Y
132 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\bin\Qt5Guid.dll" "$(TargetDir)" /Y
133 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\bin\Qt5Widgetsd.dll" "$(TargetDir)" /Y
134 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\RoiManager\bin\RoiManagerd.dll" "$(TargetDir)" /Y
135 |
136 |
137 |
138 |
139 |
140 | Level3
141 |
142 |
143 | MaxSpeed
144 | true
145 | true
146 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
147 |
148 |
149 | Console
150 | true
151 | true
152 | true
153 | true
154 |
155 |
156 |
157 |
158 | Level3
159 |
160 |
161 | Full
162 | true
163 | true
164 | NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
165 | Speed
166 |
167 |
168 |
169 |
170 | Windows
171 | true
172 | true
173 | true
174 | cudart.lib;opencv_world410.lib;cvutil.lib;Qt5Widgets.lib;Qt5Core.lib;Qt5Charts.lib;Qt5Gui.lib;qtmain.lib;PluginManager.lib;RoiManager.lib;%(AdditionalDependencies)
175 |
176 |
177 | true
178 |
179 |
180 | 64
181 | Shared
182 |
183 |
184 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\bin\cvutil.dll" "$(TargetDir)" /Y
185 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\bin\opencv_ffmpeg410_64.dll" "$(TargetDir)" /Y
186 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\bin\opencv_world410.dll" "$(TargetDir)" /Y
187 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\PluginManager\bin\PluginManager.dll" "$(TargetDir)" /Y
188 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\bin\Qt5Charts.dll" "$(TargetDir)" /Y
189 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\bin\Qt5Core.dll" "$(TargetDir)" /Y
190 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\bin\Qt5Gui.dll" "$(TargetDir)" /Y
191 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\cvutil\bin\Qt5Widgets.dll" "$(TargetDir)" /Y
192 | xcopy "C:\Users\aseethepalli\Documents\projects\GITRepositories\cvutil\build\RoiManager\bin\RoiManager.dll" "$(TargetDir)" /Y
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 | Designer
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
--------------------------------------------------------------------------------
/RhizoVisionExplorer/RhizoVisionExplorer.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 | Source Files
32 |
33 |
34 | Source Files
35 |
36 |
37 |
38 |
39 | Header Files
40 |
41 |
42 | Header Files
43 |
44 |
45 | Header Files
46 |
47 |
48 | Source Files
49 |
50 |
51 | Header Files
52 |
53 |
54 | Header Files
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | Resource Files
64 |
65 |
66 |
67 |
68 | Resource Files
69 |
70 |
71 |
--------------------------------------------------------------------------------
/RhizoVisionExplorer/RhizoVisionExplorer.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/RhizoVisionExplorer/common_types.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2021, Anand Seethepalli and Larry York
3 | Copyright (C) 2020, Courtesy of Noble Research Institute, LLC
4 |
5 | File: common_types.h
6 |
7 | Authors:
8 | Anand Seethepalli (anand.seethepalli@yahoo.co.in)
9 | Larry York (larry.york@gmail.com)
10 |
11 | This file is part of RhizoVision Explorer.
12 |
13 | RhizoVision Explorer is free software: you can redistribute
14 | it and/or modify it under the terms of the GNU General Public
15 | License as published by the Free Software Foundation, either
16 | version 3 of the License, or (at your option) any later version.
17 |
18 | RhizoVision Explorer is distributed in the hope that it will
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
21 | PURPOSE. See the GNU General Public License for more details.
22 |
23 | You should have received a copy of the GNU General Public
24 | License along with RhizoVision Explorer; see the file COPYING.
25 | If not, see .
26 | */
27 |
28 | #pragma once
29 |
30 | #ifndef COMMON_TYPES_H
31 | #define COMMON_TYPES_H
32 |
33 | #include
34 |
35 | using namespace cvutil;
36 |
37 | template
38 | using ListRef = std::vector&;
39 |
40 | typedef ListRef IndexList;
41 | typedef std::vector Indices;
42 | typedef ListRef ValueList;
43 | typedef std::vector Values;
44 |
45 | typedef ListRef PointList;
46 | typedef std::vector Points;
47 |
48 | template
49 | using ListofListsRef = std::vector>&;
50 |
51 | template
52 | using ListofLists = std::vector>;
53 |
54 | template
55 | using ListofListsPtr = std::vector>*;
56 |
57 | template
58 | using Dictionary = std::unordered_map;
59 |
60 | template
61 | using DictionaryRef = std::unordered_map&;
62 |
63 | #endif
64 |
--------------------------------------------------------------------------------
/RhizoVisionExplorer/demo.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2021, Anand Seethepalli and Larry York
3 | Copyright (C) 2020, Courtesy of Noble Research Institute, LLC
4 |
5 | File: demo.h
6 |
7 | Authors:
8 | Anand Seethepalli (anand.seethepalli@yahoo.co.in)
9 | Larry York (larry.york@gmail.com)
10 |
11 | This file is part of RhizoVision Explorer.
12 |
13 | RhizoVision Explorer is free software: you can redistribute
14 | it and/or modify it under the terms of the GNU General Public
15 | License as published by the Free Software Foundation, either
16 | version 3 of the License, or (at your option) any later version.
17 |
18 | RhizoVision Explorer is distributed in the hope that it will
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
21 | PURPOSE. See the GNU General Public License for more details.
22 |
23 | You should have received a copy of the GNU General Public
24 | License along with RhizoVision Explorer; see the file COPYING.
25 | If not, see .
26 | */
27 |
28 | #pragma once
29 |
30 | #ifndef DEMO_H
31 | #define DEMO_H
32 |
33 | #include "cvutil.h"
34 |
35 | #include
36 |
37 | std::vector> getholes(std::vector> cc, cv::Size sz)
38 | {
39 | std::vector> result;
40 | int outercomp = -1, nr, nc;
41 | result.resize(cc.size() - 1);
42 |
43 | for (int i = 0; i < cc.size(); i++)
44 | {
45 | for (int j = 0; j < cc[i].size(); j++)
46 | {
47 | nr = cc[i][j] / sz.width;
48 | nc = cc[i][j] % sz.width;
49 |
50 | if (nr == 0 || nc == 0 ||
51 | nr == (sz.height - 1) ||
52 | nc == (sz.width - 1))
53 | {
54 | outercomp = i;
55 | break;
56 | }
57 | }
58 | }
59 |
60 | for (int i = 0, j = 0; i < cc.size(); i++)
61 | {
62 | if (i != outercomp)
63 | {
64 | result[j] = cc[i];
65 | j++;
66 | }
67 | }
68 |
69 | return result;
70 | }
71 |
72 | std::vector getComponentCentroid(std::vector> cc, cv::Size sz)
73 | {
74 | unsigned long long rowsum, colsum;
75 | std::vector result;
76 | result.resize(cc.size());
77 |
78 | for (int i = 0; i < cc.size(); i++)
79 | {
80 | rowsum = 0;
81 | colsum = 0;
82 |
83 | for (int j = 0; j < cc[i].size(); j++)
84 | {
85 | rowsum += (cc[i][j] / sz.width);
86 | colsum += (cc[i][j] % sz.width);
87 | }
88 |
89 | rowsum /= cc[i].size();
90 | colsum /= cc[i].size();
91 | result[i] = rowsum * sz.width + colsum;
92 | }
93 |
94 | return result;
95 | }
96 |
97 | cv::Mat pdist2(std::vector pts, cv::Size sz)
98 | {
99 | cv::Mat m = cv::Mat(pts);
100 | m.convertTo(m, CV_32FC1);
101 | cv::Mat mr, mc, repmr, repmc, sqrepmr, sqrepmc, result;
102 |
103 | mr = floor(m / sz.width);
104 | mc = m - floor(m / sz.width) * sz.width;
105 |
106 | repmr = repeat(mr, 1, mr.rows);
107 | sqrepmr = repmr.mul(repmr);
108 |
109 | repmc = repeat(mc, 1, mc.rows);
110 | sqrepmc = repmc.mul(repmc);
111 |
112 | result = sqrepmr + sqrepmr.t() + ((repmr.mul(repmr.t())) * (-2));
113 | result = result + sqrepmc + sqrepmc.t() + ((repmc.mul(repmc.t())) * (-2));
114 |
115 | return result;
116 | }
117 |
118 | cv::Mat getnearestcomponents(cv::Mat distmap)
119 | {
120 | cv::Mat result = cv::Mat::zeros(distmap.rows, 4, CV_32SC1);
121 | int *resultptr = result.ptr();
122 | float *distptr = distmap.ptr();
123 | std::vector val = { FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX };
124 | std::vector pos = { -1, -1, -1, -1 };
125 |
126 | for (int i = 0; i < distmap.rows; i++)
127 | {
128 | val = { FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX };
129 | pos = { -1, -1, -1, -1 };
130 |
131 | for (int j = i + 1; j < distmap.rows; j++)
132 | {
133 | if (distptr[j] < val[0])
134 | {
135 | pos[3] = pos[2];
136 | val[3] = val[2];
137 |
138 | pos[2] = pos[1];
139 | val[2] = val[1];
140 |
141 | pos[1] = pos[0];
142 | val[1] = val[0];
143 |
144 | pos[0] = j;
145 | val[0] = distptr[j];
146 | }
147 | else if (distptr[j] < val[1])
148 | {
149 | pos[3] = pos[2];
150 | val[3] = val[2];
151 |
152 | pos[2] = pos[1];
153 | val[2] = val[1];
154 |
155 | pos[1] = j;
156 | val[1] = distptr[j];
157 | }
158 | else if (distptr[j] < val[2])
159 | {
160 | pos[3] = pos[2];
161 | val[3] = val[2];
162 |
163 | pos[2] = j;
164 | val[2] = distptr[j];
165 | }
166 | else if (distptr[j] < val[3])
167 | {
168 | pos[3] = j;
169 | val[3] = distptr[j];
170 | }
171 | }
172 |
173 | resultptr[i * 4] = pos[0];
174 | resultptr[i * 4 + 1] = pos[1];
175 | resultptr[i * 4 + 2] = pos[2];
176 | resultptr[i * 4 + 3] = pos[3];
177 | }
178 |
179 | return result;
180 | }
181 |
182 | std::vector getcolorcodes(cv::Mat nearest)
183 | {
184 | std::vector result;
185 | int *nearestptr = nearest.ptr();
186 | result.resize(nearest.rows);
187 | std::vector colors = { 1,2,3,4,5 }, cols, vcols;
188 | std::unordered_map cm;
189 | int found = 0;
190 | std::random_device rng;
191 | std::mt19937 urng(rng());
192 |
193 | for (int i = 0; i < nearest.rows; i++)
194 | {
195 | if (i == 0)
196 | {
197 | result[i] = colors[0];
198 | cm[i] = colors[0];
199 |
200 | for (int j = 0; j < 4; j++)
201 | {
202 | result[nearestptr[i * 4 + j]] = colors[j + 1];
203 | cm[nearestptr[i * 4 + j]] = colors[j + 1];
204 | }
205 |
206 | continue;
207 | }
208 |
209 | cols.clear();
210 | vcols.clear();
211 |
212 | if (cm[i] != 0)
213 | cols.push_back(cm[i]);
214 |
215 | for (int j = 0; j < 4; j++)
216 | {
217 | if (nearestptr[i * 4 + j] != -1 && cm[nearestptr[i * 4 + j]] != 0)
218 | cols.push_back(cm[nearestptr[i * 4 + j]]);
219 | }
220 |
221 | for (int j = 0; j < colors.size(); j++)
222 | {
223 | found = 0;
224 |
225 | for (int k = 0; k < cols.size(); k++)
226 | {
227 | if (cols[k] == colors[j])
228 | {
229 | found = 1;
230 | break;
231 | }
232 | }
233 |
234 | if (found == 0)
235 | vcols.push_back(colors[j]);
236 | }
237 |
238 | std::shuffle(vcols.begin(), vcols.end(), urng);
239 |
240 | if (cm[i] == 0)
241 | {
242 | result[i] = vcols[0];
243 | cm[i] = vcols[0];
244 |
245 | for (int j = 0, k = 1; j < 4; j++)
246 | {
247 | if (nearestptr[i * 4 + j] != -1 && cm[nearestptr[i * 4 + j]] == 0)
248 | {
249 | result[nearestptr[i * 4 + j]] = vcols[k];
250 | cm[nearestptr[i * 4 + j]] = vcols[k];
251 | k++;
252 | }
253 | }
254 | }
255 | else
256 | {
257 | for (int j = 0, k = 0; j < 4; j++)
258 | {
259 | if (nearestptr[i * 4 + j] != -1 && cm[nearestptr[i * 4 + j]] == 0)
260 | {
261 | result[nearestptr[i * 4 + j]] = vcols[k];
262 | cm[nearestptr[i * 4 + j]] = vcols[k];
263 | k++;
264 | }
265 | }
266 | }
267 | }
268 |
269 | return result;
270 | }
271 |
272 | #endif
273 |
--------------------------------------------------------------------------------
/RhizoVisionExplorer/icons/RVElogoclearback-150.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/predictivephenomics/RhizoVisionExplorer/42750c9d238153dd2d707267c70dcbe66e302083/RhizoVisionExplorer/icons/RVElogoclearback-150.png
--------------------------------------------------------------------------------
/RhizoVisionExplorer/icons/RVElogoclearback.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/predictivephenomics/RhizoVisionExplorer/42750c9d238153dd2d707267c70dcbe66e302083/RhizoVisionExplorer/icons/RVElogoclearback.png
--------------------------------------------------------------------------------
/RhizoVisionExplorer/icons/rveicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/predictivephenomics/RhizoVisionExplorer/42750c9d238153dd2d707267c70dcbe66e302083/RhizoVisionExplorer/icons/rveicon.ico
--------------------------------------------------------------------------------
/RhizoVisionExplorer/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2021, Anand Seethepalli and Larry York
3 | Copyright (C) 2020, Courtesy of Noble Research Institute, LLC
4 |
5 | File: main.cpp
6 |
7 | Authors:
8 | Anand Seethepalli (anand.seethepalli@yahoo.co.in)
9 | Larry York (larry.york@gmail.com)
10 |
11 | This file is part of RhizoVision Explorer.
12 |
13 | RhizoVision Explorer is free software: you can redistribute
14 | it and/or modify it under the terms of the GNU General Public
15 | License as published by the Free Software Foundation, either
16 | version 3 of the License, or (at your option) any later version.
17 |
18 | RhizoVision Explorer is distributed in the hope that it will
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
21 | PURPOSE. See the GNU General Public License for more details.
22 |
23 | You should have received a copy of the GNU General Public
24 | License along with RhizoVision Explorer; see the file COPYING.
25 | If not, see .
26 | */
27 |
28 | #include
29 |
30 | #include
31 | #include
32 |
33 | #include "common_types.h"
34 | #include "roottopology.h"
35 | #include "rootsegmentprop.h"
36 | #include "demo.h"
37 | #include "MainUI.h"
38 |
39 | #include
40 |
41 | using namespace std;
42 | using namespace cv;
43 | using namespace cvutil;
44 |
45 | //#ifdef NDEBUG
46 | //#define DEBUG_MODE
47 | //#endif
48 |
49 | ///////////////// Program configuration data ///////////////
50 | const string saveloc = "C:/Users/aseethepalli/Documents/projects/hundredhours2/";
51 | const string features_filename = "./pics/features.txt";
52 | //const double pixel2mm = 127 / 2408.2; //1.0; // 76.0 / 784.2;
53 | const bool showprocessedimage = true;
54 | Ptr vseg, vpro;
55 | int rwidth1 = 400, rwidth2 = 400, cwidth1 = 800, cwidth2 = 800;
56 | ////////////////////////////////////////////////////////////
57 |
58 | void getMedianMaxRootNumbers(Mat seg, double &medrtno, double &maxrtno)
59 | {
60 | Mat seg1, seg2, diff, m, m2;
61 | double *mptr;
62 | int zidx = 0;
63 |
64 | hconcat(Mat::zeros(seg.rows, 1, seg.type()), seg, seg1);
65 | hconcat(seg, Mat::zeros(seg.rows, 1, seg.type()), seg2);
66 | diff = seg1 - seg2;
67 |
68 | diff = (diff > 0) / 255;
69 | reduce(diff, m, 1, CV_REDUCE_SUM, CV_MAKE_TYPE(CV_MAT_DEPTH(CV_64F), diff.channels()));
70 |
71 | std::sort(m.ptr(), m.ptr() + m.rows);
72 | //cv::sort(m, m2, cv::SortFlags::SORT_DESCENDING);
73 | mptr = m.ptr();
74 | maxrtno = mptr[m.rows - 1];
75 |
76 | for (; mptr[zidx] == 0; zidx++);
77 |
78 | medrtno = ((m.rows - zidx) % 2 == 0) ? ((mptr[(m.rows - zidx) / 2 + zidx] + mptr[(m.rows - zidx) / 2 - 1 + zidx]) / 2.0)
79 | : mptr[(m.rows - zidx) / 2 + zidx];
80 | }
81 |
82 | double getperimeterlength(vector> &contours)
83 | {
84 | double perimeter = 0.0;
85 | Point diff;
86 |
87 | for (auto &c : contours)
88 | {
89 | for (int i = 0; i < (c.size() - 1); i++)
90 | {
91 | diff = c[i] - c[i + 1];
92 | perimeter += sqrt(diff.ddot(diff));
93 | }
94 |
95 | diff = c[0] - c[c.size() - 1];
96 | perimeter += sqrt(diff.ddot(diff));
97 | }
98 |
99 | return perimeter;
100 | }
101 |
102 | void getavgrootradius(ListofListsRef radii, double &medradius, double& avgradius)
103 | {
104 | int rsize = 0;
105 | avgradius = 0.0;
106 | medradius = 0.0;
107 | Values rd;
108 |
109 | if (radii.size() == 0)
110 | return;
111 |
112 | for (int i = 0; i < radii.size(); i++)
113 | rd.insert(rd.end(), radii[i].begin(), radii[i].end());
114 |
115 | sort(rd.begin(), rd.end());
116 |
117 | if ((rd.size() % 2) == 0)
118 | medradius = (rd[rd.size() / 2 - 1] + rd[rd.size() / 2]) / 2.0;
119 | else
120 | medradius = rd[rd.size() / 2 - 1];
121 |
122 | for (int i = 0; i < radii.size(); i++)
123 | {
124 | for (int j = 0; j < radii[i].size(); j++)
125 | avgradius += radii[i][j];
126 |
127 | rsize += static_cast(radii[i].size());
128 | }
129 |
130 | avgradius /= double(rsize);
131 | }
132 |
133 | void getvolumesurfacearea(Mat skeleton, Mat dist, ListofListsRef segments, PointList overlap, double& volume, double& surfacearea)
134 | {
135 | int i, j, x, y, xinc, yinc, currx, curry, nextx, nexty, nnextpt, fxinc, fyinc;
136 | double rad = 0, sqr = sqrt(2), dv = 0, dvol = 0, dsa = 0;
137 | size_t cisz;
138 |
139 | float *dtptr = dist.ptr();
140 | uchar *skel = skeleton.ptr();
141 |
142 | volume = 0.0;
143 | surfacearea = 0.0;
144 |
145 | for (i = 0; i < segments.size(); i++)
146 | {
147 | cisz = segments[i].size() - 1;
148 |
149 | for (j = 0; j < cisz; j++)
150 | {
151 | nnextpt = j + 1;
152 |
153 | currx = segments[i][j].x;
154 | curry = segments[i][j].y;
155 | nextx = segments[i][nnextpt].x;
156 | nexty = segments[i][nnextpt].y;
157 |
158 | if (nextx != currx)
159 | xinc = abs(currx - nextx) / (nextx - currx);
160 | else
161 | xinc = 0;
162 |
163 | if (nexty != curry)
164 | yinc = abs(curry - nexty) / (nexty - curry);
165 | else
166 | yinc = 0;
167 |
168 | fxinc = fabs(xinc);
169 | fyinc = fabs(yinc);
170 | rad = fxinc + fyinc;
171 | rad = (rad == 2.0) ? CVUTIL_SQRT2 : rad;
172 |
173 | for (x = currx, y = curry; !(x == nextx && y == nexty); x += xinc, y += yinc)
174 | {
175 | dv = dtptr[y * dist.cols + x];
176 | dvol += (CV_PI * dv * dv * rad);
177 | dsa += (2.0 * CV_PI * dv * rad);
178 | }
179 | }
180 |
181 | /*dv = dtptr[y * dist.cols + x];
182 | dvol += (CV_PI * dv * dv);
183 | dsa += (2.0 * CV_PI * dv);*/
184 | }
185 |
186 | for (auto &overlappt : overlap)
187 | {
188 | // To check if the overlappt is a diagonal or orthogonal
189 | if (skel[overlappt.y * skeleton.cols + overlappt.x + 1] > 0)
190 | {
191 | // Orthogonal
192 | dv = dtptr[overlappt.y * dist.cols + overlappt.x];
193 | dvol += (CV_PI * dv * dv);
194 | dsa += (2.0 * CV_PI * dv);
195 | }
196 | else
197 | {
198 | // Diagonal
199 | dv = dtptr[overlappt.y * dist.cols + overlappt.x];
200 | dvol += (CV_PI * dv * dv * CVUTIL_SQRT2);
201 | dsa += (2.0 * CV_PI * dv * CVUTIL_SQRT2);
202 | }
203 | }
204 |
205 | volume = dvol;
206 | surfacearea = dsa;
207 | }
208 |
209 | void getdiameterrangehistograms(Mat skeleton, Mat dist, ListofListsRef segments, PointList overlap, Values rranges,
210 | ValueList rootlengthhist, ValueList projareahist, ValueList sahist, ValueList vhist, double &rootlength, double &volume, double &sarea)
211 | /*double& coarse, double& medium, double& fine*///double dlo, double dhi)
212 | {
213 | int i, j, k, x, y, xinc, yinc, currx, curry, nextx, nexty, nnextpt, fxinc, fyinc, didx;
214 | double rad = 0, sqr = sqrt(2.0), dv = 0;
215 | size_t cisz;
216 |
217 | size_t rsize = rranges.size();
218 | rootlengthhist.resize(rsize + 1);
219 | projareahist.resize(rsize + 1);
220 | sahist.resize(rsize + 1);
221 | vhist.resize(rsize + 1);
222 |
223 | Mat radrange = Mat::zeros(dist.size(), CV_8UC1);
224 |
225 | if (rsize > 0)
226 | {
227 | for (k = 0; k < (rsize - 1); k++)
228 | {
229 | rootlengthhist[k] = 0.0;
230 | projareahist[k] = 0.0;
231 | sahist[k] = 0.0;
232 | vhist[k] = 0.0;
233 |
234 | radrange = radrange + (((dist <= rranges[k + 1]) - (dist <= rranges[k])) / 255u) * uint8_t(k + 1);
235 | }
236 |
237 | rootlengthhist[rsize - 1] = 0.0;
238 | projareahist[rsize - 1] = 0.0;
239 | sahist[rsize - 1] = 0.0;
240 | vhist[rsize - 1] = 0.0;
241 |
242 | radrange = radrange + ((dist > rranges[rsize - 1]) / 255u) * uint8_t(rsize);
243 | }
244 | else
245 | {
246 | rootlengthhist[0] = 0.0;
247 | projareahist[0] = 0.0;
248 | sahist[0] = 0.0;
249 | vhist[0] = 0.0;
250 | }
251 |
252 | float *dtptr = dist.ptr();
253 | uchar *skel = skeleton.ptr();
254 | uchar *rptr = radrange.ptr();
255 |
256 | for (i = 0; i < segments.size(); i++)
257 | {
258 | cisz = segments[i].size() - 1;
259 |
260 | for (j = 0; j < cisz; j++)
261 | {
262 | nnextpt = j + 1;
263 |
264 | currx = segments[i][j].x;
265 | curry = segments[i][j].y;
266 | nextx = segments[i][nnextpt].x;
267 | nexty = segments[i][nnextpt].y;
268 |
269 | if (nextx != currx)
270 | xinc = abs(currx - nextx) / (nextx - currx);
271 | else
272 | xinc = 0;
273 |
274 | if (nexty != curry)
275 | yinc = abs(curry - nexty) / (nexty - curry);
276 | else
277 | yinc = 0;
278 |
279 | fxinc = fabs(xinc);
280 | fyinc = fabs(yinc);
281 | rad = fxinc + fyinc;
282 | rad = (rad == 2.0) ? CVUTIL_SQRT2 : rad;
283 |
284 | for (x = currx, y = curry; !(x == nextx && y == nexty); x += xinc, y += yinc)
285 | {
286 | dv = dtptr[y * dist.cols + x];
287 | didx = rptr[y * dist.cols + x];
288 |
289 | rootlengthhist[didx] += rad;
290 | projareahist[didx] += (2 * dv * rad);
291 | vhist[didx] += (CV_PI * dv * dv * rad);
292 | sahist[didx] += (2.0 * CV_PI * dv * rad);
293 | }
294 | }
295 |
296 | /*dv = dtptr[y * dist.cols + x];
297 | didx = rptr[y * dist.cols + x];
298 |
299 | rootlengthhist[didx] += rad;
300 | projareahist[didx] += (2 * dv * rad);
301 | vhist[didx] += (CV_PI * dv * dv * rad);
302 | sahist[didx] += (2.0 * CV_PI * dv * rad);
303 | */
304 | }
305 |
306 | for (auto &overlappt : overlap)
307 | {
308 | // To check if the overlappt is a diagonal or orthogonal
309 | if (skel[overlappt.y * skeleton.cols + overlappt.x + 1] > 0)
310 | {
311 | // Orthogonal
312 | dv = dtptr[overlappt.y * dist.cols + overlappt.x];
313 | didx = rptr[overlappt.y * dist.cols + overlappt.x];
314 |
315 | rootlengthhist[didx] += 1.0;
316 | //projareahist[didx] += (2 * dv * rad);
317 | vhist[didx] += (CV_PI * dv * dv);
318 | sahist[didx] += (2.0 * CV_PI * dv);
319 | }
320 | else
321 | {
322 | // Diagonal
323 | dv = dtptr[overlappt.y * dist.cols + overlappt.x];
324 | didx = rptr[overlappt.y * dist.cols + overlappt.x];
325 |
326 | rootlengthhist[didx] += CVUTIL_SQRT2;
327 | //projareahist[didx] += (2 * dv * rad);
328 | vhist[didx] += (CV_PI * dv * dv * CVUTIL_SQRT2);
329 | sahist[didx] += (2.0 * CV_PI * dv * CVUTIL_SQRT2);
330 | }
331 | }
332 |
333 | // Now to add the histograms to get total root length, volume
334 | // and surface area.
335 | rootlength = 0;
336 | volume = 0;
337 | sarea = 0;
338 | for (i = 0; i < rootlengthhist.size(); i++)
339 | {
340 | rootlength += rootlengthhist[i];
341 | volume += vhist[i];
342 | sarea += sahist[i];
343 | }
344 | }
345 |
346 | void getdiameterrangehistograms(Mat skeleton, Mat dist, ListofListsRef segments, PointList overlap, Values rranges,
347 | ValueList rootlengthhist, ValueList projareahist, ValueList sahist, ValueList vhist, double &rootlength, double &volume, double &sarea, Mat& rtdpoints)
348 | /*double& coarse, double& medium, double& fine*///double dlo, double dhi)
349 | {
350 | int i, j, k, x, y, xinc, yinc, currx, curry, nextx, nexty, nnextpt, fxinc, fyinc, didx;
351 | double rad = 0, sqr = sqrt(2.0), dv = 0;
352 | size_t cisz;
353 | map rdpoints;
354 |
355 | size_t rsize = rranges.size();
356 | rootlengthhist.resize(rsize + 1);
357 | projareahist.resize(rsize + 1);
358 | sahist.resize(rsize + 1);
359 | vhist.resize(rsize + 1);
360 |
361 | Mat radrange = Mat::zeros(dist.size(), CV_8UC1);
362 |
363 | if (rsize > 0)
364 | {
365 | for (k = 0; k < (rsize - 1); k++)
366 | {
367 | rootlengthhist[k] = 0.0;
368 | projareahist[k] = 0.0;
369 | sahist[k] = 0.0;
370 | vhist[k] = 0.0;
371 |
372 | radrange = radrange + (((dist <= rranges[k + 1]) - (dist <= rranges[k])) / 255u) * uint8_t(k + 1);
373 | }
374 |
375 | rootlengthhist[rsize - 1] = 0.0;
376 | projareahist[rsize - 1] = 0.0;
377 | sahist[rsize - 1] = 0.0;
378 | vhist[rsize - 1] = 0.0;
379 |
380 | radrange = radrange + ((dist > rranges[rsize - 1]) / 255u) * uint8_t(rsize);
381 | }
382 | else
383 | {
384 | rootlengthhist[0] = 0.0;
385 | projareahist[0] = 0.0;
386 | sahist[0] = 0.0;
387 | vhist[0] = 0.0;
388 | }
389 |
390 | float *dtptr = dist.ptr();
391 | uchar *skel = skeleton.ptr();
392 | uchar *rptr = radrange.ptr();
393 |
394 | for (i = 0; i < segments.size(); i++)
395 | {
396 | cisz = segments[i].size() - 1;
397 |
398 | for (j = 0; j < cisz; j++)
399 | {
400 | nnextpt = j + 1;
401 |
402 | currx = segments[i][j].x;
403 | curry = segments[i][j].y;
404 | nextx = segments[i][nnextpt].x;
405 | nexty = segments[i][nnextpt].y;
406 |
407 | if (nextx != currx)
408 | xinc = abs(currx - nextx) / (nextx - currx);
409 | else
410 | xinc = 0;
411 |
412 | if (nexty != curry)
413 | yinc = abs(curry - nexty) / (nexty - curry);
414 | else
415 | yinc = 0;
416 |
417 | fxinc = fabs(xinc);
418 | fyinc = fabs(yinc);
419 | rad = fxinc + fyinc;
420 | rad = (rad == 2.0) ? CVUTIL_SQRT2 : rad;
421 |
422 | for (x = currx, y = curry; !(x == nextx && y == nexty); x += xinc, y += yinc)
423 | {
424 | dv = dtptr[y * dist.cols + x];
425 | didx = rptr[y * dist.cols + x];
426 |
427 | rdpoints[dv] += rad;
428 |
429 | rootlengthhist[didx] += rad;
430 | projareahist[didx] += (2 * dv * rad);
431 | vhist[didx] += (CV_PI * dv * dv * rad);
432 | sahist[didx] += (2.0 * CV_PI * dv * rad);
433 | }
434 | }
435 |
436 | /*dv = dtptr[y * dist.cols + x];
437 | didx = rptr[y * dist.cols + x];
438 |
439 | rootlengthhist[didx] += rad;
440 | projareahist[didx] += (2 * dv * rad);
441 | vhist[didx] += (CV_PI * dv * dv * rad);
442 | sahist[didx] += (2.0 * CV_PI * dv * rad);
443 | */
444 | }
445 |
446 | for (auto &overlappt : overlap)
447 | {
448 | // To check if the overlappt is a diagonal or orthogonal
449 | if (skel[overlappt.y * skeleton.cols + overlappt.x + 1] > 0)
450 | {
451 | // Orthogonal
452 | dv = dtptr[overlappt.y * dist.cols + overlappt.x];
453 | didx = rptr[overlappt.y * dist.cols + overlappt.x];
454 |
455 | rdpoints[dv] += 1.0;
456 |
457 | rootlengthhist[didx] += 1.0;
458 | //projareahist[didx] += (2 * dv * rad);
459 | vhist[didx] += (CV_PI * dv * dv);
460 | sahist[didx] += (2.0 * CV_PI * dv);
461 | }
462 | else
463 | {
464 | // Diagonal
465 | dv = dtptr[overlappt.y * dist.cols + overlappt.x];
466 | didx = rptr[overlappt.y * dist.cols + overlappt.x];
467 |
468 | rdpoints[dv] += CVUTIL_SQRT2;
469 |
470 | rootlengthhist[didx] += CVUTIL_SQRT2;
471 | //projareahist[didx] += (2 * dv * rad);
472 | vhist[didx] += (CV_PI * dv * dv * CVUTIL_SQRT2);
473 | sahist[didx] += (2.0 * CV_PI * dv * CVUTIL_SQRT2);
474 | }
475 | }
476 |
477 | rtdpoints = Mat::zeros(static_cast(rdpoints.size()), 2, CV_64FC1);
478 | double *rtdptr = rtdpoints.ptr();
479 |
480 | int rtdidx = 0;
481 | for (auto& kv : rdpoints)
482 | {
483 | rtdptr[2 * rtdidx] = kv.first;
484 | rtdptr[2 * rtdidx + 1] = kv.second;
485 |
486 | rtdidx++;
487 | }
488 |
489 | // Now to add the histograms to get total root length, volume
490 | // and surface area.
491 | rootlength = 0;
492 | volume = 0;
493 | sarea = 0;
494 | for (i = 0; i < rootlengthhist.size(); i++)
495 | {
496 | rootlength += rootlengthhist[i];
497 | volume += vhist[i];
498 | sarea += sahist[i];
499 | }
500 | }
501 |
502 | void getshallowdeeproots(ListofListsRef segments, double& shallow, double& medium, double& deep, double &avgangle)
503 | {
504 | shallow = 0.0;
505 | medium = 0.0;
506 | deep = 0.0;
507 | avgangle = 0.0;
508 |
509 | Mat m, m2, cov, me, lam, ev;
510 | double *evptr = nullptr;
511 | int i, j, k, x, y, nnextpt, currx, curry, nextx, nexty, xinc, yinc;
512 | size_t csz = segments.size(), cisz = 0, szcount = 0;
513 | int wsize = 20, nsamples = 0, npoints = 0, minv = 0, maxv = 0;
514 | double angle = 0;
515 |
516 | m.create(10000, 2, CV_64FC1);
517 | m2.create(wsize * wsize * 4, 2, CV_64FC1);
518 |
519 | double *mptr = m.ptr(), *mptr2 = m2.ptr();
520 |
521 | for (i = 0, szcount = 0; i < csz; i++)
522 | {
523 | if (segments[i].size() <= 1)
524 | continue;
525 |
526 | // To reconstruct the full segment before getting
527 | // angle stats.
528 | cisz = segments[i].size() - 1;
529 | //szcount += cisz;
530 |
531 | //cout << "szcount = " << szcount << endl;
532 |
533 | for (j = 0, nsamples = 0; j < cisz; j++)
534 | {
535 | nnextpt = (j + 1);
536 | currx = segments[i][j].x;
537 | curry = segments[i][j].y;
538 | nextx = segments[i][nnextpt].x;
539 | nexty = segments[i][nnextpt].y;
540 | xinc = (currx == nextx) ? 0 : abs(currx - nextx) / (nextx - currx);
541 | yinc = (curry == nexty) ? 0 : abs(curry - nexty) / (nexty - curry);
542 |
543 | for (x = currx, y = curry; !(x == nextx && y == nexty); x += xinc, y += yinc)
544 | {
545 | mptr[nsamples * 2] = x;
546 | mptr[nsamples * 2 + 1] = y;
547 | nsamples++;
548 | }
549 | }
550 |
551 | mptr[nsamples * 2] = nextx;
552 | mptr[nsamples * 2 + 1] = nexty;
553 | nsamples++;
554 |
555 | // Now to browse through the segment using a
556 | // (2 * wsize + 1)-by-(2 * wsize + 1) window
557 | // and recording the orientation using the
558 | // eigen vectors from the covariance matix.
559 | for (j = 0; j < nsamples; j++)
560 | {
561 | npoints = 0;
562 |
563 | for (k = j;
564 | k < nsamples &&
565 | abs(mptr[j * 2] - mptr[k * 2]) <= wsize &&
566 | abs(mptr[j * 2 + 1] - mptr[k * 2 + 1]) <= wsize;
567 | k++)
568 | {
569 | mptr2[npoints * 2] = mptr[k * 2];
570 | mptr2[npoints * 2 + 1] = mptr[k * 2 + 1];
571 | npoints++;
572 | }
573 |
574 | for (k = (j - 1);
575 | k >= 0 &&
576 | abs(mptr[j * 2] - mptr[k * 2]) <= wsize &&
577 | abs(mptr[j * 2 + 1] - mptr[k * 2 + 1]) <= wsize;
578 | k--)
579 | {
580 | mptr2[npoints * 2] = mptr[k * 2];
581 | mptr2[npoints * 2 + 1] = mptr[k * 2 + 1];
582 | npoints++;
583 | }
584 |
585 | if (npoints > 1)
586 | {
587 | calcCovarMatrix(m2.rowRange(0, npoints), cov, me, COVAR_ROWS | COVAR_NORMAL);
588 | eigen(cov, lam, ev);
589 | evptr = ev.ptr();
590 | angle = abs((atan(evptr[1] / evptr[0]) * 180.0) / CV_PI);
591 |
592 | avgangle = ((szcount * avgangle) + angle) / (szcount + 1);
593 | szcount++;
594 |
595 | if (angle <= 30) //(CV_PI / 6))
596 | shallow++;
597 | else if (angle <= 60) //(CV_PI / 3))
598 | medium++;
599 | else
600 | deep++;
601 | }
602 | }
603 | }
604 |
605 | angle = deep + medium + shallow;
606 | shallow /= angle;
607 | medium /= angle;
608 | deep /= angle;
609 | //avgangle /= szcount;
610 |
611 | m.release();
612 | m2.release();
613 | }
614 |
615 | void getshallowdeeprootsth(ListofListsRef segments, double& shallow, double& medium, double& deep, double &avgangle)
616 | {
617 | shallow = 0.0;
618 | medium = 0.0;
619 | deep = 0.0;
620 | avgangle = 0.0;
621 |
622 | int nthreads = getNumberOfCPUs() - 3;
623 | vector t(nthreads);
624 | vector tshallow(nthreads), tdeep(nthreads), tmedium(nthreads), tavgangle(nthreads), tcount(nthreads);
625 | vector m(nthreads), m2(nthreads);
626 | double anglev = 0, ncount = 0;
627 |
628 | for (int th = 0; th < nthreads; th++)
629 | {
630 | t[th] = thread([&](int thr)
631 | {
632 | int npoints = 0;
633 | Mat cov, me, lam, ev;
634 | double *evptr = nullptr;
635 | int i, j, k, x, y, nnextpt, currx, curry, nextx, nexty, xinc, yinc;
636 | size_t csz = segments.size(), cisz = 0, szcount = 0;
637 | int wsize = 20, nsamples = 0, minv = 0, maxv = 0;
638 | double angle = 0;
639 |
640 | m[thr].create(10000, 2, CV_64FC1);
641 | m2[thr].create(wsize * wsize * 4, 2, CV_64FC1);
642 |
643 | double *mptr = m[thr].ptr(), *mptr2 = m2[thr].ptr();
644 |
645 | for (i = 0; i < csz; i++)
646 | {
647 | if (segments[i].size() <= 1)
648 | continue;
649 |
650 | // To reconstruct the full segment before getting
651 | // angle stats.
652 | cisz = segments[i].size() - 1;
653 | szcount += cisz;
654 |
655 | //cout << "szcount = " << szcount << endl;
656 |
657 | for (j = 0, nsamples = 0; j < cisz; j++)
658 | {
659 | nnextpt = (j + 1);
660 | currx = segments[i][j].x;
661 | curry = segments[i][j].y;
662 | nextx = segments[i][nnextpt].x;
663 | nexty = segments[i][nnextpt].y;
664 | xinc = (currx == nextx) ? 0 : abs(currx - nextx) / (nextx - currx);
665 | yinc = (curry == nexty) ? 0 : abs(curry - nexty) / (nexty - curry);
666 |
667 | for (x = currx, y = curry; (x != nextx && y != nexty); x += xinc, y += yinc)
668 | {
669 | mptr[nsamples * 2] = x;
670 | mptr[nsamples * 2 + 1] = y;
671 | nsamples++;
672 | }
673 | }
674 |
675 | mptr[nsamples * 2] = nextx;
676 | mptr[nsamples * 2 + 1] = nexty;
677 | nsamples++;
678 |
679 | // Now to browse through the segment using a
680 | // (2 * wsize + 1)-by-(2 * wsize + 1) window
681 | // and recording the orientation using the
682 | // eigen vectors from the covariance matix.
683 | for (j = 0; j < nsamples; j++)
684 | {
685 | npoints = 0;
686 |
687 | for (k = j;
688 | k < nsamples &&
689 | abs(mptr[j * 2] - mptr[k * 2]) <= wsize &&
690 | abs(mptr[j * 2 + 1] - mptr[k * 2 + 1]) <= wsize;
691 | k++)
692 | {
693 | mptr2[npoints * 2] = mptr[k * 2];
694 | mptr2[npoints * 2 + 1] = mptr[k * 2 + 1];
695 | npoints++;
696 | }
697 |
698 | for (k = (j - 1);
699 | k >= 0 &&
700 | abs(mptr[j * 2] - mptr[k * 2]) <= wsize &&
701 | abs(mptr[j * 2 + 1] - mptr[k * 2 + 1]) <= wsize;
702 | k--)
703 | {
704 | mptr2[npoints * 2] = mptr[k * 2];
705 | mptr2[npoints * 2 + 1] = mptr[k * 2 + 1];
706 | npoints++;
707 | }
708 |
709 | if (npoints > 1)
710 | {
711 | calcCovarMatrix(m2[thr].rowRange(0, npoints), cov, me, COVAR_ROWS);
712 | eigen(cov, lam, ev);
713 | evptr = ev.ptr();
714 | angle = abs((atan(evptr[1] / evptr[0]) * 180.0) / CV_PI);
715 | tavgangle[thr] += angle;
716 |
717 | if (angle <= 30) //(CV_PI / 6))
718 | tshallow[thr]++;
719 | else if (angle <= 60) //(CV_PI / 3))
720 | tmedium[thr]++;
721 | else
722 | tdeep[thr]++;
723 | }
724 | }
725 | }
726 |
727 | m[thr].release();
728 | m2[thr].release();
729 |
730 | tcount[thr] = szcount;
731 | }, th);
732 | }
733 |
734 | for (int th = 0; th < nthreads; th++)
735 | {
736 | t[th].join();
737 |
738 | deep += tdeep[th];
739 | medium += tmedium[th];
740 | shallow += tshallow[th];
741 |
742 | ncount += tcount[th];
743 | avgangle += tavgangle[th];
744 | }
745 |
746 | anglev = deep + medium + shallow;
747 | shallow /= anglev;
748 | medium /= anglev;
749 | deep /= anglev;
750 | avgangle /= ncount;
751 | }
752 |
753 | bool checkProgress(feature_config* config, QString str)
754 | {
755 | config->ui->updateProgress(str);
756 | QApplication::processEvents();
757 | return config->abortprocess;
758 | }
759 |
760 | //void feature_extractor(string filename, string savefolder, vector& featurevals, bool invertimage, bool saveseg, bool saveimages, bool pixelconv, double conversion, double rootlo, double roothi)
761 | void feature_extractor(feature_config* config)
762 | {
763 | Mat img, out, seg, lsim, lsimcropped, skel, dilatedskel, dist;
764 | Mat perimeter, hull, fhull, chull, dilatedhull, selement, merged, holes, pmap, nearest;
765 | vector> contours;
766 | vector> holepts;
767 | vector channels, hch;
768 | vector> hullpt;
769 | vector hierarchy;
770 | vector centroids, colorcodes;
771 | Points branchpts, endpts, overlappts;
772 | ListofLists rootsegments;
773 | ListofLists radii;
774 | double rootlength = -1.0, mediannoroots = -1.0, maxnoroots = -1.0;
775 | double perimeterlength = -1.0, medradius = -1.0, avgradius = -1.0, maxradius = -1.0;
776 | //double coarser = 0.0, mediumr = 0.0, finer = 0.0;
777 | Values rootlengthhist = {}, projareahist = {}, sahist = {}, vhist = {};
778 | double shallowo = 0.0, mediumo = 0.0, deepo = 0.0, avgang = 0.0;
779 | double volume = -1.0, surfacearea = -1.0, vtime;
780 | int maxradrowidx = -1, nholes = 0;
781 | double pixel2mm = 1.0, avgholesize = 0.0;
782 | bool isborder = false, isborderholefound = false;
783 | //double diameterlo = config->rootlo, diameterhi = config->roothi;
784 | vector radiusranges;
785 | double nwarea = 0, convarea = 0, widthtodepthratio = 0, lowerrootarea = 0;
786 | std::random_device rng;
787 | std::mt19937 urng(rng());
788 | int nfeatures;
789 | Mat rtdpoints;
790 | RotateFlags flag = ROTATE_90_CLOCKWISE, revflag = ROTATE_90_COUNTERCLOCKWISE;
791 |
792 | switch (config->rotation)
793 | {
794 | case 90:
795 | flag = ROTATE_90_CLOCKWISE;
796 | revflag = ROTATE_90_COUNTERCLOCKWISE;
797 | break;
798 | case 180:
799 | flag = ROTATE_180;
800 | revflag = ROTATE_180;
801 | break;
802 | case 270:
803 | flag = ROTATE_90_COUNTERCLOCKWISE;
804 | revflag = ROTATE_90_CLOCKWISE;
805 | break;
806 | }
807 |
808 | // Determine the number of features to be extracted
809 | if (config->roottype == 0) // crown root
810 | nfeatures = 24 + 4 * (static_cast(config->dranges.size()) + 1);
811 | else
812 | nfeatures = 12 + 4 * (static_cast(config->dranges.size()) + 1);
813 |
814 | #ifndef _DEBUG
815 | thread *t1;
816 | #endif
817 |
818 | vector> cc, colors =
819 | { { 228, 26, 28 },
820 | { 55, 126, 184 },
821 | { 77, 175, 74 },
822 | { 152, 78, 163 },
823 | { 255, 127, 0 } };
824 |
825 | if (config->pixelconv)
826 | {
827 | if (config->pixelspermm == 0) // For DPI conversion
828 | pixel2mm /= (config->conversion / 25.4);
829 | else
830 | pixel2mm /= config->conversion;
831 | //diameterlo *= config->conversion;
832 | //diameterhi *= config->conversion;
833 | }
834 |
835 | // If the diameter ranges are given in mm, we need
836 | // to convert it to pixel units.
837 | for (auto &d : config->dranges)
838 | {
839 | if (!config->pixelconv)
840 | radiusranges.push_back(d / 2.0);
841 | else
842 | radiusranges.push_back(d / 2.0 / pixel2mm);
843 | }
844 |
845 | if (config->rotation != 0)
846 | rotate(config->input, img, flag);
847 | else
848 | img = config->input.clone();
849 |
850 | if ((!config->batchmode) && checkProgress(config, "Thresholding the input image ..."))
851 | return;
852 |
853 | for (int ii = 0; ii < nfeatures; ii++)
854 | config->features.push_back(NAN);
855 |
856 | if (img.empty())
857 | {
858 | //for (int ii = 0; ii < nfeatures; ii++)
859 | // config->features.push_back(NAN);
860 |
861 | Mat m1 = Mat::zeros(out.size(), out.type());
862 | Mat m2 = Mat::ones(out.size(), out.type()) * 255u;
863 | if (!config->invertimage)
864 | m1 = (m1 < 128);
865 |
866 | if (config->rotation != 0)
867 | {
868 | rotate(m1, config->input, revflag);
869 | rotate(m2, config->processed, revflag);
870 | }
871 | else
872 | {
873 | config->seg = m1;
874 | config->processed = m2;
875 | }
876 |
877 | return;
878 | }
879 |
880 | srand(time(0));
881 | tic();
882 |
883 | if (config->invertimage)
884 | img = Scalar::all(255) - img;
885 |
886 | out = getSingleChannel(img < config->threshold, CV_8UC1);
887 |
888 | /*if (countNonZero(out) == 0)
889 | {
890 | Mat m1 = Mat::zeros(out.size(), out.type());
891 | Mat m2 = Mat::ones(out.size(), out.type()) * 255u;
892 | if (!config->invertimage)
893 | m1 = (m1 < 128);
894 |
895 | if (config->rotation != 0)
896 | {
897 | rotate(m1, config->input, revflag);
898 | rotate(m2, config->processed, revflag);
899 | }
900 | else
901 | {
902 | config->seg = m1;
903 | config->processed = m2;
904 | }
905 |
906 | return;
907 | }*/
908 |
909 | if ((!config->batchmode) && checkProgress(config, "Filtering noise ..."))
910 | return;
911 |
912 | if (config->roottype == 0 && config->keepLargest == true)
913 | seg = getLargestConnectedComponent(out);
914 | else
915 | {
916 | if ((!config->filterbknoise) && (!config->filterfgnoise))
917 | seg = out.clone();
918 | else
919 | {
920 | if (config->filterbknoise)
921 | seg = getImageFromComponents(out.size(), getConnectedComponents(out, (config->maxcompsizebk / pixel2mm) / pixel2mm));
922 | if (config->filterfgnoise)
923 | seg = 255 - getImageFromComponents(seg.size(), getConnectedComponents(255 - seg, (config->maxcompsizefg / pixel2mm) / pixel2mm));
924 | }
925 | }
926 |
927 | if (countNonZero(seg) == 0)
928 | {
929 | Mat m1 = Mat::zeros(out.size(), out.type());
930 | Mat m2 = Mat::ones(out.size(), out.type()) * 255u;
931 | if (!config->invertimage)
932 | m1 = (m1 < 128);
933 |
934 | if (config->rotation != 0)
935 | {
936 | rotate(m1, config->input, revflag);
937 | rotate(m2, config->processed, revflag);
938 | }
939 | else
940 | {
941 | config->seg = m1;
942 | config->processed = m2;
943 | }
944 |
945 | return;
946 | }
947 |
948 | out = Mat();
949 |
950 | Mat segcropped;
951 | auto fresultseg = find(seg>0, FindType::Subscripts);
952 | double rminseg = seg.rows, rmaxseg = -1, cminseg = seg.cols, cmaxseg = -1;
953 | int *rcpseg = fresultseg.first.ptr();
954 |
955 | #ifndef _DEBUG
956 | for (int ii = 0; ii < fresultseg.first.rows; ii++)
957 | {
958 | if (rminseg > rcpseg[2 * ii])
959 | rminseg = rcpseg[2 * ii];
960 | if (cminseg > rcpseg[2 * ii + 1])
961 | cminseg = rcpseg[2 * ii + 1];
962 | if (rmaxseg < rcpseg[2 * ii])
963 | rmaxseg = rcpseg[2 * ii];
964 | if (cmaxseg < rcpseg[2 * ii + 1])
965 | cmaxseg = rcpseg[2 * ii + 1];
966 | }
967 |
968 | if ((rmaxseg + 2) <= seg.rows)
969 | rmaxseg += 2;
970 | else
971 | rmaxseg++;
972 |
973 | if ((cmaxseg + 2) <= seg.cols)
974 | cmaxseg += 2;
975 | else
976 | cmaxseg++;
977 |
978 | if ((cminseg - 1) >= 0)
979 | cminseg --;
980 | #else
981 | rminseg = 0;
982 | rmaxseg = seg.rows;
983 | cminseg = 0;
984 | cmaxseg = seg.cols;
985 | #endif
986 |
987 | if ((rmaxseg - rminseg) == 1 || (cmaxseg - cminseg) == 1)
988 | {
989 | return;
990 | }
991 |
992 | if (rmaxseg > rminseg || cmaxseg > cminseg)
993 | segcropped = seg.rowRange(rminseg, rmaxseg).colRange(cminseg, cmaxseg).clone();
994 | else
995 | segcropped = seg.clone();
996 |
997 | if ((!config->batchmode) && checkProgress(config, "Simplifying contours ..."))
998 | return;
999 |
1000 | if (config->enablesmooththresh)
1001 | lsim = linesim(segcropped, LineSimplificationType::DouglasPeucker, config->smooththresh);
1002 | else
1003 | lsim = segcropped.clone();
1004 |
1005 | if ((!config->batchmode) && checkProgress(config, "Determining distance map ..."))
1006 | return;
1007 |
1008 | dist = bwdist(lsim);
1009 |
1010 | if ((!config->batchmode) && checkProgress(config, "Skeletonizing ..."))
1011 | return;
1012 |
1013 | skel = bwskel(lsim, dist);
1014 |
1015 | if ((!config->batchmode) && checkProgress(config, "Finding the contours ..."))
1016 | return;
1017 |
1018 | findContours(lsim.clone(), contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE);
1019 |
1020 | // Convex hull is determined only for whole roots.
1021 | if (config->roottype == 0)
1022 | {
1023 | if ((!config->batchmode) && checkProgress(config, "Finding the convex hull ..."))
1024 | return;
1025 |
1026 | hullpt.resize(1);
1027 | if (contours.size() > 0)
1028 | {
1029 | if (config->keepLargest)
1030 | convexHull(contours[0], hullpt[0], false);
1031 | else
1032 | {
1033 | // Combine all the contours before finding the convex hull that
1034 | // encapsulates all the contours.
1035 | size_t sz = 0;
1036 | vector cont;
1037 | for (auto& co : contours)
1038 | sz += co.size();
1039 | cont.reserve(sz);
1040 | for (auto& co : contours)
1041 | cont.insert(cont.end(), co.begin(), co.end());
1042 |
1043 | convexHull(cont, hullpt[0], false);
1044 | }
1045 | }
1046 | }
1047 |
1048 | if ((!config->batchmode) && checkProgress(config, "Finding the root topology ..."))
1049 | return;
1050 |
1051 | getroottopology(skel, dist, branchpts, endpts, overlappts, rootsegments, config->enableRootPruning, config->rootPruningThreshold);
1052 |
1053 | if ((!config->batchmode) && checkProgress(config, "Extracting the features ..."))
1054 | return;
1055 |
1056 | #ifndef _DEBUG
1057 | t1 = new thread([&]() {
1058 | #endif
1059 | if (config->roottype == 0)
1060 | {
1061 | getshallowdeeproots(rootsegments, shallowo, mediumo, deepo, avgang);
1062 |
1063 | holes = addBorder(lsim, 0);
1064 |
1065 | holepts = getConnectedComponents(255 - holes, -1, 4);
1066 | nholes = 0;
1067 | avgholesize = 0.0;
1068 |
1069 | for (auto &h : holepts)
1070 | {
1071 | isborder = false;
1072 |
1073 | if (!isborderholefound)
1074 | {
1075 | for (auto &hv : h)
1076 | {
1077 | if (hv == 0)
1078 | {
1079 | isborder = true;
1080 | isborderholefound = true;
1081 | break;
1082 | }
1083 | }
1084 | }
1085 |
1086 | if (!isborder)
1087 | {
1088 | avgholesize += h.size();
1089 | nholes++;
1090 | }
1091 | }
1092 |
1093 | avgholesize /= nholes;
1094 |
1095 | convarea = 0.0;
1096 |
1097 |
1098 | for (int i = 0, ni = 0; i < hullpt[0].size(); i++)
1099 | {
1100 | ni = ((i + 1) % hullpt[0].size());
1101 | convarea += double(hullpt[0][i].x * hullpt[0][ni].y - hullpt[0][ni].x * hullpt[0][i].y);
1102 | }
1103 |
1104 | convarea /= 2.0;
1105 | }
1106 | else
1107 | {
1108 | //getrootlength(skel, rootsegments, overlappts, rootlength);
1109 | //getvolumesurfacearea(skel, dist, rootsegments, overlappts, volume, surfacearea);
1110 |
1111 | //getMedianMaxRootNumbers(lsim, mediannoroots, maxnoroots);
1112 | perimeterlength = getperimeterlength(contours) * pixel2mm;
1113 | }
1114 |
1115 | nwarea = double(countNonZero(lsim));
1116 |
1117 | #ifndef _DEBUG
1118 | });
1119 | #endif
1120 | // We extract the root length, volume and surface area in a separate
1121 | // thread if the root type we are working is disconnected roots.
1122 | getrootradii(skel, lsim, dist, rootsegments, radii, maxradius, maxradrowidx);
1123 | //if (config->roottype == 0)
1124 | // getrootlength(skel, rootsegments, overlappts, rootlength);
1125 | getavgrootradius(radii, medradius, avgradius);
1126 | //if (config->roottype == 0)
1127 | // getvolumesurfacearea(skel, dist, rootsegments, overlappts, volume, surfacearea);
1128 |
1129 | if (config->batchmode)
1130 | getdiameterrangehistograms(skel, dist, rootsegments, overlappts, radiusranges, rootlengthhist, projareahist, sahist, vhist, rootlength, volume, surfacearea);
1131 | else
1132 | {
1133 | getdiameterrangehistograms(skel, dist, rootsegments, overlappts, radiusranges, rootlengthhist, projareahist, sahist, vhist, rootlength, volume, surfacearea, rtdpoints);
1134 | config->rtdpoints = rtdpoints;
1135 | }
1136 |
1137 | double rmin = 10000, rmax = -1, cmin = 10000, cmax = -1;
1138 |
1139 | if (config->roottype == 0)
1140 | {
1141 | auto fresult = find(lsim > 0, FindType::Subscripts);
1142 | int *rcp = fresult.first.ptr();
1143 | rmin = fresult.first.rows;
1144 | cmin = fresult.first.rows;
1145 |
1146 | for (int ii = 0; ii < fresult.first.rows; ii++)
1147 | {
1148 | if (rmin > rcp[2 * ii])
1149 | rmin = rcp[2 * ii];
1150 | if (cmin > rcp[2 * ii + 1])
1151 | cmin = rcp[2 * ii + 1];
1152 | if (rmax < rcp[2 * ii])
1153 | rmax = rcp[2 * ii];
1154 | if (cmax < rcp[2 * ii + 1])
1155 | cmax = rcp[2 * ii + 1];
1156 | }
1157 |
1158 | rmax++;
1159 | cmax++;
1160 | widthtodepthratio = double(cmax - cmin) / double(rmax - rmin);
1161 |
1162 | getMedianMaxRootNumbers(lsim, mediannoroots, maxnoroots);
1163 | perimeterlength = getperimeterlength(contours) * pixel2mm;
1164 | }
1165 |
1166 | if (maxradius > 0 && lsim.rows > 1 && config->roottype == 0)
1167 | lowerrootarea = double(countNonZero(lsim.rowRange(maxradrowidx, lsim.rows)));
1168 | else
1169 | lowerrootarea = NAN;
1170 |
1171 | #ifndef _DEBUG
1172 | t1->join();
1173 |
1174 | delete t1;
1175 | #endif
1176 |
1177 | toc(vtime);
1178 | //cout << "Done. Processing time : " << vtime << " seconds." << endl;
1179 |
1180 |
1181 | // File name,Median number of roots,Maximum number of roots,Number of root tips,Total root length,
1182 | // Depth,Maximum width,Width-to-depth ratio,Network area,Convex area,Solidity,
1183 | // Lower Root Area,Average diameter,Median diameter,Maximum diameter,
1184 | // Perimeter,Volume,Surface area,
1185 | // Holes,Average Hole size,Computation,Average root orientation
1186 | // Shallow Angle Frequency,Medium Angle Frequency,Steep Angle Frequency,Shallowness Index,
1187 | // Fine Radius Frequency,Medium Radius Frequency,Coarse Radius Frequency,Fineness Index,
1188 | int featureidx = 0;
1189 | if (config->roottype == 0)
1190 | {
1191 | config->features[featureidx++] = mediannoroots;
1192 | config->features[featureidx++] = maxnoroots;
1193 | }
1194 | config->features[featureidx++] = endpts.size();
1195 | if (config->roottype != 0)
1196 | config->features[featureidx++] = branchpts.size();
1197 | config->features[featureidx++] = rootlength * pixel2mm;
1198 | if (config->roottype != 0)
1199 | config->features[featureidx++] = branchpts.size() / (rootlength * pixel2mm);
1200 | if (config->roottype == 0)
1201 | {
1202 | config->features[featureidx++] = double(rmax - rmin) * pixel2mm;
1203 | config->features[featureidx++] = double(cmax - cmin) * pixel2mm;
1204 | config->features[featureidx++] = widthtodepthratio;
1205 | }
1206 | config->features[featureidx++] = nwarea * pixel2mm * pixel2mm;
1207 | if (config->roottype == 0)
1208 | {
1209 | config->features[featureidx++] = convarea * pixel2mm * pixel2mm;
1210 | config->features[featureidx] = config->features[featureidx - 2] / config->features[featureidx - 1];
1211 | featureidx++;
1212 | config->features[featureidx++] = lowerrootarea * pixel2mm * pixel2mm;
1213 | }
1214 | config->features[featureidx++] = avgradius * pixel2mm * 2.0;
1215 | config->features[featureidx++] = medradius * pixel2mm * 2.0;
1216 | if (maxradius >= 0)
1217 | config->features[featureidx++] = maxradius * pixel2mm * 2.0;
1218 | else
1219 | config->features[featureidx++] = NAN;
1220 | config->features[featureidx++] = perimeterlength;
1221 | config->features[featureidx++] = volume * pixel2mm * pixel2mm * pixel2mm;
1222 | config->features[featureidx++] = surfacearea * pixel2mm * pixel2mm;
1223 | if (config->roottype == 0)
1224 | {
1225 | config->features[featureidx++] = nholes;
1226 | config->features[featureidx++] = avgholesize * pixel2mm * pixel2mm;
1227 | }
1228 | config->features[featureidx++] = vtime;
1229 | if (config->roottype == 0)
1230 | {
1231 | config->features[featureidx++] = avgang;
1232 | config->features[featureidx++] = shallowo;
1233 | config->features[featureidx++] = mediumo;
1234 | config->features[featureidx++] = deepo;
1235 | }
1236 |
1237 | if (!config->batchmode)
1238 | config->rootlengthhist.clear();
1239 | for (int k = 0; k <= radiusranges.size(); k++)
1240 | {
1241 | config->features[featureidx++] = rootlengthhist[k] * pixel2mm;
1242 | if (!config->batchmode)
1243 | config->rootlengthhist.push_back(rootlengthhist[k] * pixel2mm);
1244 | }
1245 | for (int k = 0; k <= radiusranges.size(); k++)
1246 | config->features[featureidx++] = projareahist[k] * pixel2mm * pixel2mm;
1247 | for (int k = 0; k <= radiusranges.size(); k++)
1248 | config->features[featureidx++] = sahist[k] * pixel2mm * pixel2mm;
1249 | for (int k = 0; k <= radiusranges.size(); k++)
1250 | config->features[featureidx++] = vhist[k] * pixel2mm * pixel2mm * pixel2mm;
1251 |
1252 | if (!config->batchmode)
1253 | config->rtdpoints *= pixel2mm;
1254 |
1255 | if ((!config->batchmode) || (config->batchmode && config->savesegmented))
1256 | {
1257 | Mat m;
1258 |
1259 | //if (config->invertimage)
1260 | //{
1261 | m = Mat::zeros(seg.size(), seg.type());
1262 | lsim.copyTo(m.rowRange(rminseg, rmaxseg).colRange(cminseg, cmaxseg));
1263 | m = (m < 128);
1264 | //}
1265 | //else
1266 | //{
1267 | /*m = Mat::zeros(seg.size(), seg.type());
1268 | lsim.copyTo(m.rowRange(rminseg, rmaxseg).colRange(cminseg, cmaxseg));
1269 | m = (m < 128);*/
1270 | //}
1271 |
1272 | //imwrite(sefilename, m);
1273 | if (config->rotation != 0)
1274 | {
1275 | rotate(m, config->seg, revflag);
1276 | }
1277 | else
1278 | {
1279 | m.copyTo(config->seg);
1280 | }
1281 | }
1282 |
1283 | if ((!config->batchmode) && checkProgress(config, "Generating output image ..."))
1284 | return;
1285 |
1286 | if (config->batchmode && !config->saveprocessed)
1287 | return;
1288 | else
1289 | {
1290 | Mat m;
1291 |
1292 | m = Mat::zeros(seg.size(), lsim.type());
1293 | lsim.copyTo(m.rowRange(rminseg, rmaxseg).colRange(cminseg, cmaxseg));
1294 | lsim = m.clone();
1295 | m = Mat::zeros(seg.size(), CV_32FC1);
1296 | dist.copyTo(m.rowRange(rminseg, rmaxseg).colRange(cminseg, cmaxseg));
1297 | dist = m.clone();
1298 | m = Mat::zeros(seg.size(), seg.type());
1299 | skel.copyTo(m.rowRange(rminseg, rmaxseg).colRange(cminseg, cmaxseg));
1300 | skel = m.clone();
1301 | }
1302 |
1303 | // Convex hull is drawn on feature images only for whole roots.
1304 | if (config->roottype == 0)
1305 | {
1306 | Mat m = Mat::zeros(seg.size(), lsim.type());
1307 |
1308 | if (config->showConvexHull)
1309 | {
1310 | hull = Mat::zeros(rmaxseg - rminseg, cmaxseg - cminseg, CV_8UC1);
1311 | drawContours(hull, hullpt, -1, Scalar(255), 2, 8, noArray(), 0, Point());
1312 | hull.copyTo(m.rowRange(rminseg, rmaxseg).colRange(cminseg, cmaxseg));
1313 | }
1314 |
1315 | hull = m.clone();
1316 |
1317 | if (config->showConvexHull)
1318 | dilate(hull, dilatedhull, getStructuringElement(MORPH_ELLIPSE, Size(3, 3)));
1319 | }
1320 |
1321 | Mat m = Mat::zeros(seg.size(), lsim.type());
1322 |
1323 | if (config->showContours)
1324 | {
1325 | perimeter = Mat::zeros(rmaxseg - rminseg, cmaxseg - cminseg, CV_8UC1);
1326 | drawContours(perimeter, contours, -1, Scalar(255), config->contourwidth, 8, hierarchy);
1327 | perimeter.copyTo(m.rowRange(rminseg, rmaxseg).colRange(cminseg, cmaxseg));
1328 | }
1329 |
1330 | perimeter = m.clone();
1331 |
1332 | // Invert the color so the background is white
1333 | lsim = (lsim < 128);
1334 |
1335 | // Convert distance transform to an image.
1336 | double minv, maxv;
1337 | dist.copyTo(m);
1338 | minMaxLoc(m, &minv, &maxv);
1339 | m = (m / maxv) * 255;
1340 | m.convertTo(m, CV_8UC1);
1341 | // To dilate skel, perimeter and convex hull.
1342 |
1343 | /*sefilename = config->savefolder + fefile.substr(0, fefile.length() - 4) + "_seg6.png";
1344 | img2 = drawtopology2(lsim, skel, branchpts, endpts, overlappts);
1345 | img2 = img2.rowRange(rmi, rma).colRange(cmi, cma).clone();
1346 | imwrite(sefilename, img2);*/
1347 | if (config->roottype == 0)
1348 | {
1349 | if (config->showMedialAxis && (!config->showMedialAxisDiameter))
1350 | {
1351 | //skel = skel + perimeter;
1352 | selement = getStructuringElement(MORPH_ELLIPSE, Size(config->medialaxiswidth, config->medialaxiswidth));
1353 | dilate(skel, dilatedskel, selement);
1354 | //dilate(hull, dilatedhull, selement);
1355 | dilatedskel = dilatedskel + perimeter;
1356 | }
1357 | else
1358 | dilatedskel = perimeter;
1359 |
1360 | Mat dskel;
1361 |
1362 | channels.push_back(lsim - dilatedskel);
1363 |
1364 | if (config->showDistMap)
1365 | channels.push_back(lsim - dilatedskel - dilatedhull + m);
1366 | else
1367 | channels.push_back(lsim - dilatedskel - dilatedhull);
1368 |
1369 | channels.push_back((lsim - dilatedhull - dilatedskel) + dilatedskel);
1370 |
1371 | if (config->showMedialAxisDiameter)
1372 | {
1373 | vector dch;
1374 | dskel = drawmedialaxis(dist, skel, radiusranges, config->medialaxiswidth);
1375 | split(dskel, dch);
1376 |
1377 | auto t = (dch[1] > 0);
1378 |
1379 | // We subtract the green channel of the medial axis
1380 | // to set the medial axis pixels to zero
1381 | for (int cidx = 0; cidx < channels.size(); cidx++)
1382 | {
1383 | channels[cidx] = channels[cidx] - t;
1384 | channels[cidx] = channels[cidx] + dch[cidx];
1385 | }
1386 | }
1387 |
1388 | merge(channels, merged);
1389 |
1390 | holes = lsim - dilatedskel;
1391 | holes = addBorder(255 - holes, 0);
1392 |
1393 | if (holepts.size() <= 1)
1394 | {
1395 | ////merged = drawtopology2(lsim, skel, branchpts, endpts, overlappts);
1396 | //imwrite(fefilename, merged);
1397 | cvtColor(merged, merged, COLOR_BGR2RGB);
1398 | if (config->rotation != 0)
1399 | {
1400 | rotate(merged, config->processed, revflag);
1401 | }
1402 | else
1403 | {
1404 | merged.copyTo(config->processed);
1405 | }
1406 |
1407 | return;
1408 | }
1409 |
1410 | if (config->showHoles)
1411 | {
1412 | holepts = getholes(holepts, Size(cmaxseg - cminseg + 2, rmaxseg - rminseg + 2));
1413 | if (holepts.size() > 5)
1414 | {
1415 | centroids = getComponentCentroid(holepts, holes.size());
1416 | pmap = pdist2(centroids, holes.size());
1417 | nearest = getnearestcomponents(pmap);
1418 | colorcodes = getcolorcodes(nearest);
1419 | }
1420 | else
1421 | {
1422 | vector colvalues = { 1,2,3,4,5 };
1423 | std::shuffle(colvalues.begin(), colvalues.end(), urng);
1424 | colorcodes.resize(holepts.size());
1425 |
1426 | for (int i = 0; i < colorcodes.size(); i++)
1427 | colorcodes[i] = colvalues[i];
1428 | }
1429 |
1430 | merged = drawtopology_wholeroot(merged, Scalar_(rmaxseg, rminseg, cmaxseg, cminseg), holepts, colorcodes, colors);
1431 | }
1432 | }
1433 | else
1434 | {
1435 | if (config->showMedialAxis)
1436 | {
1437 | selement = getStructuringElement(MORPH_ELLIPSE, Size(config->medialaxiswidth, config->medialaxiswidth));
1438 | dilate(skel, dilatedskel, selement);
1439 | }
1440 | else
1441 | {
1442 | skel = Mat::zeros(lsim.size(), CV_8UC1);
1443 | dilatedskel = Mat::zeros(lsim.size(), CV_8UC1);
1444 | branchpts.clear();
1445 | endpts.clear();
1446 | overlappts.clear();
1447 | }
1448 |
1449 | Mat dmap;
1450 | if (config->showDistMap)
1451 | dmap = m;
1452 | else
1453 | dmap = Mat::zeros(lsim.size(), CV_8UC1);
1454 |
1455 | if (config->showMedialAxis)
1456 | {
1457 | if (!config->showMedialAxisDiameter)
1458 | merged = drawtopology_disconnectedroot(lsim, dmap, Scalar_(rmaxseg, rminseg, cmaxseg, cminseg), dilatedskel, branchpts, endpts, overlappts, config->medialaxiswidth);
1459 | else
1460 | {
1461 | vector lch;
1462 | lch.push_back(lsim - dilatedskel);
1463 | lch.push_back(lsim + dmap - dilatedskel);
1464 | lch.push_back(lsim - dilatedskel);
1465 | merge(lch, merged);
1466 |
1467 | Mat dskel = drawmedialaxis(dist, skel, radiusranges, config->medialaxiswidth);
1468 | merged = merged + dskel;
1469 | //vector dch;
1470 | //split(dskel, dch);
1471 |
1472 | //auto t = (dch[0] > 0);
1473 | //
1474 |
1475 | //// We subtract the green channel of the medial axis
1476 | //// to set the medial axis pixels to zero
1477 | //for (int cidx = 0; cidx < lch.size(); cidx++)
1478 | //{
1479 | // lch[cidx] = lch[cidx] - t;
1480 | // window("adad", t);
1481 | // window("adad2", dch[cidx]);
1482 | // lch[cidx] = lch[cidx] + dch[cidx];
1483 | // window("adad3", lch[cidx]);
1484 | //}
1485 |
1486 |
1487 | //cvtColor(merged, merged, COLOR_BGR2RGB);
1488 | }
1489 | }
1490 | else
1491 | {
1492 | vector lch;
1493 | lch.push_back(lsim - dilatedskel);
1494 | lch.push_back(lsim + dmap - dilatedskel);
1495 | lch.push_back(lsim - dilatedskel);
1496 | merge(lch, merged);
1497 | }
1498 | }
1499 |
1500 | cvtColor(merged, merged, COLOR_BGR2RGB);
1501 |
1502 | if (config->rotation != 0)
1503 | {
1504 | rotate(merged, config->processed, revflag);
1505 | }
1506 | else
1507 | {
1508 | merged.copyTo(config->processed);
1509 | }
1510 |
1511 | //merged.copyTo(config->processed);
1512 | //imwrite(fefilename, merged);
1513 | }
1514 |
1515 | int main(int argc, char *argv[])
1516 | {
1517 | setUseOptimized(true);
1518 |
1519 | if (!checkHardwareSupport(CV_CPU_AVX2))
1520 | {
1521 | init(argc, argv, false);
1522 | setUseOptimized(false);
1523 | }
1524 | else
1525 | {
1526 | init(argc, argv, true);
1527 | }
1528 |
1529 | //QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
1530 |
1531 | QCoreApplication *app = QApplication::instance();
1532 | app->setApplicationName("RhizoVision Explorer");
1533 |
1534 | Ptr wnd = getImageProcessorWindow(QIcon(":/icons/RVElogoclearback.png"));
1535 | wnd->enableROI(true);
1536 | wnd->setVisibleROI(true);
1537 | wnd->enableActions(true);
1538 | wnd->setVisibleActions(true);
1539 | wnd->setInitialBanner(QPixmap(":/icons/RVElogoclearback.png").scaledToHeight(200, Qt::SmoothTransformation),
1540 | QPixmap(), //QPixmap(":/icons/noble-logo-color.png").scaledToHeight(75, Qt::SmoothTransformation),
1541 | "RhizoVision Explorer",
1542 | "Load a plant root image from File menu\n or drag and drop it here.");
1543 | MainUI *dialog = new MainUI();
1544 | dialog->setprocessfunction(feature_extractor);
1545 | dialog->setHostWindow(wnd.get());
1546 |
1547 | QObject::connect(dialog, &MainUI::updateVisualOutput, [&](Mat m) { wnd->setImage(m); });
1548 | //QObject::connect(dialog, &MainUI::updateProgress, [&](QString status) { wnd->updateProgress(status); });
1549 |
1550 | wnd->loadPlugins(dialog);
1551 | wnd->show();
1552 |
1553 | return QApplication::exec();
1554 | }
1555 |
--------------------------------------------------------------------------------
/RhizoVisionExplorer/moc_FeatureExtractorThread.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | ** Meta object code from reading C++ file 'FeatureExtractorThread.h'
3 | **
4 | ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.12.3)
5 | **
6 | ** WARNING! All changes made in this file will be lost!
7 | *****************************************************************************/
8 |
9 | #include "FeatureExtractorThread.h"
10 | #include
11 | #include
12 | #if !defined(Q_MOC_OUTPUT_REVISION)
13 | #error "The header file 'FeatureExtractorThread.h' doesn't include ."
14 | #elif Q_MOC_OUTPUT_REVISION != 67
15 | #error "This file was generated using the moc from 5.12.3. It"
16 | #error "cannot be used with the include files from this version of Qt."
17 | #error "(The moc has changed too much.)"
18 | #endif
19 |
20 | QT_BEGIN_MOC_NAMESPACE
21 | QT_WARNING_PUSH
22 | QT_WARNING_DISABLE_DEPRECATED
23 | struct qt_meta_stringdata_FeatureExtractorThread_t {
24 | QByteArrayData data[5];
25 | char stringdata0[55];
26 | };
27 | #define QT_MOC_LITERAL(idx, ofs, len) \
28 | Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
29 | qptrdiff(offsetof(qt_meta_stringdata_FeatureExtractorThread_t, stringdata0) + ofs \
30 | - idx * sizeof(QByteArrayData)) \
31 | )
32 | static const qt_meta_stringdata_FeatureExtractorThread_t qt_meta_stringdata_FeatureExtractorThread = {
33 | {
34 | QT_MOC_LITERAL(0, 0, 22), // "FeatureExtractorThread"
35 | QT_MOC_LITERAL(1, 23, 14), // "ReportProgress"
36 | QT_MOC_LITERAL(2, 38, 0), // ""
37 | QT_MOC_LITERAL(3, 39, 8), // "filename"
38 | QT_MOC_LITERAL(4, 48, 6) // "fileno"
39 |
40 | },
41 | "FeatureExtractorThread\0ReportProgress\0"
42 | "\0filename\0fileno"
43 | };
44 | #undef QT_MOC_LITERAL
45 |
46 | static const uint qt_meta_data_FeatureExtractorThread[] = {
47 |
48 | // content:
49 | 8, // revision
50 | 0, // classname
51 | 0, 0, // classinfo
52 | 1, 14, // methods
53 | 0, 0, // properties
54 | 0, 0, // enums/sets
55 | 0, 0, // constructors
56 | 0, // flags
57 | 1, // signalCount
58 |
59 | // signals: name, argc, parameters, tag, flags
60 | 1, 2, 19, 2, 0x06 /* Public */,
61 |
62 | // signals: parameters
63 | QMetaType::Void, QMetaType::QString, QMetaType::Int, 3, 4,
64 |
65 | 0 // eod
66 | };
67 |
68 | void FeatureExtractorThread::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
69 | {
70 | if (_c == QMetaObject::InvokeMetaMethod) {
71 | auto *_t = static_cast(_o);
72 | Q_UNUSED(_t)
73 | switch (_id) {
74 | case 0: _t->ReportProgress((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
75 | default: ;
76 | }
77 | } else if (_c == QMetaObject::IndexOfMethod) {
78 | int *result = reinterpret_cast(_a[0]);
79 | {
80 | using _t = void (FeatureExtractorThread::*)(QString , int );
81 | if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&FeatureExtractorThread::ReportProgress)) {
82 | *result = 0;
83 | return;
84 | }
85 | }
86 | }
87 | }
88 |
89 | QT_INIT_METAOBJECT const QMetaObject FeatureExtractorThread::staticMetaObject = { {
90 | &QThread::staticMetaObject,
91 | qt_meta_stringdata_FeatureExtractorThread.data,
92 | qt_meta_data_FeatureExtractorThread,
93 | qt_static_metacall,
94 | nullptr,
95 | nullptr
96 | } };
97 |
98 |
99 | const QMetaObject *FeatureExtractorThread::metaObject() const
100 | {
101 | return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
102 | }
103 |
104 | void *FeatureExtractorThread::qt_metacast(const char *_clname)
105 | {
106 | if (!_clname) return nullptr;
107 | if (!strcmp(_clname, qt_meta_stringdata_FeatureExtractorThread.stringdata0))
108 | return static_cast(this);
109 | return QThread::qt_metacast(_clname);
110 | }
111 |
112 | int FeatureExtractorThread::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
113 | {
114 | _id = QThread::qt_metacall(_c, _id, _a);
115 | if (_id < 0)
116 | return _id;
117 | if (_c == QMetaObject::InvokeMetaMethod) {
118 | if (_id < 1)
119 | qt_static_metacall(this, _c, _id, _a);
120 | _id -= 1;
121 | } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
122 | if (_id < 1)
123 | *reinterpret_cast(_a[0]) = -1;
124 | _id -= 1;
125 | }
126 | return _id;
127 | }
128 |
129 | // SIGNAL 0
130 | void FeatureExtractorThread::ReportProgress(QString _t1, int _t2)
131 | {
132 | void *_a[] = { nullptr, const_cast(reinterpret_cast(&_t1)), const_cast(reinterpret_cast(&_t2)) };
133 | QMetaObject::activate(this, &staticMetaObject, 0, _a);
134 | }
135 | QT_WARNING_POP
136 | QT_END_MOC_NAMESPACE
137 |
--------------------------------------------------------------------------------
/RhizoVisionExplorer/moc_MainUI.cpp:
--------------------------------------------------------------------------------
1 | /****************************************************************************
2 | ** Meta object code from reading C++ file 'MainUI.h'
3 | **
4 | ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.12.3)
5 | **
6 | ** WARNING! All changes made in this file will be lost!
7 | *****************************************************************************/
8 |
9 | #include "MainUI.h"
10 | #include
11 | #include
12 | #include
13 | #if !defined(Q_MOC_OUTPUT_REVISION)
14 | #error "The header file 'MainUI.h' doesn't include ."
15 | #elif Q_MOC_OUTPUT_REVISION != 67
16 | #error "This file was generated using the moc from 5.12.3. It"
17 | #error "cannot be used with the include files from this version of Qt."
18 | #error "(The moc has changed too much.)"
19 | #endif
20 |
21 | QT_BEGIN_MOC_NAMESPACE
22 | QT_WARNING_PUSH
23 | QT_WARNING_DISABLE_DEPRECATED
24 | struct qt_meta_stringdata_CheckEnabler_t {
25 | QByteArrayData data[4];
26 | char stringdata0[39];
27 | };
28 | #define QT_MOC_LITERAL(idx, ofs, len) \
29 | Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
30 | qptrdiff(offsetof(qt_meta_stringdata_CheckEnabler_t, stringdata0) + ofs \
31 | - idx * sizeof(QByteArrayData)) \
32 | )
33 | static const qt_meta_stringdata_CheckEnabler_t qt_meta_stringdata_CheckEnabler = {
34 | {
35 | QT_MOC_LITERAL(0, 0, 12), // "CheckEnabler"
36 | QT_MOC_LITERAL(1, 13, 12), // "stateChanged"
37 | QT_MOC_LITERAL(2, 26, 0), // ""
38 | QT_MOC_LITERAL(3, 27, 11) // "textChanged"
39 |
40 | },
41 | "CheckEnabler\0stateChanged\0\0textChanged"
42 | };
43 | #undef QT_MOC_LITERAL
44 |
45 | static const uint qt_meta_data_CheckEnabler[] = {
46 |
47 | // content:
48 | 8, // revision
49 | 0, // classname
50 | 0, 0, // classinfo
51 | 2, 14, // methods
52 | 0, 0, // properties
53 | 0, 0, // enums/sets
54 | 0, 0, // constructors
55 | 0, // flags
56 | 2, // signalCount
57 |
58 | // signals: name, argc, parameters, tag, flags
59 | 1, 0, 24, 2, 0x06 /* Public */,
60 | 3, 0, 25, 2, 0x06 /* Public */,
61 |
62 | // signals: parameters
63 | QMetaType::Void,
64 | QMetaType::Void,
65 |
66 | 0 // eod
67 | };
68 |
69 | void CheckEnabler::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
70 | {
71 | if (_c == QMetaObject::InvokeMetaMethod) {
72 | auto *_t = static_cast(_o);
73 | Q_UNUSED(_t)
74 | switch (_id) {
75 | case 0: _t->stateChanged(); break;
76 | case 1: _t->textChanged(); break;
77 | default: ;
78 | }
79 | } else if (_c == QMetaObject::IndexOfMethod) {
80 | int *result = reinterpret_cast(_a[0]);
81 | {
82 | using _t = void (CheckEnabler::*)();
83 | if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&CheckEnabler::stateChanged)) {
84 | *result = 0;
85 | return;
86 | }
87 | }
88 | {
89 | using _t = void (CheckEnabler::*)();
90 | if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&CheckEnabler::textChanged)) {
91 | *result = 1;
92 | return;
93 | }
94 | }
95 | }
96 | Q_UNUSED(_a);
97 | }
98 |
99 | QT_INIT_METAOBJECT const QMetaObject CheckEnabler::staticMetaObject = { {
100 | &QWidget::staticMetaObject,
101 | qt_meta_stringdata_CheckEnabler.data,
102 | qt_meta_data_CheckEnabler,
103 | qt_static_metacall,
104 | nullptr,
105 | nullptr
106 | } };
107 |
108 |
109 | const QMetaObject *CheckEnabler::metaObject() const
110 | {
111 | return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
112 | }
113 |
114 | void *CheckEnabler::qt_metacast(const char *_clname)
115 | {
116 | if (!_clname) return nullptr;
117 | if (!strcmp(_clname, qt_meta_stringdata_CheckEnabler.stringdata0))
118 | return static_cast(this);
119 | return QWidget::qt_metacast(_clname);
120 | }
121 |
122 | int CheckEnabler::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
123 | {
124 | _id = QWidget::qt_metacall(_c, _id, _a);
125 | if (_id < 0)
126 | return _id;
127 | if (_c == QMetaObject::InvokeMetaMethod) {
128 | if (_id < 2)
129 | qt_static_metacall(this, _c, _id, _a);
130 | _id -= 2;
131 | } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
132 | if (_id < 2)
133 | *reinterpret_cast(_a[0]) = -1;
134 | _id -= 2;
135 | }
136 | return _id;
137 | }
138 |
139 | // SIGNAL 0
140 | void CheckEnabler::stateChanged()
141 | {
142 | QMetaObject::activate(this, &staticMetaObject, 0, nullptr);
143 | }
144 |
145 | // SIGNAL 1
146 | void CheckEnabler::textChanged()
147 | {
148 | QMetaObject::activate(this, &staticMetaObject, 1, nullptr);
149 | }
150 | struct qt_meta_stringdata_StringCheckEnabler_t {
151 | QByteArrayData data[4];
152 | char stringdata0[45];
153 | };
154 | #define QT_MOC_LITERAL(idx, ofs, len) \
155 | Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
156 | qptrdiff(offsetof(qt_meta_stringdata_StringCheckEnabler_t, stringdata0) + ofs \
157 | - idx * sizeof(QByteArrayData)) \
158 | )
159 | static const qt_meta_stringdata_StringCheckEnabler_t qt_meta_stringdata_StringCheckEnabler = {
160 | {
161 | QT_MOC_LITERAL(0, 0, 18), // "StringCheckEnabler"
162 | QT_MOC_LITERAL(1, 19, 12), // "stateChanged"
163 | QT_MOC_LITERAL(2, 32, 0), // ""
164 | QT_MOC_LITERAL(3, 33, 11) // "textChanged"
165 |
166 | },
167 | "StringCheckEnabler\0stateChanged\0\0"
168 | "textChanged"
169 | };
170 | #undef QT_MOC_LITERAL
171 |
172 | static const uint qt_meta_data_StringCheckEnabler[] = {
173 |
174 | // content:
175 | 8, // revision
176 | 0, // classname
177 | 0, 0, // classinfo
178 | 2, 14, // methods
179 | 0, 0, // properties
180 | 0, 0, // enums/sets
181 | 0, 0, // constructors
182 | 0, // flags
183 | 2, // signalCount
184 |
185 | // signals: name, argc, parameters, tag, flags
186 | 1, 0, 24, 2, 0x06 /* Public */,
187 | 3, 0, 25, 2, 0x06 /* Public */,
188 |
189 | // signals: parameters
190 | QMetaType::Void,
191 | QMetaType::Void,
192 |
193 | 0 // eod
194 | };
195 |
196 | void StringCheckEnabler::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
197 | {
198 | if (_c == QMetaObject::InvokeMetaMethod) {
199 | auto *_t = static_cast(_o);
200 | Q_UNUSED(_t)
201 | switch (_id) {
202 | case 0: _t->stateChanged(); break;
203 | case 1: _t->textChanged(); break;
204 | default: ;
205 | }
206 | } else if (_c == QMetaObject::IndexOfMethod) {
207 | int *result = reinterpret_cast(_a[0]);
208 | {
209 | using _t = void (StringCheckEnabler::*)();
210 | if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&StringCheckEnabler::stateChanged)) {
211 | *result = 0;
212 | return;
213 | }
214 | }
215 | {
216 | using _t = void (StringCheckEnabler::*)();
217 | if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&StringCheckEnabler::textChanged)) {
218 | *result = 1;
219 | return;
220 | }
221 | }
222 | }
223 | Q_UNUSED(_a);
224 | }
225 |
226 | QT_INIT_METAOBJECT const QMetaObject StringCheckEnabler::staticMetaObject = { {
227 | &QWidget::staticMetaObject,
228 | qt_meta_stringdata_StringCheckEnabler.data,
229 | qt_meta_data_StringCheckEnabler,
230 | qt_static_metacall,
231 | nullptr,
232 | nullptr
233 | } };
234 |
235 |
236 | const QMetaObject *StringCheckEnabler::metaObject() const
237 | {
238 | return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
239 | }
240 |
241 | void *StringCheckEnabler::qt_metacast(const char *_clname)
242 | {
243 | if (!_clname) return nullptr;
244 | if (!strcmp(_clname, qt_meta_stringdata_StringCheckEnabler.stringdata0))
245 | return static_cast(this);
246 | return QWidget::qt_metacast(_clname);
247 | }
248 |
249 | int StringCheckEnabler::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
250 | {
251 | _id = QWidget::qt_metacall(_c, _id, _a);
252 | if (_id < 0)
253 | return _id;
254 | if (_c == QMetaObject::InvokeMetaMethod) {
255 | if (_id < 2)
256 | qt_static_metacall(this, _c, _id, _a);
257 | _id -= 2;
258 | } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
259 | if (_id < 2)
260 | *reinterpret_cast(_a[0]) = -1;
261 | _id -= 2;
262 | }
263 | return _id;
264 | }
265 |
266 | // SIGNAL 0
267 | void StringCheckEnabler::stateChanged()
268 | {
269 | QMetaObject::activate(this, &staticMetaObject, 0, nullptr);
270 | }
271 |
272 | // SIGNAL 1
273 | void StringCheckEnabler::textChanged()
274 | {
275 | QMetaObject::activate(this, &staticMetaObject, 1, nullptr);
276 | }
277 | struct qt_meta_stringdata_MainUI_t {
278 | QByteArrayData data[48];
279 | char stringdata0[569];
280 | };
281 | #define QT_MOC_LITERAL(idx, ofs, len) \
282 | Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
283 | qptrdiff(offsetof(qt_meta_stringdata_MainUI_t, stringdata0) + ofs \
284 | - idx * sizeof(QByteArrayData)) \
285 | )
286 | static const qt_meta_stringdata_MainUI_t qt_meta_stringdata_MainUI = {
287 | {
288 | QT_MOC_LITERAL(0, 0, 6), // "MainUI"
289 | QT_MOC_LITERAL(1, 7, 18), // "updateVisualOutput"
290 | QT_MOC_LITERAL(2, 26, 0), // ""
291 | QT_MOC_LITERAL(3, 27, 7), // "cv::Mat"
292 | QT_MOC_LITERAL(4, 35, 1), // "m"
293 | QT_MOC_LITERAL(5, 37, 14), // "updateProgress"
294 | QT_MOC_LITERAL(6, 52, 6), // "status"
295 | QT_MOC_LITERAL(7, 59, 7), // "getName"
296 | QT_MOC_LITERAL(8, 67, 11), // "std::string"
297 | QT_MOC_LITERAL(9, 79, 18), // "getApplicationType"
298 | QT_MOC_LITERAL(10, 98, 7), // "AppType"
299 | QT_MOC_LITERAL(11, 106, 13), // "getOutputType"
300 | QT_MOC_LITERAL(12, 120, 10), // "OutputType"
301 | QT_MOC_LITERAL(13, 131, 16), // "getAlgorithmName"
302 | QT_MOC_LITERAL(14, 148, 13), // "getParameters"
303 | QT_MOC_LITERAL(15, 162, 28), // "std::vector"
304 | QT_MOC_LITERAL(16, 191, 11), // "getPluginUI"
305 | QT_MOC_LITERAL(17, 203, 8), // "QWidget*"
306 | QT_MOC_LITERAL(18, 212, 8), // "setImage"
307 | QT_MOC_LITERAL(19, 221, 5), // "image"
308 | QT_MOC_LITERAL(20, 227, 9), // "imagename"
309 | QT_MOC_LITERAL(21, 237, 7), // "execute"
310 | QT_MOC_LITERAL(22, 245, 15), // "getOutputImages"
311 | QT_MOC_LITERAL(23, 261, 20), // "std::vector"
312 | QT_MOC_LITERAL(24, 282, 15), // "getDisplayIndex"
313 | QT_MOC_LITERAL(25, 298, 15), // "setDisplayIndex"
314 | QT_MOC_LITERAL(26, 314, 3), // "idx"
315 | QT_MOC_LITERAL(27, 318, 11), // "getFeatures"
316 | QT_MOC_LITERAL(28, 330, 19), // "std::vector"
317 | QT_MOC_LITERAL(29, 350, 6), // "roiidx"
318 | QT_MOC_LITERAL(30, 357, 12), // "setBatchMode"
319 | QT_MOC_LITERAL(31, 370, 2), // "on"
320 | QT_MOC_LITERAL(32, 373, 10), // "saveOutput"
321 | QT_MOC_LITERAL(33, 384, 6), // "savloc"
322 | QT_MOC_LITERAL(34, 391, 13), // "inputfilename"
323 | QT_MOC_LITERAL(35, 405, 12), // "saveMetadata"
324 | QT_MOC_LITERAL(36, 418, 6), // "imgloc"
325 | QT_MOC_LITERAL(37, 425, 8), // "filepath"
326 | QT_MOC_LITERAL(38, 434, 12), // "loadMetadata"
327 | QT_MOC_LITERAL(39, 447, 11), // "writeHeader"
328 | QT_MOC_LITERAL(40, 459, 8), // "filename"
329 | QT_MOC_LITERAL(41, 468, 17), // "getCSVColumnNames"
330 | QT_MOC_LITERAL(42, 486, 20), // "std::vector"
331 | QT_MOC_LITERAL(43, 507, 16), // "getProgressSteps"
332 | QT_MOC_LITERAL(44, 524, 5), // "abort"
333 | QT_MOC_LITERAL(45, 530, 8), // "getChart"
334 | QT_MOC_LITERAL(46, 539, 7), // "QChart*"
335 | QT_MOC_LITERAL(47, 547, 21) // "updatesegmentedoutput"
336 |
337 | },
338 | "MainUI\0updateVisualOutput\0\0cv::Mat\0m\0"
339 | "updateProgress\0status\0getName\0std::string\0"
340 | "getApplicationType\0AppType\0getOutputType\0"
341 | "OutputType\0getAlgorithmName\0getParameters\0"
342 | "std::vector\0getPluginUI\0"
343 | "QWidget*\0setImage\0image\0imagename\0"
344 | "execute\0getOutputImages\0std::vector\0"
345 | "getDisplayIndex\0setDisplayIndex\0idx\0"
346 | "getFeatures\0std::vector\0roiidx\0"
347 | "setBatchMode\0on\0saveOutput\0savloc\0"
348 | "inputfilename\0saveMetadata\0imgloc\0"
349 | "filepath\0loadMetadata\0writeHeader\0"
350 | "filename\0getCSVColumnNames\0"
351 | "std::vector\0getProgressSteps\0"
352 | "abort\0getChart\0QChart*\0updatesegmentedoutput"
353 | };
354 | #undef QT_MOC_LITERAL
355 |
356 | static const uint qt_meta_data_MainUI[] = {
357 |
358 | // content:
359 | 8, // revision
360 | 0, // classname
361 | 0, 0, // classinfo
362 | 28, 14, // methods
363 | 0, 0, // properties
364 | 0, 0, // enums/sets
365 | 0, 0, // constructors
366 | 0, // flags
367 | 2, // signalCount
368 |
369 | // signals: name, argc, parameters, tag, flags
370 | 1, 1, 154, 2, 0x06 /* Public */,
371 | 5, 1, 157, 2, 0x06 /* Public */,
372 |
373 | // slots: name, argc, parameters, tag, flags
374 | 7, 0, 160, 2, 0x0a /* Public */,
375 | 9, 0, 161, 2, 0x0a /* Public */,
376 | 11, 0, 162, 2, 0x0a /* Public */,
377 | 13, 0, 163, 2, 0x0a /* Public */,
378 | 14, 0, 164, 2, 0x0a /* Public */,
379 | 16, 0, 165, 2, 0x0a /* Public */,
380 | 18, 2, 166, 2, 0x0a /* Public */,
381 | 18, 1, 171, 2, 0x2a /* Public | MethodCloned */,
382 | 21, 0, 174, 2, 0x0a /* Public */,
383 | 22, 0, 175, 2, 0x0a /* Public */,
384 | 24, 0, 176, 2, 0x0a /* Public */,
385 | 25, 1, 177, 2, 0x0a /* Public */,
386 | 27, 0, 180, 2, 0x0a /* Public */,
387 | 27, 1, 181, 2, 0x0a /* Public */,
388 | 30, 1, 184, 2, 0x0a /* Public */,
389 | 32, 2, 187, 2, 0x0a /* Public */,
390 | 35, 3, 192, 2, 0x0a /* Public */,
391 | 35, 2, 199, 2, 0x2a /* Public | MethodCloned */,
392 | 38, 1, 204, 2, 0x0a /* Public */,
393 | 39, 2, 207, 2, 0x0a /* Public */,
394 | 39, 1, 212, 2, 0x2a /* Public | MethodCloned */,
395 | 41, 0, 215, 2, 0x0a /* Public */,
396 | 43, 0, 216, 2, 0x0a /* Public */,
397 | 44, 0, 217, 2, 0x0a /* Public */,
398 | 45, 0, 218, 2, 0x0a /* Public */,
399 | 47, 0, 219, 2, 0x08 /* Private */,
400 |
401 | // signals: parameters
402 | QMetaType::Void, 0x80000000 | 3, 4,
403 | QMetaType::Void, QMetaType::QString, 6,
404 |
405 | // slots: parameters
406 | 0x80000000 | 8,
407 | 0x80000000 | 10,
408 | 0x80000000 | 12,
409 | 0x80000000 | 8,
410 | 0x80000000 | 15,
411 | 0x80000000 | 17,
412 | QMetaType::Void, 0x80000000 | 3, QMetaType::QString, 19, 20,
413 | QMetaType::Void, 0x80000000 | 3, 19,
414 | QMetaType::Void,
415 | 0x80000000 | 23,
416 | QMetaType::Int,
417 | QMetaType::Void, QMetaType::Int, 26,
418 | 0x80000000 | 28,
419 | 0x80000000 | 28, QMetaType::Int, 29,
420 | QMetaType::Void, QMetaType::Bool, 31,
421 | QMetaType::Int, QMetaType::QString, QMetaType::QString, 33, 34,
422 | QMetaType::Void, QMetaType::QString, QMetaType::QString, QMetaType::QString, 36, 33, 37,
423 | QMetaType::Void, QMetaType::QString, QMetaType::QString, 36, 33,
424 | QMetaType::Void, QMetaType::QString, 37,
425 | QMetaType::Int, QMetaType::QString, QMetaType::QString, 33, 40,
426 | QMetaType::Int, QMetaType::QString, 33,
427 | 0x80000000 | 42,
428 | QMetaType::Int,
429 | QMetaType::Void,
430 | 0x80000000 | 46,
431 | QMetaType::Void,
432 |
433 | 0 // eod
434 | };
435 |
436 | void MainUI::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
437 | {
438 | if (_c == QMetaObject::InvokeMetaMethod) {
439 | auto *_t = static_cast(_o);
440 | Q_UNUSED(_t)
441 | switch (_id) {
442 | case 0: _t->updateVisualOutput((*reinterpret_cast< cv::Mat(*)>(_a[1]))); break;
443 | case 1: _t->updateProgress((*reinterpret_cast< QString(*)>(_a[1]))); break;
444 | case 2: { std::string _r = _t->getName();
445 | if (_a[0]) *reinterpret_cast< std::string*>(_a[0]) = std::move(_r); } break;
446 | case 3: { AppType _r = _t->getApplicationType();
447 | if (_a[0]) *reinterpret_cast< AppType*>(_a[0]) = std::move(_r); } break;
448 | case 4: { OutputType _r = _t->getOutputType();
449 | if (_a[0]) *reinterpret_cast< OutputType*>(_a[0]) = std::move(_r); } break;
450 | case 5: { std::string _r = _t->getAlgorithmName();
451 | if (_a[0]) *reinterpret_cast< std::string*>(_a[0]) = std::move(_r); } break;
452 | case 6: { std::vector _r = _t->getParameters();
453 | if (_a[0]) *reinterpret_cast< std::vector*>(_a[0]) = std::move(_r); } break;
454 | case 7: { QWidget* _r = _t->getPluginUI();
455 | if (_a[0]) *reinterpret_cast< QWidget**>(_a[0]) = std::move(_r); } break;
456 | case 8: _t->setImage((*reinterpret_cast< cv::Mat(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
457 | case 9: _t->setImage((*reinterpret_cast< cv::Mat(*)>(_a[1]))); break;
458 | case 10: _t->execute(); break;
459 | case 11: { std::vector _r = _t->getOutputImages();
460 | if (_a[0]) *reinterpret_cast< std::vector*>(_a[0]) = std::move(_r); } break;
461 | case 12: { int _r = _t->getDisplayIndex();
462 | if (_a[0]) *reinterpret_cast< int*>(_a[0]) = std::move(_r); } break;
463 | case 13: _t->setDisplayIndex((*reinterpret_cast< int(*)>(_a[1]))); break;
464 | case 14: { std::vector _r = _t->getFeatures();
465 | if (_a[0]) *reinterpret_cast< std::vector*>(_a[0]) = std::move(_r); } break;
466 | case 15: { std::vector _r = _t->getFeatures((*reinterpret_cast< int(*)>(_a[1])));
467 | if (_a[0]) *reinterpret_cast< std::vector*>(_a[0]) = std::move(_r); } break;
468 | case 16: _t->setBatchMode((*reinterpret_cast< bool(*)>(_a[1]))); break;
469 | case 17: { int _r = _t->saveOutput((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])));
470 | if (_a[0]) *reinterpret_cast< int*>(_a[0]) = std::move(_r); } break;
471 | case 18: _t->saveMetadata((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3]))); break;
472 | case 19: _t->saveMetadata((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
473 | case 20: _t->loadMetadata((*reinterpret_cast< QString(*)>(_a[1]))); break;
474 | case 21: { int _r = _t->writeHeader((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])));
475 | if (_a[0]) *reinterpret_cast< int*>(_a[0]) = std::move(_r); } break;
476 | case 22: { int _r = _t->writeHeader((*reinterpret_cast< QString(*)>(_a[1])));
477 | if (_a[0]) *reinterpret_cast< int*>(_a[0]) = std::move(_r); } break;
478 | case 23: { std::vector _r = _t->getCSVColumnNames();
479 | if (_a[0]) *reinterpret_cast< std::vector*>(_a[0]) = std::move(_r); } break;
480 | case 24: { int _r = _t->getProgressSteps();
481 | if (_a[0]) *reinterpret_cast< int*>(_a[0]) = std::move(_r); } break;
482 | case 25: _t->abort(); break;
483 | case 26: { QChart* _r = _t->getChart();
484 | if (_a[0]) *reinterpret_cast< QChart**>(_a[0]) = std::move(_r); } break;
485 | case 27: _t->updatesegmentedoutput(); break;
486 | default: ;
487 | }
488 | } else if (_c == QMetaObject::IndexOfMethod) {
489 | int *result = reinterpret_cast(_a[0]);
490 | {
491 | using _t = void (MainUI::*)(cv::Mat );
492 | if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&MainUI::updateVisualOutput)) {
493 | *result = 0;
494 | return;
495 | }
496 | }
497 | {
498 | using _t = void (MainUI::*)(QString );
499 | if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&MainUI::updateProgress)) {
500 | *result = 1;
501 | return;
502 | }
503 | }
504 | }
505 | }
506 |
507 | QT_INIT_METAOBJECT const QMetaObject MainUI::staticMetaObject = { {
508 | &QObject::staticMetaObject,
509 | qt_meta_stringdata_MainUI.data,
510 | qt_meta_data_MainUI,
511 | qt_static_metacall,
512 | nullptr,
513 | nullptr
514 | } };
515 |
516 |
517 | const QMetaObject *MainUI::metaObject() const
518 | {
519 | return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
520 | }
521 |
522 | void *MainUI::qt_metacast(const char *_clname)
523 | {
524 | if (!_clname) return nullptr;
525 | if (!strcmp(_clname, qt_meta_stringdata_MainUI.stringdata0))
526 | return static_cast(this);
527 | if (!strcmp(_clname, "IPlugin"))
528 | return static_cast< IPlugin*>(this);
529 | if (!strcmp(_clname, "org.plugin.ImageProcessing.Segmentation.IPlugin"))
530 | return static_cast< IPlugin*>(this);
531 | return QObject::qt_metacast(_clname);
532 | }
533 |
534 | int MainUI::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
535 | {
536 | _id = QObject::qt_metacall(_c, _id, _a);
537 | if (_id < 0)
538 | return _id;
539 | if (_c == QMetaObject::InvokeMetaMethod) {
540 | if (_id < 28)
541 | qt_static_metacall(this, _c, _id, _a);
542 | _id -= 28;
543 | } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
544 | if (_id < 28)
545 | *reinterpret_cast(_a[0]) = -1;
546 | _id -= 28;
547 | }
548 | return _id;
549 | }
550 |
551 | // SIGNAL 0
552 | void MainUI::updateVisualOutput(cv::Mat _t1)
553 | {
554 | void *_a[] = { nullptr, const_cast(reinterpret_cast(&_t1)) };
555 | QMetaObject::activate(this, &staticMetaObject, 0, _a);
556 | }
557 |
558 | // SIGNAL 1
559 | void MainUI::updateProgress(QString _t1)
560 | {
561 | void *_a[] = { nullptr, const_cast(reinterpret_cast(&_t1)) };
562 | QMetaObject::activate(this, &staticMetaObject, 1, _a);
563 | }
564 |
565 | QT_PLUGIN_METADATA_SECTION
566 | static constexpr unsigned char qt_pluginMetaData[] = {
567 | 'Q', 'T', 'M', 'E', 'T', 'A', 'D', 'A', 'T', 'A', ' ', '!',
568 | // metadata version, Qt version, architectural requirements
569 | 0, QT_VERSION_MAJOR, QT_VERSION_MINOR, qPluginArchRequirements(),
570 | 0xbf,
571 | // "IID"
572 | 0x02, 0x78, 0x2f, 'o', 'r', 'g', '.', 'p',
573 | 'l', 'u', 'g', 'i', 'n', '.', 'I', 'm',
574 | 'a', 'g', 'e', 'P', 'r', 'o', 'c', 'e',
575 | 's', 's', 'i', 'n', 'g', '.', 'S', 'e',
576 | 'g', 'm', 'e', 'n', 't', 'a', 't', 'i',
577 | 'o', 'n', '.', 'I', 'P', 'l', 'u', 'g',
578 | 'i', 'n',
579 | // "className"
580 | 0x03, 0x66, 'M', 'a', 'i', 'n', 'U', 'I',
581 | 0xff,
582 | };
583 | QT_MOC_EXPORT_PLUGIN(MainUI, MainUI)
584 |
585 | QT_WARNING_POP
586 | QT_END_MOC_NAMESPACE
587 |
--------------------------------------------------------------------------------
/RhizoVisionExplorer/resource.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/predictivephenomics/RhizoVisionExplorer/42750c9d238153dd2d707267c70dcbe66e302083/RhizoVisionExplorer/resource.h
--------------------------------------------------------------------------------
/RhizoVisionExplorer/resources.qrc:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 | icons/rveicon.ico
11 | icons/RVElogoclearback-150.png
12 | icons/RVElogoclearback.png
13 |
14 |
--------------------------------------------------------------------------------
/RhizoVisionExplorer/rootsegmentprop.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2021, Anand Seethepalli and Larry York
3 | Copyright (C) 2020, Courtesy of Noble Research Institute, LLC
4 |
5 | File: rootsegmentprop.cpp
6 |
7 | Authors:
8 | Anand Seethepalli (anand.seethepalli@yahoo.co.in)
9 | Larry York (larry.york@gmail.com)
10 |
11 | This file is part of RhizoVision Explorer.
12 |
13 | RhizoVision Explorer is free software: you can redistribute
14 | it and/or modify it under the terms of the GNU General Public
15 | License as published by the Free Software Foundation, either
16 | version 3 of the License, or (at your option) any later version.
17 |
18 | RhizoVision Explorer is distributed in the hope that it will
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
21 | PURPOSE. See the GNU General Public License for more details.
22 |
23 | You should have received a copy of the GNU General Public
24 | License along with RhizoVision Explorer; see the file COPYING.
25 | If not, see .
26 | */
27 |
28 | // This file contains implementations of functions that extract
29 | // phenotypic traits from root segments such as total root length
30 | // as well as topological information such as first order and
31 | // second order roots, identification of main root, branching
32 | // frequency and average length before next branch.
33 |
34 | #include "roottopology.h"
35 | #include "rootsegmentprop.h"
36 |
37 | using namespace std;
38 | using namespace cv;
39 |
40 | void getrootlength(Mat skeleton, ListofListsRef segments, PointList overlap, double &rootlen)
41 | {
42 | rootlen = 0.0;
43 | Point diff;
44 | uchar *skel = skeleton.ptr();
45 | double a = 0, b = 0;
46 |
47 | // Compute the sum of distances of root segments using
48 | // euclidean distance metric.
49 | for (int i = 0; i < segments.size(); i++)
50 | {
51 | for (int j = 0; j < segments[i].size() - 1; j++)
52 | {
53 | diff = segments[i][j] - segments[i][j + 1];
54 | a = fabs(double(diff.x));
55 | b = fabs(double(diff.y));
56 |
57 | if (a == b)
58 | rootlen += a * CVUTIL_SQRT2;
59 | else if (a > b)
60 | rootlen += a;
61 | else
62 | rootlen += b;
63 | //rootlen += sqrt(diff.ddot(diff));
64 | }
65 | }
66 |
67 | for (auto &overlappt : overlap)
68 | {
69 | // To check if the overlappt is a diagonal or orthogonal
70 | if (skel[overlappt.y * skeleton.cols + overlappt.x + 1] > 0)
71 | {
72 | // Orthogonal
73 | rootlen++;
74 | }
75 | else
76 | {
77 | // Diagonal
78 | rootlen += CVUTIL_SQRT2;
79 | //rootlen += sqrt(2);
80 | }
81 | }
82 | }
83 |
84 | //double getrootlength(Mat skeleton)
85 | //{
86 | // double sum = 0.0;
87 | // Mat branchpt, endpt;
88 | // Points branchpts, endpts, overlap;
89 | // ListofLists segments;
90 | //
91 | // // Identify branch points and end points in the skeleton image.
92 | // getroottopology(skeleton, branchpts, endpts, overlap, segments);
93 | //
94 | // // Compute the sum of distances of root segments using
95 | // // euclidean distance metric.
96 | // getrootlength(skeleton, segments, overlap, sum);
97 | //
98 | // for (int i = 0; i < segments.size(); i++)
99 | // segments[i].resize(0);
100 | //
101 | // segments.resize(0);
102 | // overlap.resize(0);
103 | // endpts.resize(0);
104 | // branchpts.resize(0);
105 | //
106 | // return sum;
107 | //}
108 |
109 | void getrootradii(Mat skeleton, Mat segment, Mat dist, ListofListsRef segments, ListofListsRef radii, double& maxradius, int& maxradrowidx)
110 | {
111 | int i, j, x, y, xinc, yinc, currx, curry, nextx, nexty, nnextpt, ptcount;
112 | size_t cisz;
113 |
114 | Mat dskeleton;
115 | skeleton.convertTo(dskeleton, CV_64FC1);
116 | dskeleton = dskeleton / 255.0;
117 |
118 | Mat dt;
119 | dist.convertTo(dt, CV_64FC1);
120 | dt = dt.mul(dskeleton);
121 | double *dtptr = dt.ptr();
122 |
123 | maxradius = -1.0;
124 | maxradrowidx = INT_MAX;
125 |
126 | // We now get the root radii at every skeletal pixel and for each segment.
127 | // Since, each segment contains points that describe the shape of the segment
128 | // in the simplest way possible, some pixels on the root segment may not be
129 | // present in the root segment. Hence, we traverse pixel-by-pixel in each
130 | // root segment and get list of radii for all the pixels for that root
131 | // segment. This lists of radii can further be used to perform statistics,
132 | // identify main root or even cluster the roots based on root radii.
133 |
134 | // First, to allocate sufficient memory.
135 | radii.resize(segments.size());
136 | for (i = 0; i < segments.size(); i++)
137 | {
138 | cisz = segments[i].size() - 1;
139 |
140 | for (j = 0, ptcount = 0; j < cisz; j++)
141 | {
142 | nnextpt = j + 1;
143 |
144 | currx = segments[i][j].x;
145 | curry = segments[i][j].y;
146 | nextx = segments[i][nnextpt].x;
147 | nexty = segments[i][nnextpt].y;
148 |
149 | ptcount += max(abs(curry - nexty), abs(currx - nextx));
150 | }
151 |
152 | radii[i].resize(ptcount + 1);
153 | }
154 |
155 | // Each root segment may start from a branch or an end point and
156 | // end at a branch or an end point. In case of an end point, the
157 | // radius is considered only once. But in case of branch point,
158 | // since it is connected to two other root segments, the radius
159 | // at the branch point is considered thrice in total. Hence,
160 | // when calculating average root radius across plant root, we need
161 | // to subtract twice the root radius at every branch point, to get
162 | // a better estimate. But, this function just makes list of root
163 | // radii of all the pixels that are present in each segment.
164 | for (i = 0; i < segments.size(); i++)
165 | {
166 | cisz = segments[i].size() - 1;
167 | ptcount = 0;
168 |
169 | for (j = 0; j < cisz; j++)
170 | {
171 | nnextpt = j + 1;
172 |
173 | currx = segments[i][j].x;
174 | curry = segments[i][j].y;
175 | nextx = segments[i][nnextpt].x;
176 | nexty = segments[i][nnextpt].y;
177 |
178 | if (nextx != currx)
179 | xinc = abs(currx - nextx) / (nextx - currx);
180 | else
181 | xinc = 0;
182 |
183 | if (nexty != curry)
184 | yinc = abs(curry - nexty) / (nexty - curry);
185 | else
186 | yinc = 0;
187 |
188 | for (x = currx, y = curry; !(x == nextx && y == nexty); x += xinc, y += yinc)
189 | {
190 | radii[i][ptcount++] = dtptr[y * dt.cols + x];
191 | if (maxradius < dtptr[y * dt.cols + x])
192 | {
193 | maxradius = dtptr[y * dt.cols + x];
194 | maxradrowidx = y;
195 | }
196 | else if (maxradius == dtptr[y * dt.cols + x] && maxradrowidx > y)
197 | {
198 | maxradrowidx = y;
199 | }
200 | }
201 | }
202 |
203 | radii[i][ptcount] = dtptr[segments[i][j].y * dt.cols + segments[i][j].x];
204 |
205 | if (maxradius < dtptr[segments[i][j].y * dt.cols + segments[i][j].x])
206 | {
207 | maxradius = dtptr[segments[i][j].y * dt.cols + segments[i][j].x];
208 | if (maxradrowidx > segments[i][j].y)
209 | maxradrowidx = segments[i][j].y;
210 | }
211 | }
212 | }
213 |
214 | void getrootradiiforsegments(ListofListsRef radii, ValueList avgradii)
215 | {
216 | double sum = 0.0;
217 |
218 | avgradii.resize(radii.size());
219 |
220 | for (int i = 0; i < radii.size(); i++)
221 | {
222 | sum = 0.0;
223 |
224 | for (int j = 0; j < radii[i].size(); j++)
225 | sum += radii[i][j];
226 |
227 | avgradii[i] = sum / radii[i].size();
228 | }
229 | }
230 |
231 | void gethistogramofrootradii(Mat skeleton, Mat segment, ValueList x, IndexList y)
232 | {
233 | Mat dskeleton;
234 | int sum;
235 |
236 | skeleton.convertTo(dskeleton, CV_64FC1);
237 | dskeleton = dskeleton / 255.0;
238 |
239 | Mat dt = bwdist(segment);
240 | dt.convertTo(dt, CV_64FC1);
241 | dt = dt.mul(dskeleton);
242 |
243 | pair nonzeros = find(dt, FindType::IndicesAndValues);
244 | double *nzptr = nonzeros.second.ptr();
245 |
246 | x = unique(nonzeros.second);
247 | int xsz = static_cast(x.size());
248 | y.resize(xsz);
249 |
250 | for (int i = 0; i < xsz; i++)
251 | {
252 | sum = 0;
253 | for (int j = 0; j < nonzeros.second.rows; j++)
254 | if (x[i] == nzptr[j])
255 | sum++;
256 |
257 | y[i] = sum;
258 | }
259 | }
260 |
261 | /// validatesegments () - Checks root segments for errors
262 | /// Validation rules:
263 | /// ----------------
264 | /// 1. The internal points of root segments should not be shared with
265 | /// other root segments.
266 | ///
267 | /// 2. All the branch points should be used 3 times either as start points
268 | /// or end points by the root segments.
269 | ///
270 | /// 3. If a branch point is an overlapped point, it should be used 4
271 | /// times. All overlapped points must be used 4 times.
272 | ///
273 | /// 4. All end points must be used only once.
274 | ///
275 | /// 5. If an image is reconstructed with the root segments, it must
276 | /// form the complete skeleton.
277 | bool validatesegments(Mat skeleton, PointList branch, PointList end, PointList overlap, ListofListsRef rootsegments)
278 | {
279 | // The internal points of root segments should not be shared with
280 | // other root segments.
281 | size_t nsize = rootsegments.size();
282 |
283 | vector sizesdata;
284 | sizesdata.resize(nsize);
285 | size_t *sizes = sizesdata.data();
286 |
287 | for (size_t i = 0; i < rootsegments.size(); i++)
288 | sizes[i] = rootsegments[i].size();
289 |
290 | for (int i = 0; i < nsize; i++)
291 | {
292 | //cout << "i = " << i << endl;
293 |
294 | for (int j = 1; j < (sizes[i] - 1); j++)
295 | {
296 | for (int k = i + 1; k < nsize; k++)
297 | {
298 | if (k == i)
299 | continue;
300 |
301 | for (int l = 1; l < (sizes[k] - 1); l++)
302 | {
303 | if (rootsegments[i][j].x == rootsegments[k][l].x &&
304 | rootsegments[i][j].y == rootsegments[k][l].y)
305 | {
306 | #ifdef DEBUG_MESSAGES
307 | cout << "[" << __LINE__ << "]: x = " << rootsegments[i][j].x << " - y = " << rootsegments[i][j].y << endl;
308 | #endif
309 | return false;
310 | }
311 | }
312 | }
313 | }
314 | }
315 |
316 | /* All the branch points should be used 3 times either as start points
317 | or end points by the root segments.
318 |
319 | If a branch point is an overlapped point, it should be used 4
320 | times. All overlapped points must be used 4 times.
321 |
322 | All end points must be used only once. */
323 | Dictionary bids, eids, oids;
324 | Point pt;
325 | bids.reserve(branch.size());
326 | eids.reserve(end.size());
327 | oids.reserve(overlap.size());
328 |
329 | for (Point &p : branch)
330 | bids[p.x * 10000 + p.y] = -1;
331 | for (Point &p : end)
332 | eids[p.x * 10000 + p.y] = -1;
333 | for (Point &p : overlap)
334 | oids[p.x * 10000 + p.y] = -1;
335 |
336 | for (int i = 0; i < rootsegments.size(); i++)
337 | {
338 | pt = rootsegments[i][0];
339 |
340 | if (bids[pt.x * 10000 + pt.y] != 0)
341 | {
342 | if (bids[pt.x * 10000 + pt.y] < 0)
343 | bids[pt.x * 10000 + pt.y] = 1;
344 | else
345 | bids[pt.x * 10000 + pt.y]++;
346 | }
347 |
348 | if (eids[pt.x * 10000 + pt.y] != 0)
349 | {
350 | if (eids[pt.x * 10000 + pt.y] < 0)
351 | eids[pt.x * 10000 + pt.y] = 1;
352 | else
353 | eids[pt.x * 10000 + pt.y]++;
354 | }
355 |
356 | if (oids[pt.x * 10000 + pt.y] != 0)
357 | {
358 | if (oids[pt.x * 10000 + pt.y] < 0)
359 | oids[pt.x * 10000 + pt.y] = 1;
360 | else
361 | oids[pt.x * 10000 + pt.y]++;
362 | }
363 |
364 | pt = rootsegments[i][rootsegments[i].size() - 1];
365 |
366 | if (bids[pt.x * 10000 + pt.y] != 0)
367 | {
368 | if (bids[pt.x * 10000 + pt.y] < 0)
369 | bids[pt.x * 10000 + pt.y] = 1;
370 | else
371 | bids[pt.x * 10000 + pt.y]++;
372 | }
373 |
374 | if (eids[pt.x * 10000 + pt.y] != 0)
375 | {
376 | if (eids[pt.x * 10000 + pt.y] < 0)
377 | eids[pt.x * 10000 + pt.y] = 1;
378 | else
379 | eids[pt.x * 10000 + pt.y]++;
380 | }
381 |
382 | if (oids[pt.x * 10000 + pt.y] != 0)
383 | {
384 | if (oids[pt.x * 10000 + pt.y] < 0)
385 | oids[pt.x * 10000 + pt.y] = 1;
386 | else
387 | oids[pt.x * 10000 + pt.y]++;
388 | }
389 | }
390 |
391 | for (Point &p : branch)
392 | {
393 | if (bids[p.x * 10000 + p.y] != 3)
394 | {
395 | if (bids[p.x * 10000 + p.y] != 4 && bids[p.x * 10000 + p.y] != oids[p.x * 10000 + p.y])
396 | {
397 | #ifdef DEBUG_MESSAGES
398 | cout << "[" << __LINE__ << "]: x = " << p.x << " - y = " << p.y << " bids = " << bids[p.x * 10000 + p.y] << " oids = " << oids[p.x * 10000 + p.y] << endl;
399 | //window("b1", skeleton.rowRange(p.y - 3, p.y + 4).colRange(p.x - 3, p.x + 4));
400 | //window("b2", skeleton.rowRange(p.y - 103, p.y + 104).colRange(p.x - 103, p.x + 104));
401 | #endif
402 | return false;
403 | }
404 | }
405 | }
406 | for (Point &p : end)
407 | {
408 | if (eids[p.x * 10000 + p.y] != 1)
409 | {
410 | #ifdef DEBUG_MESSAGES
411 | cout << "[" << __LINE__ << "]: x = " << p.x << " - y = " << p.y << endl;
412 | #endif
413 | return false;
414 | }
415 | }
416 | for (Point &p : overlap)
417 | {
418 | if (oids[p.x * 10000 + p.y] != 4)
419 | {
420 | #ifdef DEBUG_MESSAGES
421 | cout << "[" << __LINE__ << "]: x = " << p.x << " - y = " << p.y << endl;
422 | #endif
423 | return false;
424 | }
425 | }
426 |
427 | // If an image is reconstructed with the root segments, it must
428 | // form the complete skeleton.
429 | Mat rec = Mat::zeros(skeleton.size(), CV_8UC1);
430 | unsigned char *recptr = rec.ptr();
431 | int currx, curry, nextx, nexty, xinc, yinc, x, y;
432 | const unsigned char white = static_cast(255);
433 |
434 | for (int i = 0; i < rootsegments.size(); i++)
435 | {
436 | for (int j = 0; j < rootsegments[i].size() - 1; j++)
437 | {
438 | currx = rootsegments[i][j].x - 1;
439 | curry = rootsegments[i][j].y - 1;
440 | nextx = rootsegments[i][j + 1].x - 1;
441 | nexty = rootsegments[i][j + 1].y - 1;
442 |
443 | if (!((currx == nextx) && (curry == nexty)))
444 | {
445 | if (currx == nextx)
446 | {
447 | yinc = abs(curry - nexty) / (nexty - curry);
448 |
449 | for (y = curry; y != nexty; y += yinc)
450 | recptr[y * rec.cols + currx] = white;
451 | }
452 | else if (curry == nexty)
453 | {
454 | xinc = abs(currx - nextx) / (nextx - currx);
455 |
456 | for (x = currx; x != nextx; x += xinc)
457 | recptr[curry * rec.cols + x] = white;
458 | }
459 | else
460 | {
461 | xinc = abs(currx - nextx) / (nextx - currx);
462 | yinc = abs(curry - nexty) / (nexty - curry);
463 |
464 | for (x = currx, y = curry; x != nextx; x += xinc, y += yinc)
465 | recptr[y * rec.cols + x] = white;
466 | }
467 | }
468 |
469 | recptr[nexty * rec.cols + nextx] = white;
470 | }
471 | }
472 |
473 | Mat diff = skeleton - rec;
474 |
475 | if (countNonZero(diff) > 0)
476 | {
477 | /*Mat mm;
478 | vector ch;
479 |
480 | ch.push_back(Mat::zeros(rec.size(), CV_8UC1));
481 | ch.push_back(rec);
482 | ch.push_back(skeleton);
483 |
484 | merge(ch, mm);
485 | imwrite("C:\\Users\\aseethepalli\\Documents\\projects\\AltRhizo Lite\\working2\\bb.png", mm);
486 | window("b", mm.rowRange(5001 - 10, 5001 + 11).colRange(5250 - 10, 5250 + 11));*/
487 | return false;
488 | }
489 |
490 | // We return true if all the conditions mentioned above are true.
491 | return true;
492 | }
493 |
--------------------------------------------------------------------------------
/RhizoVisionExplorer/rootsegmentprop.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2021, Anand Seethepalli and Larry York
3 | Copyright (C) 2020, Courtesy of Noble Research Institute, LLC
4 |
5 | File: rootsegmentprop.h
6 |
7 | Authors:
8 | Anand Seethepalli (anand.seethepalli@yahoo.co.in)
9 | Larry York (larry.york@gmail.com)
10 |
11 | This file is part of RhizoVision Explorer.
12 |
13 | RhizoVision Explorer is free software: you can redistribute
14 | it and/or modify it under the terms of the GNU General Public
15 | License as published by the Free Software Foundation, either
16 | version 3 of the License, or (at your option) any later version.
17 |
18 | RhizoVision Explorer is distributed in the hope that it will
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
21 | PURPOSE. See the GNU General Public License for more details.
22 |
23 | You should have received a copy of the GNU General Public
24 | License along with RhizoVision Explorer; see the file COPYING.
25 | If not, see .
26 | */
27 |
28 | #pragma once
29 |
30 | #ifndef ROOTSEGMENTPROP_H
31 | #define ROOTSEGMENTPROP_H
32 |
33 | #include "common_types.h"
34 |
35 | void getrootlength(cv::Mat skeleton, ListofListsRef segments, PointList overlap, double &rootlen);
36 | //double getrootlength(cv::Mat skeleton);
37 |
38 | void getrootradii(cv::Mat skeleton, cv::Mat segment, cv::Mat dist, ListofListsRef segments, ListofListsRef radii, double& maxradius, int& maxradrowidx);
39 | void getrootradiiforsegments(ListofListsRef radii, ValueList avgradii);
40 |
41 | void gethistogramofrootradii(cv::Mat skeleton, cv::Mat segment, ValueList x, IndexList y);
42 |
43 | bool validatesegments(cv::Mat skeleton, PointList branch, PointList end, PointList overlap, ListofListsRef rootsegments);
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/RhizoVisionExplorer/roottopology.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2021, Anand Seethepalli and Larry York
3 | Copyright (C) 2020, Courtesy of Noble Research Institute, LLC
4 |
5 | File: roottopology.h
6 |
7 | Authors:
8 | Anand Seethepalli (anand.seethepalli@yahoo.co.in)
9 | Larry York (larry.york@gmail.com)
10 |
11 | This file is part of RhizoVision Explorer.
12 |
13 | RhizoVision Explorer is free software: you can redistribute
14 | it and/or modify it under the terms of the GNU General Public
15 | License as published by the Free Software Foundation, either
16 | version 3 of the License, or (at your option) any later version.
17 |
18 | RhizoVision Explorer is distributed in the hope that it will
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
21 | PURPOSE. See the GNU General Public License for more details.
22 |
23 | You should have received a copy of the GNU General Public
24 | License along with RhizoVision Explorer; see the file COPYING.
25 | If not, see .
26 | */
27 |
28 | #pragma once
29 |
30 | #ifndef ROOTTOPOLOGY_H
31 | #define ROOTTOPOLOGY_H
32 |
33 | #include "common_types.h"
34 |
35 | void getroottopology(cv::Mat &_skeleton, cv::Mat dist, PointList branchpts, PointList endpts, PointList overlappts, ListofListsRef rootsegments, bool pruneroots, int rootPruningThreshold);
36 |
37 | cv::Mat drawtopology(cv::Mat segmented, cv::Mat skeleton, PointList branchpts, PointList endpts, PointList overlappts);
38 | cv::Mat drawtopology2(cv::Mat segmented, cv::Scalar_ ranges, cv::Mat _skeleton, PointList branchpts, PointList endpts, PointList overlappts);
39 |
40 | cv::Mat drawtopology_wholeroot(cv::Mat img, cv::Scalar_ ranges, std::vector> cc, std::vector colorcodes, std::vector> colors);
41 | cv::Mat drawtopology_disconnectedroot(cv::Mat segmented, cv::Mat dist, cv::Scalar_ ranges, cv::Mat _skeleton, PointList branchpts, PointList endpts, PointList overlappts, int width);
42 |
43 | cv::Mat drawmedialaxis(cv::Mat dist, cv::Mat skel, std::vector rranges, int width);
44 |
45 | #endif
46 |
47 |
--------------------------------------------------------------------------------
/changelog.txt:
--------------------------------------------------------------------------------
1 | version 2.0.3
2 | -------------
3 | Source code updated to reflect transfer of copyright from Noble Research
4 | Institute, LLC to Anand Seethepalli and Larry York.
5 |
6 | Updated license to GNU GPL version 3.
7 |
8 | version 2.0.2
9 | -------------
10 | New features:
11 | * The application is renamed to RhizoVision Explorer to reflect the huge revamp
12 | in the UI. The UI is expanded from only a batch processer for directories of
13 | images to a fully interactive tool. The application consists of a main window
14 | consisting of menus, toolbar and several panes such as analysis options,
15 | features, log, and ROI Manager. This functionality provided by cvutil library
16 | contains the following features.
17 | 1. Supports drag & drop of images to load.
18 | 2. Supports image panning and zooming.
19 | 3. Allows user to inspect pixel values in five different color spaces
20 | such as RGB, HSV, HLS, Lab and Luv.
21 | 4. Supports drawing Region-of-Interest (ROI) rectangles on the image
22 | to highlight important portions.
23 | 5. User can query pixel statistics of a loaded image in five different
24 | color spaces (mentioned above), either on an entire image, or the
25 | locations specified by ROIs. The statistics include mean and SD of
26 | the color channels.
27 | 6. The ROI subsystem supports selecting, moving, resizing and deleting
28 | multiple ROIs. Deleting the ROIs can be done using the delete key.
29 | Ctrl+A selects all the ROIs. All the ROIs can be deleted from the
30 | menu using Edit->ROI->Clear all ROIs.
31 | 7. The ROI subsystem also supports exporting and importing the ROIs as
32 | annotations in a text file.
33 | 8. The ROI Manager pane to the right of the main Window shows the ROIs
34 | that are currently present on the image. Selecting an ROI shows its
35 | dimensions, which can be edited in the pane.
36 | 9. The main window supports plugin system. When a plugin is loaded, its
37 | settings are populated to the left of the main window. Plugins are
38 | independent modules that implement a specific procedure/method/algorithm
39 | that can be attached to and configured frim inside the main window.
40 | 10. Main window supports browsing images in the same folder using left
41 | and right arrow keys.
42 | 11. Supports "Analyze" button in the toolbar, that invokes the current
43 | plugin loaded to perform analysis on the loaded image.
44 | 12. The main window has a log pane for logging info/warning/error messages
45 | and a features pane to display any extracted features from the plugin.
46 | Both the panes are located at the bottom of the main window.
47 | 13. The main window supports color inversion and 90 degree rotation of
48 | a loaded image.
49 | 14. If the current plugin has multiple outputs, these outputs can be
50 | browsed from the toolbar of the main window or by pressing SPACE key.
51 | SPACE key toggles the image displayed between input image and multiple
52 | output images.
53 | * The RhizoVision Explorer supports feature extraction from both root crown and
54 | broken root images that were acquired using flatbed scanner using Whole root
55 | and Brokwn root modes respectively.
56 | * The analysis options pane includes options for image pre-processing, feature
57 | extraction and output display.
58 | * The program can now convert pixels from mm using DPI value.
59 | * The program assumes the roots are darker and the background is brighter.
60 | Noise can be filtered by keeping largest connected component, filtering
61 | smaller dark components by size (non-roots) or filtering brighter components
62 | on dark components by size (fill roots).
63 | * Edge smoothing is now optional.
64 | * Feature extraction options include root pruning. Root pruning is a method
65 | where the lateral roots with root tips whose length is within the root diameter
66 | at the connecting branch plus the number of pixels given by the user.
67 | * Feature extraction options also include setting diameter ranges. A maximum
68 | of 10 ranges can be set.
69 | * User can configure how an output image can be displayed using output display
70 | options. This can be done using output display options.
71 | * After analysis the relevant features from either whole root or broken roots
72 | are extracted and populated in the Features pane at the bottom of the main
73 | window.
74 | * A histogram pane shows after running analysis that shows the total length in
75 | each diameter bin and updates with new analysis
76 | * Help has an About dialog with information about the version, license, and
77 | contact information.
78 | * The program now extracts histograms of root length, projected area, surface
79 | area and volume with bins as the diameter ranges given by the user in the
80 | Analysis options pane.
81 | * While extracting features of an image in interactive mode, a prograss bar
82 | shows the amount of progress and the steps currently running on the image.
83 | * If the images are taken in a different rotation, they can be rotated and
84 | analyzed within the program.
85 | * If Region-of-Interests (ROIs) are drawn on an image, the program only analyzes
86 | the image data in the ROIs. This may be helpful, when cropping borders or
87 | if an image has multiple root samples that require separate processing.
88 | The batch analysis also applies the existing ROIs to every image in the
89 | folder before analyzing.
90 | * The program now supports root pruning. Enabling the pruning option with
91 | a threshold level discards root segments greater than the radius of the
92 | parent segment plus the threshold level.
93 |
94 | Fixes:
95 | * main.cpp: Fixed type casting variables from unsigned int to signed int.
96 | * MainUI.cpp: Fixed loading/saving image paths to use QFile instead of fstream
97 | to fix errors when the path has non-English characters.
98 |
99 | Version 1.0:
100 | -----------
101 | New features:
102 | ------------
103 | * Modified feature extraction function to extract features in two separate threads.
104 | * Calculated area of convex polygon without drawing the pixels in a separate image.
105 | * Added About dialog box.
106 | * Added in-program documentation. It can be accessed by clicking '?' symbol at the
107 | top right corner and clicking the user interface controls.
108 | * Added support for file types: PNG, JPG, BMP, JPEG, JPE, DIB, JP2, TIFF, TIF.
109 | * The program now saves the user options in a separate metadata.csv in the same
110 | output folder along with features.csv for future reference.
111 | * Added icons and logo to the software.
112 |
113 | Issues fixed:
114 | ------------
115 | * Replaced conventional rand() function from C to random_device in C++ for longer
116 | periodicity.
117 | * Fixed program to crop empty regions before performing analysis to improve speed.
118 | * Before extracting median and maximum root numbers, the program now skips zeros
119 | from the list of root numbers from each rows.
120 | * Fixed estimation of Perimeter, where the program computed the sum of distances
121 | between contour points excluding the segment that connects first and last contour
122 | points in a circular contour.
123 | * Average and median diameter is now zero for an empty image where the program
124 | previously crashed for the input.
125 | * Fixed estimation of volume and surface area of plant root so that the extracted
126 | feature is invariant to rotation of image. This issue was observed when an image
127 | was created containing manually drawn straight line of same length but at different
128 | angles was passed to RhizoVision Analyzer.
129 | * The program now saves root diameters (average, median and maximum) instead of
130 | radii for easier verification by end users.
131 | * Fixed generation of orientation histograms as the program iterates only a few
132 | points due to wrong loop condition.
133 | * Fixed generation of orientation histograms where the program crashed when the
134 | root segment has only one pixel.
135 | * The program is fixed to check the availability of Intel AVX 2.0 instruction set
136 | and enable vector acceleration accordingly.
137 | * Fixed estimation of maximum diameter to scan all skeletal pixels and select the
138 | location of the pixel having maximum diameter that has highest row index (or
139 | greatest depth).
140 |
141 | Version 0.91
142 | ------------
143 | New features:
144 | ------------
145 | * Added UI option to save binary segmented images.
146 | * Added two new features - Number of Root Tips and Average Root Angle.
147 | * Added UI controls to set diameter ranges.
148 | * Added UI controls to manually set the threshold level.
149 |
150 | Issues fixed:
151 | ------------
152 | * Fixed issues where ghost skeletons are created.
153 | * Fixed issue in skeletonization where the ridges were not connected to the main ridge
154 | due to mis-identification of ridge endpoints.
155 | * The distanceTransform() on OpenCV returns wrong distances (for precise Euclidean
156 | distances) for pixels with location greater than 4096 rows or columns. This may
157 | make harder to compute distance transforms for larger sized images. Although
158 | OpenCV is open-source, it internally calls functions from Intel's proprietary
159 | library called Intel Performance Premitives (IPP) to compute the precise Euclidean
160 | distance transforms. Currently implemented the same algorithm as referred in IPP
161 | manually.
162 |
163 | Version 0.9
164 | -----------
165 | New features:
166 | ------------
167 | * The program is converted to a GUI. The feature extraction runs on a separate thread,
168 | while progress is shown on main window.
169 | * The user can specify in the window, the location of the images to be processed and
170 | the output location.
171 | * The program can optionally output processed images.
172 | * The program can optionally convert features from pixel units to physical units (millimeters).
173 | * An additional feature 'Average Hole Size' is extracted from the plant root images.
174 |
175 | Issues fixed:
176 | ------------
177 | * demo.h:getnearestcomponents() - Fixed an issue where nearest components were wrongly
178 | assigned.
179 | * main.cpp:getcoarsefineroots() - The coarse, medium and fine roots are returned as
180 | fraction of the total number of roots.
181 | * main.cpp:getshallowdeeproots() - The shallow, medium and deep roots are returned as
182 | fraction of the total number of roots.
183 | * main.cpp:feature_extractor() - Fixed the function to convert features from pixel units
184 | to physical units (millimeters).
185 | * roottopology.cpp:getroottolopogy() - Fixed a memory leak issue, that leads to large
186 | memory allocation of the order of 9 GB when the program is run on 4000 images.
187 |
188 | Version 0.1
189 | -----------
190 | * Initial creation.
191 | * The program runs in console window and extracts plant root features from each image in a specified directory.
192 |
--------------------------------------------------------------------------------