image-processing.scm 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 John Darrington <jmd@gnu.org>
  3. ;;; Copyright © 2017, 2019 Ricardo Wurmus <rekado@elephly.net>
  4. ;;; Copyright © 2014, 2021 Ludovic Courtès <ludo@gnu.org>
  5. ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
  6. ;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
  7. ;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <me@tobias.gr>
  8. ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
  9. ;;; Copyright © 2018 Lprndn <guix@lprndn.info>
  10. ;;; Copyright © 2019, 2021 Efraim Flashner <efraim@flashner.co.il>
  11. ;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
  12. ;;; Copyright © 2020, 2021 Vinicius Monego <monego@posteo.net>
  13. ;;; Copyright © 2020 Pierre Neidhardt <mail@ambrevar.xyz>
  14. ;;; Copyright © 2020 Brendan Tildesley <mail@brendan.scot>
  15. ;;; Copyright © 2021 Oleh Malyi <astroclubzp@gmail.com>
  16. ;;; Copyright © 2021 Felix Gruber <felgru@posteo.net>
  17. ;;; Copyright © 2021 Andy Tai <atai@atai.org>
  18. ;;; Copyright © 2021 Ekaitz Zarraga <ekaitz@elenq.tech>
  19. ;;; Copyright © 2021 Paul Garlick <pgarlick@tourbillion-technology.com>
  20. ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
  21. ;;;
  22. ;;; This file is part of GNU Guix.
  23. ;;;
  24. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  25. ;;; under the terms of the GNU General Public License as published by
  26. ;;; the Free Software Foundation; either version 3 of the License, or (at
  27. ;;; your option) any later version.
  28. ;;;
  29. ;;; GNU Guix is distributed in the hope that it will be useful, but
  30. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  31. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  32. ;;; GNU General Public License for more details.
  33. ;;;
  34. ;;; You should have received a copy of the GNU General Public License
  35. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  36. (define-module (gnu packages image-processing)
  37. #:use-module ((guix licenses) #:prefix license:)
  38. #:use-module (guix packages)
  39. #:use-module (guix utils)
  40. #:use-module (guix download)
  41. #:use-module (guix git-download)
  42. #:use-module (guix build-system qt)
  43. #:use-module (guix build-system cmake)
  44. #:use-module (guix build-system gnu)
  45. #:use-module (guix build-system python)
  46. #:use-module (gnu packages)
  47. #:use-module (gnu packages algebra)
  48. #:use-module (gnu packages bison)
  49. #:use-module (gnu packages boost)
  50. #:use-module (gnu packages check)
  51. #:use-module (gnu packages compression)
  52. #:use-module (gnu packages curl)
  53. #:use-module (gnu packages docbook)
  54. #:use-module (gnu packages documentation)
  55. #:use-module (gnu packages flex)
  56. #:use-module (gnu packages fontutils)
  57. #:use-module (gnu packages geo)
  58. #:use-module (gnu packages ghostscript)
  59. #:use-module (gnu packages gl)
  60. #:use-module (gnu packages glib)
  61. #:use-module (gnu packages gnome)
  62. #:use-module (gnu packages graphics)
  63. #:use-module (gnu packages graphviz)
  64. #:use-module (gnu packages gstreamer)
  65. #:use-module (gnu packages gtk)
  66. #:use-module (gnu packages icu4c)
  67. #:use-module (gnu packages image)
  68. #:use-module (gnu packages imagemagick)
  69. #:use-module (gnu packages maths)
  70. #:use-module (gnu packages pdf)
  71. #:use-module (gnu packages perl)
  72. #:use-module (gnu packages photo)
  73. #:use-module (gnu packages pkg-config)
  74. #:use-module (gnu packages protobuf)
  75. #:use-module (gnu packages python)
  76. #:use-module (gnu packages python-check)
  77. #:use-module (gnu packages python-xyz)
  78. #:use-module (gnu packages qt)
  79. #:use-module (gnu packages serialization)
  80. #:use-module (gnu packages sqlite)
  81. #:use-module (gnu packages tbb)
  82. #:use-module (gnu packages tls)
  83. #:use-module (gnu packages version-control)
  84. #:use-module (gnu packages video)
  85. #:use-module (gnu packages xiph)
  86. #:use-module (gnu packages xml)
  87. #:use-module (gnu packages xorg)
  88. #:use-module (ice-9 match)
  89. #:use-module (srfi srfi-1))
  90. (define-public dcmtk
  91. (package
  92. (name "dcmtk")
  93. (version "3.6.6")
  94. (source
  95. (origin
  96. (method url-fetch)
  97. (uri
  98. (string-append "ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/"
  99. "dcmtk" (string-join (string-split version #\.) "")
  100. "/dcmtk-" version ".tar.gz"))
  101. (sha256
  102. (base32 "13j5yf3p6qj3mr17d77r3kcqchf055hgvk1w15vmdr8f54mwcnb8"))))
  103. (build-system cmake-build-system)
  104. (inputs
  105. `(("icu4c" ,icu4c)
  106. ("libjpeg" ,libjpeg-turbo)
  107. ("libpng" ,libpng)
  108. ("libtiff" ,libtiff)
  109. ("libxml2" ,libxml2)
  110. ("openssl" ,openssl)
  111. ("zlib" ,zlib)))
  112. (native-inputs
  113. `(("doxygen" ,doxygen))) ; for HTML documentation
  114. (home-page "https://dcmtk.org")
  115. (synopsis "Libraries and programs implementing parts of the DICOM standard")
  116. (description "DCMTK is a collection of libraries and applications
  117. implementing large parts the DICOM standard. It includes software for
  118. examining, constructing and converting DICOM image files, handling offline
  119. media, sending and receiving images over a network connection, as well as
  120. demonstrative image storage and worklist servers.")
  121. (license (license:fsf-free
  122. "file://COPYRIGHT"
  123. "A union of the Apache 2.0 licence and various non-copyleft
  124. licences similar to the Modified BSD licence."))))
  125. (define-public mia
  126. (package
  127. (name "mia")
  128. (version "2.4.6")
  129. (source (origin
  130. (method url-fetch)
  131. (uri (string-append "mirror://sourceforge/mia/mia/"
  132. (version-major+minor version)
  133. "/mia-" version ".tar.xz"))
  134. (sha256
  135. (base32
  136. "0j4nd5z7i3v199jh7hqqhwd4g7snchizkc7rhzanpvngqg91m1pb"))))
  137. (build-system cmake-build-system)
  138. (arguments
  139. `(#:configure-flags
  140. (list "-DMIA_CREATE_NIPYPE_INTERFACES=0"
  141. "-DCMAKE_CXX_FLAGS=-fpermissive")))
  142. (inputs
  143. `(("boost" ,boost)
  144. ("dcmtk" ,dcmtk)
  145. ("doxygen" ,doxygen)
  146. ("eigen" ,eigen)
  147. ("fftw" ,fftw)
  148. ("fftwf" ,fftwf)
  149. ("gsl" ,gsl)
  150. ("gts" ,gts)
  151. ("hdf5" ,hdf5)
  152. ("itpp" ,itpp)
  153. ("libjpeg" ,libjpeg-turbo)
  154. ("libpng" ,libpng)
  155. ("libtiff" ,libtiff)
  156. ("libxml" ,libxml2)
  157. ("libxml++" ,libxml++)
  158. ("maxflow" ,maxflow)
  159. ("niftilib" ,niftilib)
  160. ("nlopt" ,nlopt)
  161. ("openexr" ,openexr)
  162. ("python-lxml" ,python2-lxml)
  163. ("vtk" ,vtk)))
  164. (native-inputs
  165. `(("pkg-config" ,pkg-config)
  166. ("python" ,python-2)))
  167. (home-page "http://mia.sourceforge.net")
  168. (synopsis "Toolkit for gray scale medical image analysis")
  169. (description "MIA provides a combination of command line tools, plug-ins,
  170. and libraries that make it possible run image processing tasks interactively
  171. in a command shell and to prototype using the shell's scripting language. It
  172. is built around a plug-in structure that makes it easy to add functionality
  173. without compromising the original code base and it makes use of a wide variety
  174. of external libraries that provide additional functionality.")
  175. (license license:gpl3+)))
  176. (define-public opencolorio
  177. (package
  178. (name "opencolorio")
  179. (version "1.1.1")
  180. (source
  181. (origin
  182. (method git-fetch)
  183. (uri (git-reference
  184. (url "https://github.com/AcademySoftwareFoundation/OpenColorIO")
  185. (commit (string-append "v" version))))
  186. (sha256
  187. (base32 "12srvxca51czpfjl0gabpidj9n84mw78ivxy5w75qhq2mmc798sb"))
  188. (file-name (git-file-name name version))
  189. (modules '((guix build utils)))
  190. (snippet
  191. `(begin
  192. ;; Remove bundled tarballs, patches, and .jars(!). XXX: Upstream
  193. ;; claims to have fixed USE_EXTERNAL_YAML, but it still fails with:
  194. ;; https://github.com/AcademySoftwareFoundation/OpenColorIO/issues/517
  195. ;; When removing it, also remove it from the licence field comment.
  196. (for-each delete-file-recursively
  197. (filter
  198. (lambda (full-name)
  199. (let ((file (basename full-name)))
  200. (not (or (string-prefix? "yaml-cpp-0.3" file)
  201. (string=? "unittest.h" file)))))
  202. (find-files "ext" ".*")))
  203. #t))))
  204. (build-system cmake-build-system)
  205. (arguments
  206. `(#:configure-flags
  207. (list (string-append "-DCMAKE_CXX_FLAGS="
  208. "-Wno-error=deprecated-declarations "
  209. "-Wno-error=unused-function")
  210. "-DOCIO_BUILD_STATIC=OFF"
  211. ;; "-DUSE_EXTERNAL_YAML=ON"
  212. "-DUSE_EXTERNAL_TINYXML=ON"
  213. "-DUSE_EXTERNAL_LCMS=ON")
  214. #:phases
  215. (modify-phases %standard-phases
  216. (add-after 'unpack 'patch-test-suite
  217. (lambda _
  218. (substitute* "src/core_tests/CMakeLists.txt"
  219. (("/bin/sh") (which "bash")))
  220. #t)))))
  221. (native-inputs
  222. `(("git" ,git)
  223. ("pkg-config" ,pkg-config)))
  224. (inputs
  225. ;; XXX Adding freeglut, glew, ilmbase, mesa, and openimageio for
  226. ;; ocioconvert fails: error: conflicting declaration ?typedef void
  227. ;; (* PFNGLGETFRAGMENTMATERIALFVSGIXPROC)(GLenum, GLenum, GLfloat*)
  228. `(("lcms" ,lcms)
  229. ("openexr" ,openexr)
  230. ("tinyxml" ,tinyxml)))
  231. (home-page "https://opencolorio.org")
  232. (synopsis "Color management for visual effects and animation")
  233. (description
  234. "OpenColorIO, or OCIO, is a complete color management solution geared
  235. towards motion picture production, with an emphasis on visual effects and
  236. computer animation. It provides a straightforward and consistent user
  237. experience across all supporting applications while allowing for sophisticated
  238. back-end configuration options suitable for high-end production usage.
  239. OCIO is compatible with the @acronym{ACES, Academy Color Encoding
  240. Specification} and is @acronym{LUT, look-up table}-format agnostic, supporting
  241. many popular formats.")
  242. (license (list license:expat ; docs/ociotheme/static, ext/yaml-cpp-*
  243. license:zlib ; src/core/md5
  244. license:bsd-3)))) ; the rest
  245. (define-public vtk
  246. (package
  247. (name "vtk")
  248. (version "9.0.1")
  249. (source (origin
  250. (method url-fetch)
  251. (uri (string-append "https://vtk.org/files/release/"
  252. (version-major+minor version)
  253. "/VTK-" version ".tar.gz"))
  254. (sha256
  255. (base32
  256. "1ir2lq9i45ls374lcmjzw0nrm5l5hnm1w47lg8g8d0n2j7hsaf8v"))
  257. (patches
  258. (search-patches "vtk-fix-freetypetools-build-failure.patch"))
  259. (modules '((guix build utils)))
  260. (snippet
  261. '(begin
  262. (for-each
  263. (lambda (dir)
  264. (delete-file-recursively
  265. (string-append "ThirdParty/" dir "/vtk" dir)))
  266. ;; pugixml depended upon unconditionally
  267. '("doubleconversion" "eigen" "expat" "freetype" "gl2ps"
  268. "glew" "hdf5" "jpeg" "jsoncpp" "libproj" "libxml2" "lz4"
  269. "netcdf" "ogg" "png" "sqlite" "theora" "tiff" "zlib"))
  270. #t))))
  271. (properties `((release-monitoring-url . "https://vtk.org/download/")))
  272. (build-system cmake-build-system)
  273. (arguments
  274. '(#:build-type "Release" ;Build without '-g' to save space.
  275. #:configure-flags '(;"-DBUILD_TESTING:BOOL=TRUE"
  276. ; ; not honored
  277. "-DVTK_USE_EXTERNAL=OFF" ;; default
  278. "-DVTK_MODULE_USE_EXTERNAL_VTK_doubleconversion=ON"
  279. "-DVTK_MODULE_USE_EXTERNAL_VTK_eigen=ON"
  280. "-DVTK_MODULE_USE_EXTERNAL_VTK_expat=ON"
  281. "-DVTK_MODULE_USE_EXTERNAL_VTK_freetype=ON"
  282. "-DVTK_MODULE_USE_EXTERNAL_VTK_gl2ps=ON"
  283. "-DVTK_MODULE_USE_EXTERNAL_VTK_glew=ON"
  284. "-DVTK_MODULE_USE_EXTERNAL_VTK_hdf5=ON"
  285. "-DVTK_MODULE_USE_EXTERNAL_VTK_jpeg=ON"
  286. "-DVTK_MODULE_USE_EXTERNAL_VTK_jsoncpp=ON"
  287. "-DVTK_MODULE_USE_EXTERNAL_VTK_libproj=ON"
  288. "-DVTK_MODULE_USE_EXTERNAL_VTK_libxml2=ON"
  289. "-DVTK_MODULE_USE_EXTERNAL_VTK_lz4=ON"
  290. "-DVTK_MODULE_USE_EXTERNAL_VTK_netcdf=ON"
  291. "-DVTK_MODULE_USE_EXTERNAL_VTK_ogg=ON"
  292. "-DVTK_MODULE_USE_EXTERNAL_VTK_png=ON"
  293. ;"-DVTK_MODULE_USE_EXTERNAL_VTK_pugixml=ON" ; breaks IO/CityGML
  294. "-DVTK_MODULE_USE_EXTERNAL_VTK_sqlite=ON"
  295. "-DVTK_MODULE_USE_EXTERNAL_VTK_theora=ON"
  296. "-DVTK_MODULE_USE_EXTERNAL_VTK_tiff=ON"
  297. "-DVTK_MODULE_USE_EXTERNAL_VTK_zlib=ON"
  298. "-DVTK_WRAP_PYTHON=ON"
  299. "-DVTK_PYTHON_VERSION:STRING=3"
  300. )
  301. #:phases
  302. (modify-phases %standard-phases
  303. (add-after 'unpack 'patch-sources
  304. (lambda _
  305. (substitute* "Common/Core/vtkFloatingPointExceptions.cxx"
  306. (("<fenv.h>") "<cfenv>"))
  307. (substitute* "Common/Core/CMakeLists.txt"
  308. (("fenv.h") "cfenv")))))
  309. #:tests? #f)) ;XXX: test data not included
  310. (inputs
  311. `(("double-conversion" ,double-conversion)
  312. ("eigen" ,eigen)
  313. ("expat" ,expat)
  314. ("freetype" ,freetype)
  315. ("gl2ps" ,gl2ps)
  316. ("glew" ,glew)
  317. ("glu" ,glu)
  318. ("hdf5" ,hdf5)
  319. ("jpeg" ,libjpeg-turbo)
  320. ("jsoncpp" ,jsoncpp)
  321. ("libtheora" ,libtheora)
  322. ("libX11" ,libx11)
  323. ("libxml2" ,libxml2)
  324. ("libXt" ,libxt)
  325. ("lz4" ,lz4)
  326. ("mesa" ,mesa)
  327. ("netcdf" ,netcdf)
  328. ("png" ,libpng)
  329. ("proj" ,proj.4)
  330. ("python", python)
  331. ;("pugixml" ,pugixml)
  332. ("sqlite" ,sqlite)
  333. ("tiff" ,libtiff)
  334. ("xorgproto" ,xorgproto)
  335. ("zlib" ,zlib)))
  336. (propagated-inputs
  337. ;; VTK's 'VTK-vtk-module-find-packages.cmake' calls
  338. ;; 'find_package(THEORA)', which in turns looks for libogg.
  339. `(("libogg" ,libogg)))
  340. (home-page "https://vtk.org/")
  341. (synopsis "Libraries for 3D computer graphics")
  342. (description
  343. "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
  344. image processing and visualization. It supports a wide variety of
  345. visualization algorithms including: scalar, vector, tensor, texture, and
  346. volumetric methods; and advanced modeling techniques such as: implicit
  347. modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay
  348. triangulation. VTK has an extensive information visualization framework, has
  349. a suite of 3D interaction widgets, supports parallel processing, and
  350. integrates with various databases on GUI toolkits such as Qt and Tk.")
  351. (license license:bsd-3)))
  352. ;; freecad needs an old version of VTK, because VTK's API changed from 8 to 9
  353. (define-public vtk-8
  354. (package
  355. (name "vtk")
  356. (version "8.2.0")
  357. (source (origin
  358. (method url-fetch)
  359. (uri (string-append "https://vtk.org/files/release/"
  360. (version-major+minor version)
  361. "/VTK-" version ".tar.gz"))
  362. (sha256
  363. (base32
  364. "1fspgp8k0myr6p2a6wkc21ldcswb4bvmb484m12mxgk1a9vxrhrl"))
  365. (patches
  366. (search-patches "vtk-8-fix-freetypetools-build-failure.patch"))
  367. (modules '((guix build utils)))
  368. (snippet
  369. '(begin
  370. (for-each
  371. (lambda (dir)
  372. (delete-file-recursively
  373. (string-append "ThirdParty/" dir "/vtk" dir)))
  374. ;; ogg, pugixml depended upon unconditionally
  375. '("doubleconversion" "eigen" "expat" "freetype" "gl2ps"
  376. "glew" "hdf5" "jpeg" "jsoncpp" "libproj" "libxml2" "lz4"
  377. "netcdf" "png" "sqlite" "theora" "tiff" "zlib"))
  378. #t))))
  379. (build-system cmake-build-system)
  380. (arguments
  381. '(#:build-type "Release" ;Build without '-g' to save space.
  382. #:configure-flags '(;"-DBUILD_TESTING:BOOL=TRUE"
  383. ;"-DVTK_MODULE_USE_EXTERNAL_vtkogg:BOOL=TRUE" ; not honored
  384. "-DVTK_USE_SYSTEM_DOUBLECONVERSION:BOOL=TRUE"
  385. "-DVTK_USE_SYSTEM_EIGEN:BOOL=TRUE"
  386. "-DVTK_USE_SYSTEM_EXPAT:BOOL=TRUE"
  387. "-DVTK_USE_SYSTEM_FREETYPE:BOOL=TRUE"
  388. "-DVTK_USE_SYSTEM_GL2PS:BOOL=TRUE"
  389. "-DVTK_USE_SYSTEM_GLEW:BOOL=TRUE"
  390. "-DVTK_USE_SYSTEM_HDF5:BOOL=TRUE"
  391. "-DVTK_USE_SYSTEM_JPEG:BOOL=TRUE"
  392. "-DVTK_USE_SYSTEM_JSONCPP:BOOL=TRUE"
  393. "-DVTK_USE_SYSTEM_LIBPROJ:BOOL=TRUE"
  394. "-DVTK_USE_SYSTEM_LIBXML2:BOOL=TRUE"
  395. "-DVTK_USE_SYSTEM_LZ4:BOOL=TRUE"
  396. "-DVTK_USE_SYSTEM_NETCDF:BOOL=TRUE"
  397. "-DVTK_USE_SYSTEM_PNG:BOOL=TRUE"
  398. ;"-DVTK_USE_SYSTEM_PUGIXML:BOOL=TRUE" ; breaks IO/CityGML
  399. "-DVTK_USE_SYSTEM_SQLITE:BOOL=TRUE"
  400. "-DVTK_USE_SYSTEM_THEORA:BOOL=TRUE"
  401. "-DVTK_USE_SYSTEM_TIFF:BOOL=TRUE"
  402. "-DVTK_USE_SYSTEM_ZLIB:BOOL=TRUE")
  403. #:tests? #f)) ;XXX: test data not included
  404. (inputs
  405. `(("double-conversion" ,double-conversion)
  406. ("eigen" ,eigen)
  407. ("expat" ,expat)
  408. ("freetype" ,freetype)
  409. ("gl2ps" ,gl2ps)
  410. ("glew" ,glew)
  411. ("glu" ,glu)
  412. ("hdf5" ,hdf5)
  413. ("jpeg" ,libjpeg-turbo)
  414. ("jsoncpp" ,jsoncpp)
  415. ;("libogg" ,libogg)
  416. ("libtheora" ,libtheora)
  417. ("libX11" ,libx11)
  418. ("libxml2" ,libxml2)
  419. ("libXt" ,libxt)
  420. ("lz4" ,lz4)
  421. ("mesa" ,mesa)
  422. ("netcdf" ,netcdf)
  423. ("png" ,libpng)
  424. ("proj" ,proj.4)
  425. ;("pugixml" ,pugixml)
  426. ("sqlite" ,sqlite)
  427. ("tiff" ,libtiff)
  428. ("xorgproto" ,xorgproto)
  429. ("zlib" ,zlib)))
  430. (home-page "https://vtk.org/")
  431. (synopsis "Libraries for 3D computer graphics")
  432. (description
  433. "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
  434. image processing and visualization. It supports a wide variety of
  435. visualization algorithms including: scalar, vector, tensor, texture, and
  436. volumetric methods; and advanced modeling techniques such as: implicit
  437. modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay
  438. triangulation. VTK has an extensive information visualization framework, has
  439. a suite of 3D interaction widgets, supports parallel processing, and
  440. integrates with various databases on GUI toolkits such as Qt and Tk.")
  441. (license license:bsd-3)))
  442. ;; itksnap needs an older variant of VTK.
  443. (define-public vtk-6
  444. (package (inherit vtk)
  445. (version "6.3.0")
  446. (source (origin
  447. (method url-fetch)
  448. (uri (string-append "https://vtk.org/files/release/"
  449. (version-major+minor version)
  450. "/VTK-" version ".tar.gz"))
  451. (sha256
  452. (base32
  453. "0pla1r5mvkgl4sl213gfdhzrypdgai0h3z5mfgm6p9jz9hsr794j"))))
  454. (inputs
  455. `(("jsoncpp" ,jsoncpp-for-tensorflow)
  456. ,@(alist-delete "jsoncpp" (package-inputs vtk))))))
  457. (define-public opencv
  458. (package
  459. (name "opencv")
  460. (version "3.4.3")
  461. (source (origin
  462. (method git-fetch)
  463. (uri (git-reference
  464. (url "https://github.com/opencv/opencv")
  465. (commit version)))
  466. (file-name (git-file-name name version))
  467. (sha256
  468. (base32
  469. "06bc61r8myym4s8im10brdjfg4wxkrvsbhhl7vr1msdan2xddzi3"))
  470. (patches
  471. (search-patches "opencv-fix-build-of-grfmt_jpeg2000.cpp.patch"))
  472. (modules '((guix build utils)))
  473. (snippet
  474. '(begin
  475. ;; Remove external libraries. We have all available in Guix:
  476. (delete-file-recursively "3rdparty")
  477. ;; Milky icon set is non-free:
  478. (delete-file-recursively "modules/highgui/src/files_Qt/Milky")
  479. ;; Some jars found:
  480. (for-each delete-file
  481. '("modules/java/test/pure_test/lib/junit-4.11.jar"
  482. "samples/java/sbt/sbt/sbt-launch.jar"))
  483. #t))))
  484. (build-system cmake-build-system)
  485. (arguments
  486. `(#:configure-flags
  487. (list "-DWITH_IPP=OFF"
  488. "-DWITH_ITT=OFF"
  489. "-DWITH_CAROTENE=OFF" ; only visible on arm/aarch64
  490. "-DENABLE_PRECOMPILED_HEADERS=OFF"
  491. ;; CPU-Features:
  492. ;; See cmake/OpenCVCompilerOptimizations.cmake
  493. ;; (CPU_ALL_OPTIMIZATIONS) for a list of all optimizations
  494. ;; BASELINE is the minimum optimization all CPUs must support
  495. ;;
  496. ;; DISPATCH is the list of optional dispatches.
  497. "-DCPU_BASELINE=SSE2"
  498. ,@(match (%current-system)
  499. ("x86_64-linux"
  500. '("-DCPU_DISPATCH=NEON;VFPV3;FP16;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX"
  501. "-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2"))
  502. ("armhf-linux"
  503. '("-DCPU_BASELINE_DISABLE=NEON")) ; causes build failures
  504. ("aarch64-linux"
  505. '("-DCPU_BASELINE=NEON"
  506. "-DCPU_DISPATCH=NEON;VFPV3;FP16"))
  507. (_ '()))
  508. "-DBUILD_PERF_TESTS=OFF"
  509. "-DBUILD_TESTS=ON"
  510. (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
  511. "/opencv-contrib/modules")
  512. ;;Define test data:
  513. (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
  514. "/opencv-extra/testdata")
  515. ;; Is ON by default and would try to rebuild 3rd-party protobuf,
  516. ;; which we had removed, which would lead to an error:
  517. "-DBUILD_PROTOBUF=OFF"
  518. ;; Rebuild protobuf files, because we have a slightly different
  519. ;; version than the included one. If we would not update, we
  520. ;; would get a compile error later:
  521. "-DPROTOBUF_UPDATE_FILES=ON"
  522. ;; xfeatures2d disabled, because it downloads extra binaries from
  523. ;; https://github.com/opencv/opencv_3rdparty
  524. ;; defined in xfeatures2d/cmake/download_{vgg|bootdesc}.cmake
  525. ;; Cmp this bug entry:
  526. ;; https://github.com/opencv/opencv_contrib/issues/1131
  527. "-DBUILD_opencv_xfeatures2d=OFF")
  528. #:phases
  529. (modify-phases %standard-phases
  530. (add-after 'unpack 'disable-broken-tests
  531. (lambda _
  532. ;; These tests fails with:
  533. ;; vtkXOpenGLRenderWindow (0x723990): Could not find a decent config
  534. ;; I think we have no OpenGL support with the Xvfb.
  535. (substitute* '("modules/viz/test/test_tutorial3.cpp"
  536. "modules/viz/test/test_main.cpp"
  537. "modules/viz/test/tests_simple.cpp"
  538. "modules/viz/test/test_viz3d.cpp")
  539. (("(TEST\\(Viz, )([a-z].*\\).*)" all pre post)
  540. (string-append pre "DISABLED_" post)))
  541. ;; This one fails with "unknown file: Failure"
  542. ;; But I couldn't figure out which file was missing:
  543. (substitute* "../opencv-contrib/modules/face/test/test_face_align.cpp"
  544. (("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)"
  545. all pre post)
  546. (string-append pre "DISABLED_" post)))
  547. ;; Failure reason: Bad accuracy
  548. ;; Incorrect count of accurate poses [2nd case]: 90.000000 / 94.000000
  549. (substitute* "../opencv-contrib/modules/rgbd/test/test_odometry.cpp"
  550. (("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post)
  551. (string-append pre "DISABLED_" post)))
  552. #t))
  553. (add-after 'unpack 'unpack-submodule-sources
  554. (lambda* (#:key inputs #:allow-other-keys)
  555. (mkdir "../opencv-extra")
  556. (mkdir "../opencv-contrib")
  557. (copy-recursively (assoc-ref inputs "opencv-extra")
  558. "../opencv-extra")
  559. (copy-recursively (assoc-ref inputs "opencv-contrib")
  560. "../opencv-contrib")))
  561. (add-after 'set-paths 'add-ilmbase-include-path
  562. (lambda* (#:key inputs #:allow-other-keys)
  563. ;; OpenEXR propagates ilmbase, but its include files do not appear
  564. ;; in the CPATH, so we need to add "$ilmbase/include/OpenEXR/" to
  565. ;; the CPATH to satisfy the dependency on "ImathVec.h".
  566. (setenv "CPATH"
  567. (string-append
  568. (string-drop-right
  569. (search-input-file inputs "include/OpenEXR/ImathVec.h")
  570. 11)
  571. ":" (or (getenv "CPATH") "")))))
  572. (add-before 'check 'start-xserver
  573. (lambda* (#:key inputs #:allow-other-keys)
  574. (let ((xorg-server (assoc-ref inputs "xorg-server"))
  575. (disp ":1"))
  576. (setenv "HOME" (getcwd))
  577. (setenv "DISPLAY" disp)
  578. ;; There must be a running X server and make check doesn't start one.
  579. ;; Therefore we must do it.
  580. (zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp)))))))))
  581. (native-inputs
  582. `(("pkg-config" ,pkg-config)
  583. ("xorg-server" ,xorg-server-for-tests) ; For running the tests
  584. ("opencv-extra"
  585. ,(origin
  586. (method git-fetch)
  587. (uri (git-reference
  588. (url "https://github.com/opencv/opencv_extra")
  589. (commit version)))
  590. (file-name (git-file-name "opencv_extra" version))
  591. (sha256
  592. (base32 "08p5xnq8n1jw8svvz0fnirfg7q8dm3p4a5dl7527s5xj0f9qn7lp"))))
  593. ("opencv-contrib"
  594. ,(origin
  595. (method git-fetch)
  596. (uri (git-reference
  597. (url "https://github.com/opencv/opencv_contrib")
  598. (commit version)))
  599. (file-name (git-file-name "opencv_contrib" version))
  600. (patches (search-patches "opencv-rgbd-aarch64-test-fix.patch"))
  601. (sha256
  602. (base32 "1f334glf39nk42mpqq6j732h3ql2mpz89jd4mcl678s8n73nfjh2"))))))
  603. (inputs `(("libjpeg" ,libjpeg-turbo)
  604. ("libpng" ,libpng)
  605. ("jasper" ,jasper)
  606. ;; ffmpeg 4.0 causes core dumps in tests.
  607. ("ffmpeg" ,ffmpeg-3.4)
  608. ("libtiff" ,libtiff)
  609. ("hdf5" ,hdf5)
  610. ("libgphoto2" ,libgphoto2)
  611. ("libwebp" ,libwebp)
  612. ("zlib" ,zlib)
  613. ("gtkglext" ,gtkglext)
  614. ("openexr" ,openexr)
  615. ("ilmbase" ,ilmbase)
  616. ("gtk+" ,gtk+-2)
  617. ("python-numpy" ,python-numpy)
  618. ("protobuf" ,protobuf)
  619. ("vtk" ,vtk)
  620. ("python" ,python)))
  621. ;; These three CVEs are not a problem of OpenCV, see:
  622. ;; https://github.com/opencv/opencv/issues/10998
  623. (properties '((lint-hidden-cve . ("CVE-2018-7712"
  624. "CVE-2018-7713"
  625. "CVE-2018-7714"))))
  626. (synopsis "Computer vision library")
  627. (description "OpenCV is a library aimed at
  628. real-time computer vision, including several hundred computer
  629. vision algorithms. It can be used to do things like:
  630. @itemize
  631. @item image and video input and output
  632. @item image and video processing
  633. @item displaying
  634. @item feature recognition
  635. @item segmentation
  636. @item facial recognition
  637. @item stereo vision
  638. @item structure from motion
  639. @item augmented reality
  640. @item machine learning
  641. @end itemize\n")
  642. (home-page "https://opencv.org/")
  643. (license license:bsd-3)))
  644. (define-public vips
  645. (package
  646. (name "vips")
  647. (version "8.10.6")
  648. (source
  649. (origin
  650. (method url-fetch)
  651. (uri (string-append
  652. "https://github.com/libvips/libvips/releases/download/v"
  653. version "/vips-" version ".tar.gz"))
  654. (sha256
  655. (base32 "0vjsh3i0861f6h9as3bch956cidz824zz499pvhjs3lfjn6hhs14"))))
  656. (build-system gnu-build-system)
  657. (native-inputs
  658. `(("gobject-introspection" ,gobject-introspection)
  659. ("pkg-config" ,pkg-config)))
  660. (inputs
  661. `(("expat" ,expat)
  662. ("fftw" ,fftw)
  663. ("giflib" ,giflib)
  664. ("glib" ,glib)
  665. ("hdf5" ,hdf5)
  666. ("imagemagick" ,imagemagick)
  667. ("lcms" ,lcms)
  668. ("libexif" ,libexif)
  669. ("libgsf" ,libgsf)
  670. ("libjpeg" ,libjpeg-turbo)
  671. ("libpng" ,libpng)
  672. ("librsvg" ,librsvg)
  673. ("libtiff" ,libtiff)
  674. ("libxml2" ,libxml2)
  675. ("libwebp" ,libwebp)
  676. ("matio" ,matio)
  677. ("niftilib" ,niftilib)
  678. ("openexr" ,openexr)
  679. ("orc" ,orc)
  680. ("pango" ,pango)
  681. ("poppler" ,poppler)))
  682. (home-page "https://libvips.github.io/libvips/")
  683. (synopsis "Multithreaded image processing system with low memory needs")
  684. (description
  685. "VIPS is a demand-driven, horizontally threaded image processing library.
  686. It's particularly good at processing large images, working with colour,
  687. scientific analysis, and general research & development.
  688. Compared to most image processing libraries VIPS needs little RAM and runs
  689. quickly, especially on machines with more than one CPU core. This is primarily
  690. due to its architecture which automatically parallelises the image workflows.")
  691. (license license:lgpl2.1+)))
  692. (define-public gmic
  693. (package
  694. (name "gmic")
  695. (version "2.9.7")
  696. (source
  697. (origin
  698. (method url-fetch)
  699. (uri (string-append "https://gmic.eu/files/source/gmic_"
  700. version ".tar.gz"))
  701. (sha256
  702. (base32 "05kzaplsl5qvxs7v6g73q0lq8dii8g6v77ap609188m7gr43f9cl"))))
  703. (build-system cmake-build-system)
  704. (arguments
  705. `(#:tests? #f ;there are no tests
  706. #:configure-flags '("-DBUILD_LIB_STATIC=OFF"
  707. "-DENABLE_DYNAMIC_LINKING=ON"
  708. "-DENABLE_LTO=ON")
  709. #:phases
  710. (modify-phases %standard-phases
  711. (add-before 'configure 'set-LDFLAGS
  712. (lambda* (#:key inputs outputs #:allow-other-keys)
  713. (setenv "LDFLAGS"
  714. (string-append
  715. "-Wl,-rpath="
  716. (assoc-ref outputs "out") "/lib")))))))
  717. (native-inputs
  718. `(("pkg-config" ,pkg-config)))
  719. (inputs
  720. `(("curl" ,curl)
  721. ("fftw" ,fftw)
  722. ("graphicsmagick" ,graphicsmagick)
  723. ("libjpeg-turbo" ,libjpeg-turbo)
  724. ("libpng" ,libpng)
  725. ("libtiff" ,libtiff)
  726. ("libx11" ,libx11)
  727. ;;("opencv" ,opencv) ;OpenCV is currently broken in the CI
  728. ("openexr" ,openexr)
  729. ("zlib" ,zlib)))
  730. (home-page "https://gmic.eu/")
  731. (synopsis "Full-featured framework for digital image processing")
  732. (description "G'MIC is a full-featured framework for digital image
  733. processing. It provides several user interfaces to convert / manipulate
  734. / filter / visualize generic image datasets, ranging from 1D scalar
  735. signals to 3D+t sequences of multi-spectral volumetric images, hence
  736. including 2D color images.")
  737. ;; Dual-licensed, either license applies.
  738. (license (list license:cecill license:cecill-c))))
  739. (define-public gmic-qt
  740. (package
  741. (inherit gmic)
  742. (name "gmic-qt")
  743. (arguments
  744. (substitute-keyword-arguments (package-arguments gmic)
  745. ((#:configure-flags _)
  746. `(list "-DGMIC_QT_HOST=none" "-DENABLE_DYNAMIC_LINKING=ON"
  747. (string-append "-DGMIC_LIB_PATH="
  748. (assoc-ref %build-inputs "gmic") "/lib")))
  749. ((#:phases phases)
  750. `(modify-phases ,phases
  751. (add-after 'unpack 'qt-chdir
  752. (lambda _ (chdir "gmic-qt") #t))))))
  753. (native-inputs
  754. `(("pkg-config" ,pkg-config)
  755. ("qttools" ,qttools)))
  756. (inputs
  757. `(("gmic" ,gmic)
  758. ("qtbase" ,qtbase-5)
  759. ,@(package-inputs gmic)))
  760. (synopsis "Qt frontend for the G'MIC image processing framework")
  761. (license license:gpl3+)))
  762. (define-public gmic-qt-krita
  763. (package
  764. (inherit gmic-qt)
  765. (name "gmic-qt-krita")
  766. (arguments
  767. (substitute-keyword-arguments (package-arguments gmic-qt)
  768. ((#:configure-flags flags)
  769. '(list "-DGMIC_QT_HOST=krita" "-DENABLE_DYNAMIC_LINKING=ON"
  770. (string-append "-DGMIC_LIB_PATH="
  771. (assoc-ref %build-inputs "gmic") "/lib")))))
  772. (synopsis "Krita plugin for the G'MIC image processing framework")))
  773. (define-public nip2
  774. (package
  775. (name "nip2")
  776. (version "8.7.1")
  777. (source
  778. (origin
  779. (method url-fetch)
  780. (uri (string-append "https://github.com/libvips/nip2/releases/download/v"
  781. version "/nip2-" version ".tar.gz" ))
  782. (sha256
  783. (base32 "0l7n427njif53npqn02gfjjly8y3khbrkzqxp10j5vp9h97psgiw"))))
  784. (build-system gnu-build-system)
  785. (arguments
  786. `(#:phases
  787. (modify-phases %standard-phases
  788. ;; test_conv.ws keep failing so disabling for now.
  789. (add-after 'unpack 'disable-test-conv
  790. (lambda _
  791. (delete-file "test/workspaces/test_conv.ws")
  792. #t))
  793. (add-before 'check 'set-home
  794. (lambda _
  795. (setenv "HOME" "/tmp") #t)))))
  796. (inputs
  797. `(("vips" ,vips)
  798. ("glib" ,glib)
  799. ("libtiff" ,libtiff)
  800. ("gtk+-2" ,gtk+-2)
  801. ("libxml2" ,libxml2)
  802. ("libexif" ,libexif)
  803. ("libjpeg" ,libjpeg-turbo) ;required by vips.pc
  804. ("librsvg" ,librsvg)
  805. ("fftw" ,fftw)
  806. ("libgsf" ,libgsf)
  807. ("imagemagick" ,imagemagick)
  808. ("orc" ,orc)
  809. ("matio" ,matio)
  810. ("lcms" ,lcms)
  811. ("libwebp" ,libwebp)
  812. ("openexr" ,openexr)
  813. ("poppler" ,poppler)
  814. ("gsl" ,gsl)))
  815. (native-inputs
  816. `(("flex" ,flex)
  817. ("bison" ,bison)
  818. ("pkg-config" ,pkg-config)))
  819. (home-page "https://github.com/libvips/nip2")
  820. (synopsis "Spreadsheet-like GUI for libvips")
  821. (description "This package provide a graphical user interface (GUI) for
  822. the VIPS image processing library. It's a little like a spreadsheet: you
  823. create a set of formula connecting your objects together, and on a change nip2
  824. recalculates.")
  825. (license license:gpl2+)))
  826. (define-public vxl
  827. (package
  828. (name "vxl")
  829. (version "2.0.2")
  830. (source
  831. (origin
  832. (method git-fetch)
  833. (uri (git-reference
  834. (url "https://github.com/vxl/vxl")
  835. (commit (string-append "v" version))))
  836. (file-name (git-file-name name version))
  837. (sha256
  838. (base32 "0949hw57szq8943f1whwqaz591xjmb19kj803hcv74hdai2b0ycg"))
  839. (modules '((guix build utils)))
  840. ;; TODO: vxl includes an old version of dcmtk. It won't build with
  841. ;; version 3.6.x.
  842. (snippet
  843. '(begin
  844. (for-each delete-file-recursively
  845. '("v3p/bzlib/"
  846. "v3p/geotiff/"
  847. "v3p/jpeg/"
  848. "v3p/png/"
  849. "v3p/tiff/"
  850. "v3p/zlib/"))
  851. (substitute* "v3p/CMakeLists.txt"
  852. (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
  853. ""))
  854. #t))))
  855. (build-system cmake-build-system)
  856. (inputs
  857. `(("libgeotiff" ,libgeotiff)
  858. ("libtiff" ,libtiff)
  859. ("libjpeg" ,libjpeg-turbo)
  860. ("libpng" ,libpng)
  861. ("zlib" ,zlib)))
  862. (home-page "https://github.com/vxl/vxl/")
  863. (synopsis "Collection of C++ libraries for computer vision")
  864. (description "VXL (the Vision-something-Libraries) is a collection of C++
  865. libraries designed for computer vision research and implementation.")
  866. (license license:bsd-3)))
  867. (define-public vxl-1
  868. (package (inherit vxl)
  869. (name "vxl")
  870. (version "1.18.0")
  871. (source
  872. (origin
  873. (method git-fetch)
  874. (uri (git-reference
  875. (url "https://github.com/vxl/vxl")
  876. (commit (string-append "v" version))))
  877. (file-name (git-file-name name version))
  878. (sha256
  879. (base32 "1g4mr2cc58jwm0vasscbd4y5380wj3ahkvq121z4gs83fhavvxgz"))
  880. (modules '((guix build utils)))
  881. (snippet
  882. '(begin
  883. (for-each delete-file-recursively
  884. '("v3p/bzlib/"
  885. "v3p/geotiff/"
  886. "v3p/png/"
  887. "v3p/tiff/"
  888. "v3p/zlib/"))
  889. (substitute* "v3p/CMakeLists.txt"
  890. (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
  891. ""))
  892. #t))))
  893. (arguments
  894. `(#:configure-flags
  895. ;; Needed for itk-snap
  896. (list "-DVNL_CONFIG_LEGACY_METHODS=ON")))))
  897. (define-public insight-toolkit
  898. (package
  899. (name "insight-toolkit")
  900. (version "5.0.0")
  901. (source
  902. (origin
  903. (method url-fetch)
  904. (uri (string-append "https://github.com/InsightSoftwareConsortium/ITK/"
  905. "releases/download/v" version "/InsightToolkit-"
  906. version ".tar.xz"))
  907. (sha256
  908. (base32 "0bs63mk4q8jmx38f031jy5w5n9yy5ng9x8ijwinvjyvas8cichqi"))))
  909. (build-system cmake-build-system)
  910. (arguments
  911. `(#:tests? #f ; tests require network access and external data
  912. #:configure-flags
  913. '("-DITK_USE_GPU=ON"
  914. "-DITK_USE_SYSTEM_LIBRARIES=ON"
  915. "-DITK_USE_SYSTEM_GOOGLETEST=ON"
  916. "-DITK_BUILD_SHARED=ON"
  917. ;; This prevents "GTest::GTest" from being added to the ITK_LIBRARIES
  918. ;; variable in the installed CMake files. This is necessary as other
  919. ;; packages using insight-toolkit could not be configured otherwise.
  920. "-DGTEST_ROOT=gtest")
  921. #:phases
  922. (modify-phases %standard-phases
  923. (add-after 'unpack 'do-not-tune
  924. (lambda _
  925. (substitute* "CMake/ITKSetStandardCompilerFlags.cmake"
  926. (("-mute=native") ""))
  927. #t)))))
  928. (inputs
  929. `(("eigen" ,eigen)
  930. ("expat" ,expat)
  931. ("fftw" ,fftw)
  932. ("fftwf" ,fftwf)
  933. ("hdf5" ,hdf5)
  934. ("libjpeg" ,libjpeg-turbo)
  935. ("libpng" ,libpng)
  936. ("libtiff" ,libtiff)
  937. ("mesa" ,mesa-opencl)
  938. ("perl" ,perl)
  939. ("python" ,python)
  940. ("tbb" ,tbb)
  941. ("vxl" ,vxl-1)
  942. ("zlib" ,zlib)))
  943. (native-inputs
  944. `(("googletest" ,googletest)
  945. ("pkg-config" ,pkg-config)))
  946. (home-page "https://github.com/InsightSoftwareConsortium/ITK/")
  947. (synopsis "Scientific image processing, segmentation and registration")
  948. (description "The Insight Toolkit (ITK) is a toolkit for N-dimensional
  949. scientific image processing, segmentation, and registration. Segmentation is
  950. the process of identifying and classifying data found in a digitally sampled
  951. representation. Typically the sampled representation is an image acquired
  952. from such medical instrumentation as CT or MRI scanners. Registration is the
  953. task of aligning or developing correspondences between data. For example, in
  954. the medical environment, a CT scan may be aligned with a MRI scan in order to
  955. combine the information contained in both.")
  956. (license license:asl2.0)))
  957. (define-public insight-toolkit-4
  958. (package (inherit insight-toolkit)
  959. (version "4.13.2")
  960. (source
  961. (origin
  962. (method url-fetch)
  963. (uri (string-append "https://github.com/InsightSoftwareConsortium/ITK/"
  964. "releases/download/v" version "/InsightToolkit-"
  965. version ".tar.xz"))
  966. (sha256
  967. (base32 "19cgfpd63gqrvc3m27m394gy2d7w79g5y6lvznb5qqr49lihbgns"))))
  968. (arguments
  969. `(#:tests? #f ; tests require network access and external data
  970. #:configure-flags
  971. '("-DITKV3_COMPATIBILITY=ON" ; needed for itk-snap
  972. "-DITK_USE_GPU=ON"
  973. "-DITK_USE_SYSTEM_LIBRARIES=ON"
  974. "-DITK_USE_SYSTEM_GOOGLETEST=ON"
  975. "-DITK_USE_SYSTEM_VXL=ON")))))
  976. (define-public insight-toolkit-4.12
  977. (package (inherit insight-toolkit-4)
  978. (version "4.12.2")
  979. (source
  980. (origin
  981. (method url-fetch)
  982. (uri (string-append "mirror://sourceforge/itk/itk/4.12/"
  983. "InsightToolkit-" version ".tar.xz"))
  984. (sha256
  985. (base32 "1qw9mxbh083siljygahl4gdfv91xvfd8hfl7ghwii19f60xrvn2w"))))))
  986. (define-public itk-snap
  987. (package
  988. (name "itk-snap")
  989. (version "3.8.0")
  990. (source
  991. (origin
  992. (method git-fetch)
  993. (uri (git-reference
  994. (url "https://git.code.sf.net/p/itk-snap/src")
  995. (commit (string-append "v" version))))
  996. (file-name (git-file-name name version))
  997. (sha256
  998. (base32 "15i5ixpryfrbf3vrrb5rici8fb585f25k0v1ljds16bp1f1msr4q"))))
  999. (build-system cmake-build-system)
  1000. (arguments
  1001. `(#:configure-flags
  1002. (list "-DSNAP_VERSION_GIT_SHA1=release"
  1003. "-DSNAP_VERSION_GIT_BRANCH=release"
  1004. "-DSNAP_VERSION_GIT_TIMESTAMP=0"
  1005. "-DSNAP_PACKAGE_QT_PLUGINS=OFF"
  1006. "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
  1007. #:phases
  1008. (modify-phases %standard-phases
  1009. ;; During the installation phase all libraries provided by all
  1010. ;; dependencies will be copied to the lib directory. That's insane,
  1011. ;; so we disable this.
  1012. (add-after 'unpack 'do-not-copy-dependencies
  1013. (lambda _
  1014. (substitute* "CMakeLists.txt"
  1015. (("install_qt5_executable\
  1016. \\(\\$\\{SNAP_MAIN_INSTALL_DIR\\}/\\$\\{SNAP_EXE\\}\\)")
  1017. ""))
  1018. #t))
  1019. (add-after 'unpack 'disable-gui-tests
  1020. (lambda _
  1021. ;; The GUI tests just time out.
  1022. (substitute* "CMakeLists.txt"
  1023. ((" (Workspace|DiffSpace|ProbeIntensity|RegionCompetition\
  1024. |RandomForest|RandomForestBailOut)")
  1025. ""))
  1026. #t))
  1027. (add-after 'unpack 'make-reproducible
  1028. (lambda _
  1029. (substitute* "CMakeLists.txt"
  1030. (("TODAY\\(SNAP_VERSION_COMPILE_DATE\\)")
  1031. "SET(SNAP_VERSION_COMPILE_DATE \"(removed for reproducibility)\")"))
  1032. #t))
  1033. (add-after 'unpack 'prepare-submodules
  1034. (lambda* (#:key inputs #:allow-other-keys)
  1035. (rmdir "Submodules/c3d")
  1036. (copy-recursively (assoc-ref inputs "c3d-src")
  1037. "Submodules/c3d")
  1038. (substitute* '("Submodules/c3d/adapters/BiasFieldCorrectionN4.cxx"
  1039. "Submodules/c3d/adapters/ApplyMetric.cxx")
  1040. (("vcl_") "std::"))
  1041. (rmdir "Submodules/greedy")
  1042. (symlink (assoc-ref inputs "greedy-src")
  1043. "Submodules/greedy")
  1044. #t))
  1045. (add-after 'unpack 'fix-includes
  1046. (lambda _
  1047. (substitute* "GUI/Model/RegistrationModel.cxx"
  1048. (("<vnl_symmetric_eigensystem.h>")
  1049. "<vnl/algo/vnl_symmetric_eigensystem.h>"))
  1050. #t))
  1051. (add-before 'check 'prepare-tests
  1052. (lambda _
  1053. ;; Needed by at least one test.
  1054. (setenv "HOME" "/tmp")
  1055. #t))
  1056. (add-after 'install 'wrap-executable
  1057. (lambda* (#:key inputs outputs #:allow-other-keys)
  1058. (let ((out (assoc-ref outputs "out")))
  1059. (wrap-program (string-append out "/bin/itksnap")
  1060. `("QT_PLUGIN_PATH" ":" prefix
  1061. ,(map (lambda (label)
  1062. (string-append (assoc-ref inputs label)
  1063. "/lib/qt5/plugins"))
  1064. '("qtbase" "qtdeclarative"))))
  1065. #t))))))
  1066. (inputs
  1067. `(("curl" ,curl)
  1068. ("fftw" ,fftw)
  1069. ("fftwf" ,fftwf)
  1070. ("glu" ,glu)
  1071. ("hdf5" ,hdf5)
  1072. ("mesa" ,mesa-opencl)
  1073. ;; This package does not build with either insight-toolkit 5.0.0 and
  1074. ;; not with 4.13. It really needs to be 4.12.
  1075. ("itk" ,insight-toolkit-4.12)
  1076. ("vtk" ,vtk-6)
  1077. ("qtbase" ,qtbase-5)
  1078. ("qtdeclarative" ,qtdeclarative)
  1079. ("vxl" ,vxl-1)
  1080. ("zlib" ,zlib)))
  1081. (native-inputs
  1082. `(("googletest" ,googletest)
  1083. ("qttools" ,qttools)
  1084. ("pkg-config" ,pkg-config)
  1085. ("c3d-src"
  1086. ,(let* ((commit "f521358db26e00002c911cc47bf463b043942ad3")
  1087. (revision "1")
  1088. (version (git-version "0" revision commit)))
  1089. (origin
  1090. (method git-fetch)
  1091. (uri (git-reference
  1092. (url "https://github.com/pyushkevich/c3d")
  1093. (commit commit)))
  1094. (file-name (git-file-name "c3d" version))
  1095. (sha256
  1096. (base32
  1097. "0kyv3rxrxwr8c3sa9zv01lsnhk95b27gx1s870k3yi8qp52h7bx3")))))
  1098. ;; We are using an arbitrary commit from 2017 because the latest
  1099. ;; version breaks the build...
  1100. ("greedy-src"
  1101. ,(let* ((commit "97e340f7e8e66597599144947775e6039e79a0d3")
  1102. (revision "1")
  1103. (version (git-version "0" revision commit)))
  1104. (origin
  1105. (method git-fetch)
  1106. (uri (git-reference
  1107. (url "https://github.com/pyushkevich/greedy")
  1108. (commit commit)))
  1109. (file-name (git-file-name "greedy" version))
  1110. (sha256
  1111. (base32
  1112. "0k5bc9za4jrc8z9dj08z1rkcp5xf0gnd1d2jmi1w9ny4vxh2q2ab")))))))
  1113. (home-page "https://sourceforge.net/p/itk-snap/")
  1114. (synopsis "Medical image segmentation")
  1115. (description "ITK-SNAP is a tool for segmenting anatomical structures in
  1116. medical images. It provides an automatic active contour segmentation
  1117. pipeline, along with supporting a manual segmentation toolbox. ITK-SNAP has a
  1118. full-featured UI aimed at clinical researchers.")
  1119. ;; This includes the submodules greedy and c3d.
  1120. (license license:gpl3+)))
  1121. (define-public metapixel
  1122. ;; Follow stable branch.
  1123. (let ((commit "98ee9daa093b6c334941242e63f90b1c2876eb4f"))
  1124. (package
  1125. (name "metapixel")
  1126. (version (git-version "1.0.2" "1" commit))
  1127. (source
  1128. (origin
  1129. (method git-fetch)
  1130. (uri (git-reference
  1131. (url "https://github.com/schani/metapixel")
  1132. (commit commit)
  1133. ;; TODO: Package rwimg and lispreader?
  1134. (recursive? #t)))
  1135. (file-name (git-file-name name version))
  1136. (sha256
  1137. (base32 "0r7n3a6bvcxkbpda4mwmrpicii09iql5z69nkjqygkwxw7ny3309"))))
  1138. (build-system gnu-build-system)
  1139. (inputs
  1140. `(("giflib" ,giflib)
  1141. ("libjpeg" ,libjpeg-turbo)
  1142. ("libpng" ,libpng)
  1143. ("perl" ,perl)))
  1144. (native-inputs
  1145. `(("pkg-config" ,pkg-config)
  1146. ("docbook-xml" ,docbook-xml)
  1147. ("docbook-xsl" ,docbook-xsl)
  1148. ("xsltproc" ,libxslt)))
  1149. (arguments
  1150. `(#:tests? #f ; No tests.
  1151. #:make-flags (list
  1152. (string-append "PREFIX=" (assoc-ref %outputs "out"))
  1153. (string-append "MANPAGE_XSL="
  1154. (assoc-ref %build-inputs "docbook-xsl")
  1155. "/xml/xsl/docbook-xsl-*/manpages/docbook.xsl"))
  1156. #:phases
  1157. (modify-phases %standard-phases
  1158. (delete 'configure)
  1159. (add-before 'install 'make-local-docbook-xml
  1160. (lambda* (#:key inputs #:allow-other-keys)
  1161. (substitute* "metapixel.xml"
  1162. (("http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd")
  1163. (string-append (assoc-ref inputs "docbook-xml")
  1164. "/xml/dtd/docbook/docbookx.dtd")))
  1165. #t))
  1166. (add-before 'install 'fix-directory-creation
  1167. (lambda* (#:key outputs #:allow-other-keys)
  1168. (mkdir-p (string-append (assoc-ref outputs "out") "/share/man/man1"))
  1169. #t)))))
  1170. (home-page "https://www.complang.tuwien.ac.at/schani/metapixel/")
  1171. (synopsis "Photomosaics generator")
  1172. (description "Metapixel is a program for generating photomosaics. It can
  1173. generate classical photomosaics, in which the source image is viewed as a
  1174. matrix of equally sized rectangles for each of which a matching image is
  1175. substituted, as well as collage-style photomosaics, in which rectangular parts
  1176. of the source image at arbitrary positions (i.e. not aligned to a matrix) are
  1177. substituted by matching images.")
  1178. (license license:gpl2))))
  1179. (define-public scantailor-advanced
  1180. (let ((commit "3d1e74e6ace413733511086934a66f4e3f7a6027"))
  1181. (package
  1182. (name "scantailor-advanced")
  1183. (version (string-append "1.0.16-" (string-take commit 7)))
  1184. (source
  1185. (origin
  1186. (method git-fetch)
  1187. (uri (git-reference
  1188. (url "https://github.com/4lex4/scantailor-advanced")
  1189. (commit commit)))
  1190. (file-name (git-file-name name version))
  1191. (sha256
  1192. (base32
  1193. "0kixwjb2x457dq7927hkh34c803p7yh1pmn6n61rk9shqrcg492h"))))
  1194. (build-system qt-build-system)
  1195. (native-inputs
  1196. `(("qttools" ,qttools)))
  1197. (inputs
  1198. `(("boost" ,boost)
  1199. ("libjpeg" ,libjpeg-turbo)
  1200. ("libpng" ,libpng)
  1201. ("libtiff" ,libtiff)
  1202. ("qtbase" ,qtbase-5)
  1203. ("qtsvg" ,qtsvg)
  1204. ("zlib" ,zlib)))
  1205. (arguments
  1206. `(#:phases
  1207. (modify-phases %standard-phases
  1208. ;; Some tests require a display and fail with offscreen mode.
  1209. (add-after 'unpack 'disable-failing-tests
  1210. (lambda _
  1211. (setenv "ARGS" "--exclude-regex \"imageproc_.*\"")
  1212. #t)))))
  1213. (home-page "https://github.com/4lex4/scantailor-advanced")
  1214. (synopsis "Clean up scanned pages")
  1215. (description "Scan Tailor is an interactive post-processing tool for
  1216. scanned pages. It performs operations such as page splitting, deskewing,
  1217. adding/removing borders, and others. You give it raw scans, and you get pages
  1218. ready to be printed or assembled into a PDF or DJVU file. Scanning, optical
  1219. character recognition, and assembling multi-page documents are out of scope of
  1220. this project.
  1221. Scan Tailer Advanced is a fork of Scan Tailer that merges Scan Tailor Featured
  1222. and Scan Tailor Enhanced versions as well as including many more bug fixes.")
  1223. (license license:gpl3+))))
  1224. (define-public stiff
  1225. (package
  1226. (name "stiff")
  1227. (version "2.4.0")
  1228. (source
  1229. (origin
  1230. (method url-fetch)
  1231. (uri (string-append "https://www.astromatic.net/download/stiff/stiff-"
  1232. version ".tar.gz"))
  1233. (sha256
  1234. (base32 "14m92dskzw7bwsr64ha4p0mj3ndv13gwcbfic3qxrs3zq5353s7l"))))
  1235. (build-system gnu-build-system)
  1236. (inputs
  1237. `(("libtiff" ,libtiff)
  1238. ("zlib" ,zlib)
  1239. ("libjpeg-turbo" ,libjpeg-turbo)))
  1240. (home-page "https://www.astromatic.net/software/stiff")
  1241. (synopsis "Convert scientific FITS images to TIFF format")
  1242. (description
  1243. "STIFF is a program that converts scientific @acronym{FITS, Flexible Image
  1244. Transport System} images to the more popular TIFF format for illustration
  1245. purposes.")
  1246. (license license:gpl3+)))
  1247. (define-public python-imgviz
  1248. (package
  1249. (name "python-imgviz")
  1250. (version "1.2.6")
  1251. (source
  1252. (origin
  1253. ;; PyPi tarball lacks tests.
  1254. (method git-fetch)
  1255. (uri (git-reference
  1256. (url "https://github.com/wkentaro/imgviz.git")
  1257. (commit (string-append "v" version))))
  1258. (file-name (git-file-name name version))
  1259. (sha256
  1260. (base32 "1bm0wdv5p26i8nl4kx3145cz553v401sgbpgc96sddzjfmfiydcw"))))
  1261. (build-system python-build-system)
  1262. (arguments
  1263. `(#:phases
  1264. (modify-phases %standard-phases
  1265. (replace 'check
  1266. (lambda* (#:key inputs outputs tests? #:allow-other-keys)
  1267. (when tests?
  1268. (add-installed-pythonpath inputs outputs)
  1269. (invoke "pytest" "-v" "tests"))
  1270. #t)))))
  1271. (propagated-inputs
  1272. `(("python-matplotlib" ,python-matplotlib)
  1273. ("python-numpy" ,python-numpy)
  1274. ("python-pillow" ,python-pillow)
  1275. ("python-pyyaml" ,python-pyyaml)))
  1276. (native-inputs `(("python-pytest" ,python-pytest)))
  1277. (home-page "http://github.com/wkentaro/imgviz")
  1278. (synopsis "Image Visualization Tools")
  1279. (description "Python library for object detection, semantic and instance
  1280. segmentation.")
  1281. (license license:expat)))
  1282. (define-public labelme
  1283. (package
  1284. (name "labelme")
  1285. (version "4.5.9")
  1286. (source
  1287. (origin
  1288. ;; PyPi tarball lacks tests.
  1289. (method git-fetch)
  1290. (uri (git-reference
  1291. (url "https://github.com/wkentaro/labelme.git")
  1292. (commit (string-append "v" version))))
  1293. (file-name (git-file-name name version))
  1294. (sha256
  1295. (base32 "12wn291516kdv0wqngz4l04j95g3rwc6cvkcb0gw8rrv4wgc7c66"))))
  1296. (build-system python-build-system)
  1297. (arguments
  1298. `(#:phases
  1299. (modify-phases %standard-phases
  1300. (add-before 'check 'start-xserver
  1301. (lambda* (#:key inputs #:allow-other-keys)
  1302. (let ((xorg-server (assoc-ref inputs "xorg-server")))
  1303. ;; Options taken from CI workflow.
  1304. (system (string-append xorg-server "/bin/Xvfb :99 -screen 0 "
  1305. "1920x1200x24 -ac +extension GLX +render "
  1306. "-noreset &"))
  1307. (setenv "DISPLAY" ":99.0"))))
  1308. (replace 'check
  1309. (lambda* (#:key inputs outputs tests? #:allow-other-keys)
  1310. (when tests?
  1311. (add-installed-pythonpath inputs outputs)
  1312. ;; Fails when invoking help2man for unknown reason.
  1313. (delete-file "tests/docs_tests/man_tests/test_labelme_1.py")
  1314. ;; One test hangs.
  1315. (delete-file "tests/labelme_tests/widgets_tests/test_label_dialog.py")
  1316. ;; Calls incompatible function signatures.
  1317. (delete-file "tests/labelme_tests/widgets_tests/test_label_list_widget.py")
  1318. (setenv "MPLBACKEND" "agg")
  1319. (invoke "pytest" "-v" "tests" "-m" "not gpu")))))))
  1320. (propagated-inputs
  1321. `(("python-imgviz" ,python-imgviz)
  1322. ("python-matplotlib" ,python-matplotlib)
  1323. ("python-numpy" ,python-numpy)
  1324. ("python-pillow" ,python-pillow)
  1325. ("python-pyyaml" ,python-pyyaml)
  1326. ("python-qtpy" ,python-qtpy)
  1327. ("python-termcolor" ,python-termcolor)))
  1328. (native-inputs
  1329. `(("python-pytest" ,python-pytest)
  1330. ("python-pytest-qt" ,python-pytest-qt)
  1331. ("xorg-server" ,xorg-server-for-tests)))
  1332. (home-page "https://github.com/wkentaro/labelme")
  1333. (synopsis
  1334. "Image Polygonal Annotation")
  1335. (description
  1336. "Image and video labeling tool supporting different shapes like
  1337. polygons, rectangles, circles, lines, points and VOC/COCO export.")
  1338. (license license:gpl3+)))