projects/guix·blob next-master · refs

2187 lines · 87.8 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2017 John Darrington <[email protected]>
3;;; Copyright © 2017, 2019, 2022, 2024 Ricardo Wurmus <[email protected]>
4;;; Copyright © 2014, 2021-2023 Ludovic Courtès <[email protected]>
5;;; Copyright © 2014 Mark H Weaver <[email protected]>
6;;; Copyright © 2016 Eric Bavier <[email protected]>
7;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <[email protected]>
8;;; Copyright © 2018 Björn Höfling <[email protected]>
9;;; Copyright © 2018 Lprndn <[email protected]>
10;;; Copyright © 2019, 2021, 2023 Efraim Flashner <[email protected]>
11;;; Copyright © 2020 Vincent Legoll <[email protected]>
12;;; Copyright © 2020, 2021, 2024, 2025 Vinicius Monego <[email protected]>
13;;; Copyright © 2020 Pierre Neidhardt <[email protected]>
14;;; Copyright © 2020 Brendan Tildesley <[email protected]>
15;;; Copyright © 2021 Oleh Malyi <[email protected]>
16;;; Copyright © 2021, 2022, 2024 Felix Gruber <[email protected]>
17;;; Copyright © 2021 Andy Tai <[email protected]>
18;;; Copyright © 2021 Ekaitz Zarraga <[email protected]>
19;;; Copyright © 2021 Paul Garlick <[email protected]>
20;;; Copyright © 2021 Guillaume Le Vaillant <[email protected]>
21;;; Copyright © 2021 Ivan Gankevich <[email protected]>
22;;; Copyright © 2022, 2025 Maxim Cournoyer <[email protected]>
23;;; Copyright © 2022 Tomasz Jeneralczyk <[email protected]>
24;;; Copyright © 2022 Paul A. Patience <[email protected]>
25;;; Copyright © 2023 Cairn <[email protected]>
26;;; Copyright © 2024 Nicolas Graves <[email protected]>
27;;; Copyright © 2025 Jake Forster <[email protected]>
28;;; Copyright © 2025 Anderson Torres <[email protected]>
29;;; Copyright © 2025 Andreas Enge <[email protected]>
30;;; Copyright © 2025 dan <[email protected]>
31;;;
32;;; This file is part of GNU Guix.
33;;;
34;;; GNU Guix is free software; you can redistribute it and/or modify it
35;;; under the terms of the GNU General Public License as published by
36;;; the Free Software Foundation; either version 3 of the License, or (at
37;;; your option) any later version.
38;;;
39;;; GNU Guix is distributed in the hope that it will be useful, but
40;;; WITHOUT ANY WARRANTY; without even the implied warranty of
41;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42;;; GNU General Public License for more details.
43;;;
44;;; You should have received a copy of the GNU General Public License
45;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
46
47(define-module (gnu packages image-processing)
48 #:use-module ((guix licenses) #:prefix license:)
49 #:use-module (guix packages)
50 #:use-module (guix gexp)
51 #:use-module (guix utils)
52 #:use-module (guix download)
53 #:use-module (guix git-download)
54 #:use-module (guix build-system copy)
55 #:use-module (guix build-system qt)
56 #:use-module (guix build-system cmake)
57 #:use-module (guix build-system gnu)
58 #:use-module (guix build-system meson)
59 #:use-module (guix build-system python)
60 #:use-module (guix build-system pyproject)
61 #:use-module (gnu packages)
62 #:use-module (gnu packages algebra)
63 #:use-module (gnu packages base)
64 #:use-module (gnu packages bash)
65 #:use-module (gnu packages bison)
66 #:use-module (gnu packages boost)
67 #:use-module (gnu packages check)
68 #:use-module (gnu packages compression)
69 #:use-module (gnu packages cpp)
70 #:use-module (gnu packages curl)
71 #:use-module (gnu packages docbook)
72 #:use-module (gnu packages documentation)
73 #:use-module (gnu packages engineering)
74 #:use-module (gnu packages flex)
75 #:use-module (gnu packages fontutils)
76 #:use-module (gnu packages game-development)
77 #:use-module (gnu packages gcc)
78 #:use-module (gnu packages gd)
79 #:use-module (gnu packages geo)
80 #:use-module (gnu packages ghostscript)
81 #:use-module (gnu packages gimp)
82 #:use-module (gnu packages gl)
83 #:use-module (gnu packages glib)
84 #:use-module (gnu packages gnome)
85 #:use-module (gnu packages graphics)
86 #:use-module (gnu packages graphviz)
87 #:use-module (gnu packages gstreamer)
88 #:use-module (gnu packages gtk)
89 #:use-module (gnu packages icu4c)
90 #:use-module (gnu packages image)
91 #:use-module (gnu packages imagemagick)
92 #:use-module (gnu packages linux)
93 #:use-module (gnu packages lua)
94 #:use-module (gnu packages maths)
95 #:use-module (gnu packages mpi)
96 #:use-module (gnu packages nss)
97 #:use-module (gnu packages opencl)
98 #:use-module (gnu packages pdf)
99 #:use-module (gnu packages perl)
100 #:use-module (gnu packages photo)
101 #:use-module (gnu packages pkg-config)
102 #:use-module (gnu packages pretty-print)
103 #:use-module (gnu packages protobuf)
104 #:use-module (gnu packages python)
105 #:use-module (gnu packages python-build)
106 #:use-module (gnu packages python-check)
107 #:use-module (gnu packages python-science)
108 #:use-module (gnu packages python-xyz)
109 #:use-module (gnu packages qt)
110 #:use-module (gnu packages sdl)
111 #:use-module (gnu packages serialization)
112 #:use-module (gnu packages sphinx)
113 #:use-module (gnu packages sqlite)
114 #:use-module (gnu packages ssh)
115 #:use-module (gnu packages statistics)
116 #:use-module (gnu packages swig)
117 #:use-module (gnu packages tbb)
118 #:use-module (gnu packages textutils)
119 #:use-module (gnu packages tls)
120 #:use-module (gnu packages version-control)
121 #:use-module (gnu packages video)
122 #:use-module (gnu packages xiph)
123 #:use-module (gnu packages xml)
124 #:use-module (gnu packages xorg)
125 #:use-module (ice-9 match)
126 #:use-module (srfi srfi-1))
127
128(define-public bart
129 (package
130 (name "bart")
131 (version "0.9.00")
132 (source
133 (origin
134 (method git-fetch)
135 (uri (git-reference
136 (url "https://github.com/mrirecon/bart")
137 (commit (string-append "v" version))))
138 (file-name (git-file-name name version))
139 (sha256
140 (base32 "0mj6jmw31rsnvqmpfqahhj4cy9iv5xgrhzmcsrikdz5dgd45lmjz"))))
141 (build-system gnu-build-system)
142 (arguments
143 (list
144 #:test-target "utest"
145 #:make-flags #~(list
146 (string-append "PREFIX=" #$output)
147 "PARALLEL=1"
148 "PARALLEL_NJOBS=1"
149 "OPENBLAS=1"
150 "SCALAPACK=1"
151 (string-append "BLAS_BASE=" #$(this-package-input "openblas"))
152 (string-append "CC=" #$(cc-for-target))
153 (string-append "FFTW_BASE=" #$(this-package-input "fftw")))
154 #:parallel-build? #false ;leads to non-deterministic output
155 #:phases
156 #~(modify-phases %standard-phases
157 (delete 'configure)
158 (add-after 'unpack 'patch-/bin/bash
159 (lambda _
160 (substitute* "tests/pics.mk"
161 (("/bin/bash") (which "bash"))))))))
162 (inputs
163 (list fftw
164 fftwf
165 libpng
166 openblas
167 python
168 scalapack))
169 (native-inputs
170 (list doxygen
171 util-linux)) ;for flock
172 (home-page "https://mrirecon.github.io/bart/")
173 (synopsis "Toolbox for computational magnetic resonance imaging")
174 (description "The Berkeley Advanced Reconstruction Toolbox (BART) is an
175image-reconstruction framework for Computational Magnetic Resonance Imaging.
176The tools in this software implement various reconstruction algorithms for
177Magnetic Resonance Imaging.")
178 (license license:bsd-3)))
179
180(define-public cimg
181 (package
182 (name "cimg")
183 (version "3.6.5")
184 (source
185 (origin
186 (method git-fetch)
187 (uri (git-reference
188 (url "https://github.com/GreycLab/CImg")
189 (commit (string-append "v." version))))
190 (file-name (git-file-name name version))
191 (sha256
192 (base32 "1zdw1mbwl2g0ka1gasq9l706aral0l2mfsc0vmvq2szn90l2i455"))))
193 (build-system copy-build-system)
194 (arguments
195 (list
196 #:phases
197 #~(modify-phases %standard-phases
198 (add-before 'install 'check
199 (lambda* (#:key tests? #:allow-other-keys)
200 (when tests?
201 (with-directory-excursion "examples"
202 ;; This is from upstream CI but parallelized.
203 (invoke "make" "-j"
204 (number->string (parallel-job-count)) "mlinux")
205 (invoke "./image2ascii")
206 (invoke "./generate_loop_macros")
207 ;; Build an example that requires an external library.
208 ;; Running it requires a display.
209 (invoke "make" "use_jpeg_buffer"
210 (string-append "CONF_CFLAGS="
211 (string-join '("-Dcimg_display=0"
212 "-O3"
213 "-mtune=generic"
214 "-Dcimg_use_jpeg")
215 " "))
216 "CONF_LIBS=-ljpeg"))))))
217 #:install-plan
218 #~'(("CImg.h" "include/")
219 ("plugins" "include/CImg/plugins"))))
220 (native-inputs (list libjpeg-turbo)) ;for 'check
221 (home-page "https://cimg.eu")
222 (synopsis "Small C++ image processing library")
223 (description
224 "The @acronym{CImg, Cool Image} Library is a small C++ toolkit for
225image processing. It is made of a single header file @code{CImg.h}
226that can be compiled using a minimal set of standard C++ and system
227libraries. It includes a plugin mechanism to extend its functionality
228with external tools and libraries.")
229 ;; Dual-licensed, either license applies.
230 (license (list license:cecill-c license:cecill))))
231
232(define-public dcmtk
233 (package
234 (name "dcmtk")
235 (version "3.6.9")
236 (source
237 (origin
238 (method git-fetch)
239 (uri (git-reference
240 (url "https://git.dcmtk.org/dcmtk")
241 (commit (string-append "DCMTK-" version))))
242 (sha256
243 (base32 "0x99gg1kahkzbayfciyhkw5xdcm8cs4r8cmv15kniw9pldi3zllr"))
244 (file-name (git-file-name name version))))
245 (build-system cmake-build-system)
246 (arguments
247 ;; By default, only static archives are built.
248 (list #:configure-flags #~(list "-DBUILD_SHARED_LIBS=ON")))
249 (inputs
250 (list icu4c
251 libjpeg-turbo
252 libpng
253 libtiff
254 libxml2
255 openssl
256 zlib))
257 (native-inputs
258 (list doxygen)) ; for HTML documentation
259 (home-page "https://dcmtk.org")
260 (synopsis "Libraries and programs implementing parts of the DICOM standard")
261 (description "DCMTK is a collection of libraries and applications
262implementing large parts the DICOM standard. It includes software for
263examining, constructing and converting DICOM image files, handling offline
264media, sending and receiving images over a network connection, as well as
265demonstrative image storage and worklist servers.")
266 (license (license:fsf-free
267 "file://COPYRIGHT"
268 "A union of the Apache 2.0 licence and various non-copyleft
269licences similar to the Modified BSD licence."))))
270
271(define-public opencolorio
272 (package
273 (name "opencolorio")
274 (version "2.4.2")
275 (source
276 (origin
277 (method git-fetch)
278 (uri (git-reference
279 (url "https://github.com/AcademySoftwareFoundation/OpenColorIO")
280 (commit (string-append "v" version))))
281 (sha256
282 (base32 "1h5n1adm7hlblq4z9qdbnh5jy3f6aimlk96cn1k4ah3f8vqx7zpq"))
283 (file-name (git-file-name name version))))
284 (build-system cmake-build-system)
285 (arguments
286 ;; XXX: GPU tests are failing.
287 (list #:configure-flags #~(list "-DOCIO_BUILD_GPU_TESTS=false")
288 #:phases
289 #~(modify-phases %standard-phases
290 (add-after 'unpack 'disable-test
291 ;; The approach is somewhat desperate and removes not only
292 ;; line 1436 of the failing
293 ;; FileFormatCTF/difficult_xml_unknown_elements test,
294 ;; but also the identical line 1524 of the succeeding
295 ;; FileFormatCTF/unknown_elements test.
296 (lambda _
297 (substitute* "tests/cpu/fileformats/FileFormatCTF_tests.cpp"
298 (("OCIO_CHECK_NE.*ErrorOutputs.*")
299 ""))))
300 (add-after 'unpack 'fix-broken-test
301 (lambda _
302 ;; Replace the invalid multi-line list. It is unclear why
303 ;; this is now failing after only build system updates.
304 ;; (see https://github.com/AcademySoftwareFoundation/OpenColorIO/blob/v2.4.2/tests/cpu/Config_tests.cpp#L6227)
305 (substitute* "tests/cpu/Config_tests.cpp"
306 (("cs1\\\\t\\\\n \\\\n, \\\\ncs2")
307 "cs1, cs2"))))
308 ;; Disable a failing test case on arm and riscv due to FMA
309 ;; instructions being generated.
310 ;; (see https://github.com/AcademySoftwareFoundation/OpenColorIO/issues/1784)
311 #$@(if (or (target-arm?)
312 (target-riscv64?))
313 #~((add-after 'unpack 'disable-failing-test
314 (lambda _
315 (substitute* "tests/cpu/ops/gamma/GammaOpCPU_tests.cpp"
316 ((".*apply_moncurve_mirror_style_fwd.*" all)
317 (string-append "#if 0\n" all))
318 ((".*apply_moncurve_mirror_style_rev.*" all)
319 (string-append "#endif\n" all))))))
320 #~()))))
321 (native-inputs
322 ;; XXX: OCIO has unit tests for OpenShadingLanguage, but they fail.
323 ;; They also require OIIO, but OCIO is an optional dependency to it.
324 (list pybind11 python-wrapper))
325 (inputs
326 (list expat
327 freeglut
328 glew
329 imath
330 lcms
331 libglvnd
332 ;; [email protected] fails to build with [email protected]
333 minizip-ng-4.0.9
334 openexr
335 pystring
336 yaml-cpp
337 zlib))
338 (home-page "https://opencolorio.org")
339 (synopsis "Color management for visual effects and animation")
340 (description
341 "OpenColorIO, or OCIO, is a complete color management solution geared
342towards motion picture production, with an emphasis on visual effects and
343computer animation. It provides a straightforward and consistent user
344experience across all supporting applications while allowing for sophisticated
345back-end configuration options suitable for high-end production usage.
346
347OCIO is compatible with the @acronym{ACES, Academy Color Encoding
348Specification} and is @acronym{LUT, look-up table}-format agnostic, supporting
349many popular formats.")
350 (license license:bsd-3)))
351
352(define-public vtk
353 (package
354 (name "vtk")
355 (version "9.3.1")
356 (source (origin
357 (method url-fetch)
358 (uri (string-append "https://vtk.org/files/release/"
359 (version-major+minor version)
360 "/VTK-" version ".tar.gz"))
361 (sha256
362 (base32
363 "1f6ac40db7wkb3bfh31d71qc5gy44cw29r6v4cyxrlm09q4fqm43"))
364 (modules '((guix build utils)))
365 (snippet
366 '(begin
367 (for-each
368 (lambda (dir)
369 (delete-file-recursively
370 (string-append "ThirdParty/" dir "/vtk" dir)))
371 ;; pugixml depended upon unconditionally
372 '("doubleconversion" "eigen" "expat" "freetype" "gl2ps"
373 "glew" "hdf5" "jpeg" "jsoncpp" "libharu" "libproj"
374 "libxml2" "lz4" "netcdf" "ogg" "png" "sqlite" "theora"
375 "tiff" "zlib"))
376 (substitute* "IO/ExportPDF/vtkPDFContextDevice2D.cxx"
377 (("\\bHPDF_UINT16 (noPen|dash|dot|denseDot|dashDot|dashDotDot)\\b"
378 _ var)
379 (string-append "HPDF_REAL " var)))))))
380 (properties `((release-monitoring-url . "https://vtk.org/download/")))
381 (build-system cmake-build-system)
382 (arguments
383 (list #:build-type "Release" ;Build without '-g' to save space.
384 #:configure-flags
385 #~'("-DVTK_USE_EXTERNAL=OFF" ;default
386 "-DVTK_MODULE_USE_EXTERNAL_VTK_doubleconversion=ON"
387 "-DVTK_MODULE_USE_EXTERNAL_VTK_eigen=ON"
388 "-DVTK_MODULE_USE_EXTERNAL_VTK_expat=ON"
389 "-DVTK_MODULE_USE_EXTERNAL_VTK_freetype=ON"
390 "-DVTK_MODULE_USE_EXTERNAL_VTK_gl2ps=ON"
391 "-DVTK_MODULE_USE_EXTERNAL_VTK_glew=ON"
392 "-DVTK_MODULE_USE_EXTERNAL_VTK_hdf5=ON"
393 "-DVTK_MODULE_USE_EXTERNAL_VTK_jpeg=ON"
394 "-DVTK_MODULE_USE_EXTERNAL_VTK_jsoncpp=ON"
395 "-DVTK_MODULE_USE_EXTERNAL_VTK_libharu=ON"
396 "-DVTK_MODULE_USE_EXTERNAL_VTK_libproj=ON"
397 "-DVTK_MODULE_USE_EXTERNAL_VTK_libxml2=ON"
398 "-DVTK_MODULE_USE_EXTERNAL_VTK_lz4=ON"
399 "-DVTK_MODULE_USE_EXTERNAL_VTK_netcdf=ON"
400 "-DVTK_MODULE_USE_EXTERNAL_VTK_ogg=ON"
401 "-DVTK_MODULE_USE_EXTERNAL_VTK_png=ON"
402 ;;"-DVTK_MODULE_USE_EXTERNAL_VTK_pugixml=ON" ;breaks IO/CityGML
403 "-DVTK_MODULE_USE_EXTERNAL_VTK_sqlite=ON"
404 "-DVTK_MODULE_USE_EXTERNAL_VTK_theora=ON"
405 "-DVTK_MODULE_USE_EXTERNAL_VTK_tiff=ON"
406 "-DVTK_MODULE_USE_EXTERNAL_VTK_zlib=ON"
407 "-DVTK_MODULE_ENABLE_VTK_RenderingExternal=YES" ;for F3D
408 "-DVTK_MODULE_ENABLE_VTK_GUISupportQt=YES" ;for itk-snap
409 "-DVTK_WRAP_PYTHON=ON"
410 "-DVTK_PYTHON_VERSION:STRING=3"
411
412 "-DVTK_SMP_ENABLE_OPENNMP=ON"
413 "-DVTK_SMP_ENABLE_TBB=ON"
414 "-DVTK_USE_MPI=ON"
415 #$@(if (target-riscv64?)
416 '("-DCMAKE_SHARED_LINKER_FLAGS=-latomic"
417 "-DCMAKE_EXE_LINKER_FLAGS=-latomic")
418 '()))
419
420 #:phases
421 #~(modify-phases %standard-phases
422 (add-after 'unpack 'clear-reference-to-compiler
423 (lambda _
424 (define (choose . files)
425 (let loop ((files files))
426 (if (null? files)
427 #f
428 (if (file-exists? (car files))
429 (car files)
430 (loop (cdr files))))))
431
432 ;; Do not retain a reference to GCC.
433 (substitute* (choose
434 "Common/Core/vtkBuild.h.in" ;dummy >=v9.3
435 "Common/Core/vtkConfigureDeprecated.h.in" ;v9.x
436 "Common/Core/vtkConfigure.h.in") ;v7.x
437 (("@CMAKE_CXX_COMPILER@") "c++")))))
438
439 #:tests? #f)) ;XXX: test data not included
440 (inputs
441 (list double-conversion
442 eigen
443 expat
444 freetype
445 gl2ps
446 glew
447 glu
448 hdf5
449 libharu
450 libjpeg-turbo
451 jsoncpp
452 libtheora
453 libx11
454 libxml2
455 libxt
456 lz4
457 mesa
458 netcdf
459 libpng
460 libtiff
461 openmpi
462 proj
463 python
464 ;("pugixml" ,pugixml)
465 sqlite
466 xorgproto
467 qtbase
468 zlib))
469 (propagated-inputs
470 ;; VTK's 'VTK-vtk-module-find-packages.cmake' calls
471 ;; 'find_package(THEORA)', which in turns looks for libogg. Likewise for
472 ;; TBB.
473 (list libogg
474 tbb))
475 (home-page "https://vtk.org/")
476 (synopsis "Libraries for 3D computer graphics")
477 (description
478 "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
479image processing and visualization. It supports a wide variety of
480visualization algorithms including: scalar, vector, tensor, texture, and
481volumetric methods; and advanced modeling techniques such as: implicit
482modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay
483triangulation. VTK has an extensive information visualization framework, has
484a suite of 3D interaction widgets, supports parallel processing, and
485integrates with various databases on GUI toolkits such as Qt and Tk.")
486 (license license:bsd-3)))
487
488(define-public vktdiff
489 (package
490 (name "vtkdiff")
491 (version "1.0.0")
492 (source
493 (origin
494 (method git-fetch)
495 (uri (git-reference
496 (url "https://github.com/ufz/vtkdiff")
497 (commit version)))
498 (file-name (git-file-name name version))
499 (sha256
500 (base32 "15nwzfhgyjfvd083kw1s19xkxcds9h31hx9cr339x3bkllbj609j"))))
501 (build-system cmake-build-system)
502 (inputs (list tclap vtk))
503 (arguments
504 (list
505 #:tests? #f ;There are no tests.
506 #:configure-flags #~(list "-DGUIX_BUILD=ON")))
507 (home-page "https://github.com/ufz/vtkdiff")
508 (synopsis "Numerical difference of data arrays in vtk files")
509 (description
510 "The vtkdiff tool shall provide means of numerical comparison of
511different data arrays similar to those available in the numdiff software.")
512 (license license:bsd-3)))
513
514(define-public opencv
515 (package
516 (name "opencv")
517 (version "4.12.0")
518 (source (origin
519 (method git-fetch)
520 (uri (git-reference
521 (url "https://github.com/opencv/opencv")
522 (commit version)))
523 (file-name (git-file-name name version))
524 (modules '((guix build utils)))
525 (snippet
526 '(begin
527 ;; Remove external libraries. Almost all of them are
528 ;; available in Guix.
529 (with-directory-excursion "3rdparty"
530 (for-each delete-file-recursively
531 '("cpufeatures"
532 "flatbuffers"
533 "ffmpeg"
534 "include"
535 "ippicv"
536 "ittnotify"
537 "libjasper"
538 "libjpeg"
539 "libjpeg-turbo"
540 "libpng"
541 "libtiff"
542 "libwebp"
543 "openexr"
544 "openjpeg"
545 "protobuf"
546 ;;"quirc"
547 "tbb"
548 "zlib")))
549
550 ;; Delete any bundled .jar files.
551 (for-each delete-file (find-files "." "\\.jar$"))))
552 (sha256
553 (base32
554 "1n5qif1ispmdby1cmwf9f8isdx07phyhb19jsmgrw5bk3k23dcyy"))))
555 (build-system cmake-build-system)
556 (arguments
557 `(#:parallel-tests? #f
558 #:configure-flags
559 (list "-DWITH_ADE=OFF" ;we don't have a package for ade yet
560 "-DWITH_IPP=OFF"
561 "-DWITH_ITT=OFF"
562 "-DWITH_CAROTENE=OFF" ; only visible on arm/aarch64
563 "-DENABLE_PRECOMPILED_HEADERS=OFF"
564 "-DOPENCV_GENERATE_PKGCONFIG=ON"
565
566 ;; CPU-Features:
567 ;; See cmake/OpenCVCompilerOptimizations.cmake
568 ;; (CPU_ALL_OPTIMIZATIONS) for a list of all optimizations
569 ;; BASELINE is the minimum optimization all CPUs must support
570 ;;
571 ;; DISPATCH is the list of optional dispatches.
572 "-DCPU_BASELINE=SSE2"
573
574 ;; Build Python bindings.
575 "-DBUILD_opencv_python3=ON"
576
577 ,@(match (%current-system)
578 ("x86_64-linux"
579 '("-DCPU_DISPATCH=NEON;VFPV3;FP16;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX"
580 "-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2"))
581 ("armhf-linux"
582 '("-DCPU_BASELINE_DISABLE=NEON")) ; causes build failures
583 ("aarch64-linux"
584 '("-DCPU_BASELINE=NEON"
585 "-DCPU_DISPATCH=NEON;VFPV3;FP16"))
586 (_ '()))
587
588 "-DBUILD_PERF_TESTS=OFF"
589 "-DBUILD_TESTS=ON"
590
591 (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
592 "/opencv-contrib/modules")
593
594 ;;Define test data:
595 (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
596 "/opencv-extra/testdata")
597
598 ;; Is ON by default and would try to rebuild 3rd-party protobuf,
599 ;; which we had removed, which would lead to an error:
600 "-DBUILD_PROTOBUF=OFF"
601
602 ;; OpenCV tries to use flatbuffers in 3rdparty which we removed
603 ;; so for now we don't buildfor flatbuffer support
604 ;; TODO: make OpenCV use system flatbuffers which involves
605 ;; modifying CMake files
606 "-DWITH_FLATBUFFERS=OFF"
607
608 ;; Rebuild protobuf files, because we have a slightly different
609 ;; version than the included one. If we would not update, we
610 ;; would get a compile error later:
611 "-DPROTOBUF_UPDATE_FILES=ON"
612
613 ;; For xfeatures2d.
614 "-DOPENCV_SKIP_FEATURES2D_DOWNLOADING=ON")
615 #:phases
616 (modify-phases %standard-phases
617 (add-after 'unpack 'disable-broken-tests
618 (lambda _
619 ;; This test fails with "unknown file: Failure"
620 ;; But I couldn't figure out which file was missing:
621 (substitute* "../opencv-contrib/modules/face/test/test_face_align.cpp"
622 (("\\bcan_detect_landmarks\\b" all)
623 (string-append "DISABLED_" all)))
624
625 ;; This all fails with a comparison between the expected 396 and
626 ;; the actual 440 in file size.
627 (substitute* "modules/imgcodecs/test/test_exr.impl.hpp"
628 (("\\breadWrite_32FC1\\b" all)
629 (string-append "DISABLED_" all)))
630
631 ;; These fail with protobuf parse errors that come from
632 ;; opencv-extra/alldata.
633 (substitute* "modules/dnn/test/test_layers.cpp"
634 (("\\b(Accum|DataAugmentation|Resample|Correlation|Interp)\\b" all)
635 (string-append "DISABLED_" all)))
636
637 ;; This test fails on x86-64, loosen the bounds.
638 ;; Expected: (max) < (0.1), actual: 0.2 vs 0.1
639 (substitute* "modules/photo/test/test_hdr.cpp"
640 (("0\\.1\\)") "0.222)"))
641
642 ,@(if (target-aarch64?)
643 `(;; This test fails on aarch64, loosen the bounds.
644 ;; Expected: (max) < (0.131), actual: 0.207148 vs 0.131
645 (substitute* "modules/photo/test/test_hdr.cpp"
646 (("0\\.131") "0.222"))
647 ;; These tests hang forever on aarch64.
648 (delete-file-recursively "modules/videoio/test/")
649 ;; This test fails on aarch64 due to floating-point precision
650 ;; differences with ARM NEON.
651 ;; Expected: RMSE <= 0.34, actual: 0.407627
652 (substitute* "../opencv-contrib/modules/optflow/test/test_OF_accuracy.cpp"
653 (("\\bReferenceAccuracy\\b" all)
654 (string-append "DISABLED_" all))))
655 '())
656
657 ,@(if (target-riscv64?)
658 `(;; This test fails on riscv64, loosen the bounds.
659 ;; Expected: (max) < (0.1), actual: 0.220829 vs 0.1
660 (substitute* "modules/photo/test/test_hdr.cpp"
661 (("0\\.1") "0.240"))
662 ;; Expected equality of these values:
663 ;; ellipses.size()
664 ;; Which is: 668
665 ;; ellipses_size
666 ;; Which is: 2449
667 (substitute* "../opencv-contrib/modules/ximgproc/test/test_fld.cpp"
668 (("\\bManySmallCircles\\b" all)
669 (string-append "DISABLED_" all))))
670 '())))
671 (add-after 'unpack 'unpack-submodule-sources
672 (lambda* (#:key inputs #:allow-other-keys)
673 (mkdir "../opencv-extra")
674 (mkdir "../opencv-contrib")
675 (copy-recursively (assoc-ref inputs "opencv-extra")
676 "../opencv-extra")
677 (copy-recursively (assoc-ref inputs "opencv-contrib")
678 "../opencv-contrib")
679
680 ;; Disable downloads of Boost and VGG descriptors as we include
681 ;; them in native inputs.
682 (substitute* "../opencv-contrib/modules/xfeatures2d/CMakeLists.txt"
683 (("download_(boost|vgg)_descriptors") "#"))
684 (copy-recursively (assoc-ref inputs "opencv-3rdparty-boost")
685 "../downloads/xfeatures2d")
686 (for-each make-file-writable
687 (find-files "../downloads/xfeatures2d" "."))
688 (copy-recursively (assoc-ref inputs "opencv-3rdparty-vgg")
689 "../downloads/xfeatures2d")))
690 (add-after 'build 'do-not-install-3rdparty-file
691 (lambda _
692 (substitute* "cmake_install.cmake"
693 (("file\\(INSTALL .*3rdparty/include/opencl/LICENSE.txt.*")
694 ""))))
695 (add-before 'check 'start-xserver
696 (lambda* (#:key inputs #:allow-other-keys)
697 (let ((xorg-server (assoc-ref inputs "xorg-server"))
698 (disp ":1"))
699 (setenv "HOME" (getcwd))
700 (setenv "DISPLAY" disp)
701 ;; There must be a running X server and make check doesn't start one.
702 ;; Therefore we must do it.
703 (zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp)))))))))
704 (native-inputs
705 `(("pkg-config" ,pkg-config)
706 ("xorg-server" ,xorg-server-for-tests) ;For running the tests
707 ;; These are files that are derived from the binary descriptors that
708 ;; are part of the BinBoost package. The BinBoost package is released
709 ;; under GPLv2+. See
710 ;; https://www.epfl.ch/labs/cvlab/research/descriptors-and-keypoints/research-detect-binboost/
711 ;; See xfeatures2d/cmake/download_boostdesc.cmake for commit hash.
712 ("opencv-3rdparty-boost"
713 ,(let ((commit "34e4206aef44d50e6bbcd0ab06354b52e7466d26"))
714 (origin
715 (method git-fetch)
716 (uri (git-reference (url "https://github.com/opencv/opencv_3rdparty")
717 (commit commit)))
718 (file-name (git-file-name "opencv_3rdparty" commit))
719 (sha256
720 (base32
721 "13yig1xhvgghvxspxmdidss5lqiikpjr0ddm83jsi0k85j92sn62")))))
722 ;; These are the Visual Geometry Group descriptors, released under
723 ;; BSD-3. They are generated files produced by the DLCO framework.
724 ;; See xfeatures2d/cmake/download_vgg.cmake for commit hash.
725 ("opencv-3rdparty-vgg"
726 ,(let ((commit "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d"))
727 (origin
728 (method git-fetch)
729 (uri (git-reference (url "https://github.com/opencv/opencv_3rdparty")
730 (commit commit)))
731 (file-name (git-file-name "opencv_3rdparty" commit))
732 (sha256
733 (base32
734 "0r9fam8dplyqqsd3qgpnnfgf9l7lj44di19rxwbm8mxiw0rlcdvy")))))
735 ("opencv-extra"
736 ,(origin
737 (method git-fetch)
738 (uri (git-reference
739 (url "https://github.com/opencv/opencv_extra")
740 (commit version)))
741 (file-name (git-file-name "opencv_extra" version))
742 (sha256
743 (base32
744 "0awang2hl7z194rlnic38ry6fgxy8b7k2qqasinjqznxab4dkhvz"))))
745 ("opencv-contrib"
746 ,(origin
747 (method git-fetch)
748 (uri (git-reference (url "https://github.com/opencv/opencv_contrib")
749 (commit version)))
750 (file-name (git-file-name "opencv_contrib" version))
751 (sha256
752 (base32
753 "1ai1kanlq1wr3173q86yfj6r9h3kkvjx18cakjr31jkb25qyrmny"))))))
754 (inputs
755 (list eigen
756 ffmpeg-4
757 ;; TODO: add gstreamer
758 gtk+
759 hdf5
760 imath ;should be propagated by openexr
761 jasper
762 libgphoto2
763 libjpeg-turbo
764 libpng
765 libtiff
766 libwebp
767 openblas
768 opencl-headers
769 openexr
770 openmpi
771 openjpeg
772 protobuf
773 python
774 python-numpy
775 vtk
776 zlib))
777 ;; These three CVEs are not a problem of OpenCV, see:
778 ;; https://github.com/opencv/opencv/issues/10998
779 (properties '((lint-hidden-cve . ("CVE-2018-7712"
780 "CVE-2018-7713"
781 "CVE-2018-7714"))))
782 (synopsis "Computer vision library")
783 (description "OpenCV is a library aimed at real-time computer vision,
784including several hundred computer vision algorithms. It can be used to do
785things like:
786
787@itemize
788@item image and video input and output
789@item image and video processing
790@item displaying
791@item feature recognition
792@item segmentation
793@item facial recognition
794@item stereo vision
795@item structure from motion
796@item augmented reality
797@item machine learning
798@end itemize\n
799
800This package includes the Python bindings for OpenCV, which are also known as
801the OpenCV-Python library.")
802 (home-page "https://opencv.org/")
803 (license license:bsd-3)))
804
805(define-public vips
806 (package
807 (name "vips")
808 (version "8.17.0")
809 (source
810 (origin
811 (method git-fetch)
812 (uri (git-reference
813 (url "https://github.com/libvips/libvips")
814 (commit (string-append "v" version))))
815 (file-name (git-file-name name version))
816 (sha256
817 (base32 "1rdz2mmivr02s7cksqgbramv37yw95w6s8r20hgjqx36in2ndnbl"))))
818 (build-system meson-build-system)
819 (native-inputs
820 (list `(,glib "bin")
821 gobject-introspection
822 pkg-config))
823 (inputs
824 (list glib
825 hdf5
826 imagemagick
827 poppler))
828 ;; Propagated to satisfy vips.pc.
829 (propagated-inputs
830 (list expat
831 fftw
832 lcms
833 libexif
834 libgsf
835 libjpeg-turbo
836 libpng
837 (librsvg-for-system)
838 libtiff
839 libwebp
840 matio
841 openexr
842 orc
843 pango))
844 (home-page "https://www.libvips.org/")
845 (synopsis "Multithreaded image processing system with low memory needs")
846 (description
847 "VIPS is a demand-driven, horizontally threaded image processing library.
848It's particularly good at processing large images, working with colour,
849scientific analysis, and general research & development.
850
851Compared to most image processing libraries VIPS needs little RAM and runs
852quickly, especially on machines with more than one CPU core. This is primarily
853due to its architecture which automatically parallelises the image workflows.")
854 (license license:lgpl2.1+)))
855
856(define-public gmic
857 (package
858 (name "gmic")
859 (version "3.6.5")
860 (source
861 (origin
862 (method url-fetch)
863 (uri (string-append "https://gmic.eu/files/source/gmic_"
864 version ".tar.gz"))
865 (sha256
866 (base32 "16hncbj7isxcw5al3zf62n8iwpsvbnmfclihdbgq4fnwci6yb1q9"))))
867 (build-system cmake-build-system)
868 (arguments
869 (list
870 #:tests? #f ;there are no tests
871 #:configure-flags #~(list "-DBUILD_LIB_STATIC=OFF"
872 "-DENABLE_DYNAMIC_LINKING=ON"
873 (string-append "-DCMAKE_EXE_LINKER_FLAGS="
874 "-Wl,-rpath=" #$output "/lib")
875 "-DENABLE_LTO=ON")))
876 (native-inputs
877 (list pkg-config))
878 (inputs
879 (list curl
880 fftw
881 graphicsmagick
882 imath
883 libjpeg-turbo
884 libpng
885 libtiff
886 libx11
887 openexr
888 zlib))
889 (home-page "https://gmic.eu/")
890 (synopsis "Full-featured framework for digital image processing")
891 (description "G'MIC is a full-featured framework for digital image
892processing. It provides several user interfaces to convert / manipulate
893/ filter / visualize generic image datasets, ranging from 1D scalar
894signals to 3D+t sequences of multi-spectral volumetric images, hence
895including 2D color images.")
896 ;; Dual-licensed, either license applies.
897 (license (list license:cecill license:cecill-c))))
898
899(define-public gmic-qt
900 (package
901 (inherit gmic)
902 (name "gmic-qt")
903 (arguments
904 (substitute-keyword-arguments (package-arguments gmic)
905 ((#:configure-flags _)
906 #~(list "-DGMIC_QT_HOST=none"
907 "-DENABLE_DYNAMIC_LINKING=ON"))
908 ((#:phases phases '%standard-phases)
909 #~(modify-phases #$phases
910 (add-after 'unpack 'qt-chdir
911 (lambda _ (chdir "gmic-qt")))))))
912 (native-inputs
913 (list pkg-config qttools-5))
914 (inputs
915 (modify-inputs (package-inputs gmic)
916 (prepend gmic qtbase-5)))
917 (synopsis "Qt frontend for the G'MIC image processing framework")
918 (license license:gpl3+)))
919
920(define-public gmic-qt-gimp
921 (package
922 (inherit gmic-qt)
923 (name "gmic-qt-gimp")
924 (inputs
925 ;; GIMP and its dependencies.
926 (modify-inputs (package-inputs gmic-qt)
927 (prepend gexiv2 gdk-pixbuf gegl gimp pango)))
928 (arguments
929 (substitute-keyword-arguments (package-arguments gmic-qt)
930 ((#:configure-flags flags)
931 #~(list "-DGMIC_QT_HOST=gimp3"
932 "-DENABLE_DYNAMIC_LINKING=ON"))))
933 (synopsis "GIMP plugin for the G'MIC image processing framework")))
934
935(define-public nip2
936 (package
937 (name "nip2")
938 (version "8.9.1")
939 (source
940 (origin
941 (method url-fetch)
942 (uri (string-append "https://github.com/libvips/nip2/releases/download/v"
943 version "/nip2-" version ".tar.gz" ))
944 (sha256
945 (base32 "1kbndn37m0cfjvrvw25b5if9d962r8v79q78i2lzm55r7zmjcpmp"))))
946 (build-system gnu-build-system)
947 (arguments
948 `(#:phases
949 (modify-phases %standard-phases
950 (add-before 'check 'set-home
951 (lambda _
952 (setenv "HOME" "/tmp"))))))
953 (inputs (list gsl gtk+-2 vips))
954 (native-inputs (list bison flex pkg-config))
955 (home-page "https://github.com/libvips/nip2")
956 (synopsis "Spreadsheet-like GUI for libvips")
957 (description "This package provide a graphical user interface (GUI) for
958the VIPS image processing library. It's a little like a spreadsheet: you
959create a set of formula connecting your objects together, and on a change nip2
960recalculates.")
961 (license license:gpl2+)))
962
963(define-public paraview
964 (package
965 (name "paraview")
966 (version "6.0.0")
967 (source
968 (origin
969 (method git-fetch)
970 (uri (git-reference
971 (url "https://gitlab.kitware.com/paraview/paraview")
972 (commit (string-append "v" version))
973 (recursive? #t)))
974 (file-name (git-file-name name version))
975 (sha256
976 (base32 "1m1c7vngrpaqdqvnjx4wj0va20hih5rb7rf0a44mp3wqgp4wgy0f"))
977 (modules '((guix build utils)))
978 (snippet
979 ;; TODO: Also remove unused bundled libraries and plugins?
980 #~(begin
981 ;; Remove bundled ParaView libraries which are available in Guix
982 ;; or undesired.
983 (for-each (lambda (dir)
984 (delete-file-recursively
985 (string-append "ThirdParty/" dir "/vtk"
986 (string-downcase dir))))
987 '(;;"CosmoHaloFinder"
988 ;;"IceT"
989 "NvPipe" ; Don't want NvPipe support
990 ;;"QtTesting"
991 ;;"cinema"
992 ;;"cinemasci"
993 "protobuf"))
994 ;; Remove undesired ParaView plugins.
995 (delete-file-recursively "Plugins/pvNVIDIAIndeX")
996 ;; Remove bundled VTK libraries which are available in Guix.
997 (for-each (lambda (dir)
998 (delete-file-recursively
999 (string-append "VTK/ThirdParty/" dir "/vtk" dir)))
1000 '("cgns"
1001 "cli11"
1002 ;;"diy2"
1003 "doubleconversion"
1004 "eigen"
1005 ;;"exodusII"
1006 "expat"
1007 ;;"exprtk"
1008 ;;"fast-float"
1009 ;;"fides"
1010 "fmt"
1011 "freetype"
1012 "gl2ps"
1013 ;;"glad"
1014 ;;"h5part"
1015 "hdf5"
1016 ;;"ioss"
1017 "jpeg"
1018 "jsoncpp"
1019 ;;"kissfft"
1020 ;;"libharu" ; Requires some PRs applied to 2.3.0
1021 "libproj"
1022 "libxml2"
1023 ;;"loguru"
1024 "lz4"
1025 "lzma"
1026 "mpi4py"
1027 "netcdf"
1028 "nlohmannjson"
1029 "ogg"
1030 ;;"pegtl"
1031 "png"
1032 "pugixml"
1033 "sqlite"
1034 "theora"
1035 "tiff"
1036 ;;"token"
1037 "utf8"
1038 ;;"verdict"
1039 ;;"viskores"
1040 ;;"vpic"
1041 ;;"vtkm"
1042 ;;"xdmf2"
1043 ;;"xdmf3"
1044 "zlib"))))))
1045 (build-system qt-build-system)
1046 (arguments
1047 (list
1048 #:qtbase qtbase
1049 #:build-type "Release" ; 542 MiB in release mode
1050 #:tests? #f ; Downloads test data
1051 #:configure-flags
1052 #~(let ((doc (string-append "share/doc/" #$name "-" #$version)))
1053 (list
1054 (string-append "-DCMAKE_INSTALL_DOCDIR=" doc) ; For paraview.qch
1055
1056 ;; ParaView build options
1057 "-DPARAVIEW_BUILD_DEVELOPER_DOCUMENTATION=ON"
1058 (string-append "-DPARAVIEW_GENERATED_DOCUMENTATION_OUTPUT_DIRECTORY=" doc)
1059
1060 ;; ParaView capability options
1061 ;;"-DPARAVIEW_USE_EXTERNAL_VTK=ON" ; Unsupported by ParaView
1062 "-DPARAVIEW_USE_MPI=ON"
1063 "-DPARAVIEW_USE_PYTHON=ON"
1064 "-DPARAVIEW_USE_QTWEBENGINE=ON"
1065
1066 ;; ParaView features
1067 ;;
1068 ;; Enable those that are disabled by default.
1069 ;; Commented means the dependencies are missing from Guix
1070 ;; (or are otherwise described).
1071 ;;"-DPARAVIEW_ENABLE_ADIOS2=ON"
1072 ;;"-DPARAVIEW_ENABLE_COSMOTOOLS=ON"
1073 ;;"-DPARAVIEW_ENABLE_CATALYST=ON"
1074 "-DPARAVIEW_ENABLE_FFMPEG=ON"
1075 ;;"-DPARAVIEW_ENABLE_FIDES=ON"
1076 "-DPARAVIEW_ENABLE_GDAL=ON"
1077 ;;"-DPARAVIEW_ENABLE_LAS=ON"
1078 ;;"-DPARAVIEW_ENABLE_LOOKINGGLASS=ON" ; Downloads dependency
1079 ;;"-DPARAVIEW_ENABLE_MOMENTINVARIANTS=ON" ; Downloads dependency
1080 "-DPARAVIEW_ENABLE_MOTIONFX=ON"
1081 ;;"-DPARAVIEW_ENABLE_OPENTURNS=ON"
1082 ;;"-DPARAVIEW_ENABLE_OPENVDB=ON" ; Dependency not found
1083 ;;"-DPARAVIEW_ENABLE_PDAL=ON"
1084 ;;"-DPARAVIEW_ENABLE_RAYTRACING=ON"
1085 "-DPARAVIEW_ENABLE_VISITBRIDGE=ON"
1086 "-DPARAVIEW_ENABLE_XDMF3=ON"
1087
1088 ;; ParaView miscellaneous options
1089 ;;
1090 ;; Without -DPARAVIEW_DATA_EXCLUDE_FROM_ALL=OFF, test data is
1091 ;; downloaded even with tests disabled.
1092 "-DPARAVIEW_VERSIONED_INSTALL=OFF"
1093 "-DPARAVIEW_DATA_EXCLUDE_FROM_ALL=OFF"
1094
1095 ;; ParaView plugins
1096 ;;
1097 ;; Enable those that are disabled by default.
1098 ;; Commented means the dependencies are missing from Guix
1099 ;; (or are otherwise described).
1100 ;;"-DPARAVIEW_PLUGIN_ENABLE_AdiosReaderPixie=ON"
1101 ;;"-DPARAVIEW_PLUGIN_ENABLE_AdiosReaderStaging=ON"
1102 "-DPARAVIEW_PLUGIN_ENABLE_CAVEInteraction=ON"
1103 ;;"-DPARAVIEW_PLUGIN_ENABLE_CDIReader=ON"
1104 "-DPARAVIEW_PLUGIN_ENABLE_GeographicalMap=ON"
1105 "-DPARAVIEW_PLUGIN_ENABLE_GmshIO=ON"
1106 "-DPARAVIEW_PLUGIN_ENABLE_InSituExodus=ON"
1107 ;;"-DPARAVIEW_PLUGIN_ENABLE_LookingGlass=ON"
1108 "-DPARAVIEW_PLUGIN_ENABLE_NetCDFTimeAnnotationPlugin=ON"
1109 ;;"-DPARAVIEW_PLUGIN_ENABLE_ParFlow=ON" ; Build fails
1110 ;;"-DPARAVIEW_PLUGIN_ENABLE_PythonQtPlugin=ON"
1111 "-DPARAVIEW_PLUGIN_ENABLE_SpaceMouseInteractor=ON"
1112 ;;"-DPARAVIEW_PLUGIN_ENABLE_VDFReaderPlugin=ON"
1113 ;;"-DPARAVIEW_PLUGIN_ENABLE_XRInterface=ON" ; Build fails
1114 ;;"-DPARAVIEW_PLUGIN_ENABLE_zSpace=ON"
1115
1116 ;; VTK options
1117 "-DVTK_SMP_IMPLEMENTATION_TYPE=TBB"
1118 "-DVTKm_ENABLE_MPI=ON"
1119
1120 ;; External libraries for ParaView and VTK
1121 "-DVTK_MODULE_USE_EXTERNAL_ParaView_protobuf=ON"
1122 "-DVTK_MODULE_USE_EXTERNAL_VTK_cgns=ON"
1123 "-DVTK_MODULE_USE_EXTERNAL_VTK_cli11=ON"
1124 "-DVTK_MODULE_USE_EXTERNAL_VTK_doubleconversion=ON"
1125 "-DVTK_MODULE_USE_EXTERNAL_VTK_eigen=ON"
1126 "-DVTK_MODULE_USE_EXTERNAL_VTK_expat=ON"
1127 "-DVTK_MODULE_USE_EXTERNAL_VTK_fmt=ON"
1128 "-DVTK_MODULE_USE_EXTERNAL_VTK_freetype=ON"
1129 "-DVTK_MODULE_USE_EXTERNAL_VTK_gl2ps=ON"
1130 "-DVTK_MODULE_USE_EXTERNAL_VTK_hdf5=ON"
1131 "-DVTK_MODULE_USE_EXTERNAL_VTK_jpeg=ON"
1132 "-DVTK_MODULE_USE_EXTERNAL_VTK_jsoncpp=ON"
1133 "-DVTK_MODULE_USE_EXTERNAL_VTK_libproj=ON"
1134 "-DVTK_MODULE_USE_EXTERNAL_VTK_libxml2=ON"
1135 "-DVTK_MODULE_USE_EXTERNAL_VTK_lz4=ON"
1136 "-DVTK_MODULE_USE_EXTERNAL_VTK_lzma=ON"
1137 "-DVTK_MODULE_USE_EXTERNAL_VTK_mpi4py=ON"
1138 "-DVTK_MODULE_USE_EXTERNAL_VTK_netcdf=ON"
1139 "-DVTK_MODULE_USE_EXTERNAL_VTK_nlohmannjson=ON"
1140 "-DVTK_MODULE_USE_EXTERNAL_VTK_ogg=ON"
1141 ;;"-DVTK_MODULE_USE_EXTERNAL_VTK_pegtl=ON"
1142 "-DVTK_MODULE_USE_EXTERNAL_VTK_png=ON"
1143 "-DVTK_MODULE_USE_EXTERNAL_VTK_pugixml=ON"
1144 "-DVTK_MODULE_USE_EXTERNAL_VTK_sqlite=ON"
1145 "-DVTK_MODULE_USE_EXTERNAL_VTK_theora=ON"
1146 "-DVTK_MODULE_USE_EXTERNAL_VTK_tiff=ON"
1147 "-DVTK_MODULE_USE_EXTERNAL_VTK_utf8=ON"
1148 "-DVTK_MODULE_USE_EXTERNAL_VTK_zlib=ON"))
1149 #:phases
1150 #~(modify-phases %standard-phases
1151 (add-after 'set-paths 'hide-gfortran
1152 (lambda _
1153 (setenv "CPLUS_INCLUDE_PATH"
1154 (string-join
1155 (delete (string-append #$(this-package-native-input "gfortran")
1156 "/include/c++")
1157 (string-split (getenv "CPLUS_INCLUDE_PATH") #\:))
1158 ":"))))
1159 (replace 'install-license-files
1160 (lambda _
1161 (let ((src (string-append #$output "/share/licenses/ParaView"))
1162 (dst (string-append #$output "/share/doc/"
1163 #$name "-" #$version "/licenses")))
1164 (copy-recursively src dst)
1165 (delete-file-recursively (dirname src))))))))
1166 (native-inputs
1167 (list gfortran
1168 ;; For the documentation
1169 doxygen
1170 graphviz
1171 perl
1172 python-sphinx))
1173 (inputs
1174 (list boost
1175 cgns
1176 cli11
1177 curl
1178 double-conversion
1179 eigen
1180 expat
1181 ffmpeg
1182 fmt-11
1183 freetype
1184 gdal
1185 gl2ps
1186 gmsh
1187 hdf5
1188 nlohmann-json ;For ParFlow; build fails
1189 jsoncpp
1190 libjpeg-turbo
1191 libogg
1192 libpng
1193 libtheora
1194 libtiff
1195 libxcursor
1196 libxml2
1197 libxslt
1198 libxt
1199 lz4
1200 lzip
1201 mesa
1202 netcdf
1203 openmpi
1204 ;;openvdb ;For OpenVDB; dependency not found
1205 ;;openvr ;For XRInterface; build fails
1206 ;;pegtl ;For VTK; build fails
1207 proj
1208 protobuf
1209 pugixml
1210 python-cftime
1211 python-matplotlib
1212 python-mpi4py
1213 python-numpy
1214 python-wrapper
1215 qt5compat
1216 qtdeclarative
1217 qtmultimedia
1218 qtsvg
1219 qttools
1220 qtwebchannel
1221 qtwebengine
1222 sdl2
1223 sqlite
1224 tbb
1225 utfcpp
1226 zlib))
1227 (home-page "https://www.paraview.org/")
1228 (synopsis "VTK-based, parallel data analyzer and visualizer")
1229 (description "ParaView is a VTK-based, parallel data analyzer and
1230visualizer which allows exploring data interactively in 3D or
1231programmatically.")
1232 (license license:bsd-3)))
1233
1234(define-public vxl
1235 (package
1236 (name "vxl")
1237 (version "3.5.0")
1238 (source
1239 (origin
1240 (method git-fetch)
1241 (uri (git-reference
1242 (url "https://github.com/vxl/vxl")
1243 (commit (string-append "v" version))))
1244 (file-name (git-file-name name version))
1245 (sha256
1246 (base32 "0iqq4lm51l5gvkax6r79ypifqmgir3p3vman9gsc2085d2agjvbs"))
1247 (modules '((guix build utils)))
1248 ;; TODO: vxl includes an old version of dcmtk. It won't build with
1249 ;; version 3.6.x.
1250 (snippet
1251 '(begin
1252 (for-each delete-file-recursively
1253 '("v3p/bzlib/"
1254 "v3p/geotiff/"
1255 "v3p/jpeg/"
1256 "v3p/png/"
1257 "v3p/tiff/"
1258 "v3p/zlib/"))
1259 (substitute* "v3p/CMakeLists.txt"
1260 (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
1261 ""))
1262 #t))))
1263 (build-system cmake-build-system)
1264 (arguments
1265 ;; Not an actual test, but is incorrectly generated by the build system.
1266 (list #:test-exclude "vul_vul_test_driver"))
1267 (inputs
1268 (list libgeotiff libtiff libjpeg-turbo libpng zlib))
1269 (home-page "https://github.com/vxl/vxl/")
1270 (synopsis "Collection of C++ libraries for computer vision")
1271 (description "VXL (the Vision-something-Libraries) is a collection of C++
1272libraries designed for computer vision research and implementation.")
1273 (license license:bsd-3)))
1274
1275(define-public vxl-1
1276 (package (inherit vxl)
1277 (name "vxl")
1278 (version "1.18.0")
1279 (source
1280 (origin
1281 (method git-fetch)
1282 (uri (git-reference
1283 (url "https://github.com/vxl/vxl")
1284 (commit (string-append "v" version))))
1285 (file-name (git-file-name name version))
1286 (sha256
1287 (base32 "1g4mr2cc58jwm0vasscbd4y5380wj3ahkvq121z4gs83fhavvxgz"))
1288 (modules '((guix build utils)))
1289 (snippet
1290 '(begin
1291 (for-each delete-file-recursively
1292 '("v3p/bzlib/"
1293 "v3p/geotiff/"
1294 "v3p/png/"
1295 "v3p/tiff/"
1296 "v3p/zlib/"))
1297 (substitute* "v3p/CMakeLists.txt"
1298 (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
1299 ""))))))
1300 (arguments
1301 (substitute-keyword-arguments (package-arguments vxl)
1302 ((#:configure-flags flags)
1303 #~(cons* ;; Needed for itk-snap
1304 "-DVNL_CONFIG_LEGACY_METHODS=ON"
1305 "-DCMAKE_CXX_STANDARD=14"
1306 #$flags))))))
1307
1308(define-public insight-toolkit
1309 ;; For information about ITK remote modules, see:
1310 ;; https://insightsoftwareconsortium.github.io/ITKWikiArchive/Wiki/ITK/Policy_and_Procedures_for_Adding_Remote_Modules
1311 ;; For a remote MODULE, use the commit in
1312 ;; 'Modules/Remote/MODULE.remote.cmake'.
1313 ;; MorphologicalContourInterpolation is required by itk-snap.
1314 ;; SimpleITKFilters and GenericLabelInterpolator are required by simpleitk.
1315 ;; GenericLabelInterpolator and AdaptiveDenoising are required by ants.
1316 (let* ((module-mci-commit "821bf9b3ef8eaaab10391ed060dc9ca5e4d37b39")
1317 (module-mci-file (git-file-name "ITKMorphologicalContourInterpolation"
1318 module-mci-commit))
1319 (module-sitkf-commit "bb896868fc6480835495d0da4356d5db009592a6")
1320 (module-sitkf-file (git-file-name "ITKSimpleITKFilters"
1321 module-sitkf-commit))
1322 (module-gli-commit "ebf2436469ccf82c08fab54b7446f699ad0eae01")
1323 (module-gli-file (git-file-name "ITKGenericLabelInterpolator"
1324 module-gli-commit))
1325 (module-ad-commit "853934c352f83cb1e8f87e3051e1b8e75dbb41fe")
1326 (module-ad-file (git-file-name "ITKAdaptiveDenoising"
1327 module-ad-commit)))
1328 (package
1329 (name "insight-toolkit")
1330 (version "5.4.4")
1331 (source
1332 (origin
1333 (method git-fetch)
1334 (uri (git-reference
1335 (url "https://github.com/InsightSoftwareConsortium/ITK")
1336 (commit (string-append "v" version))))
1337 (file-name (git-file-name name version))
1338 (sha256
1339 (base32 "1l5rby8jj8726k380aivycmhn56cz56mr9k3r56c8hkkrfwwng50"))
1340 ;; This patch is required to build with both ITK_USE_GPU=ON and
1341 ;; ITK_WRAP_PYTHON=ON.
1342 ;; <https://github.com/InsightSoftwareConsortium/ITK/pull/4842>
1343 (patches (search-patches "insight-toolkit-fix-build.patch"))))
1344 (build-system cmake-build-system)
1345 (outputs '("out" "python"))
1346 (arguments
1347 (list
1348 #:imported-modules (append %cmake-build-system-modules
1349 %pyproject-build-system-modules)
1350 #:modules '(((guix build pyproject-build-system) #:prefix py:)
1351 (guix build cmake-build-system)
1352 (guix build utils))
1353 #:configure-flags
1354 #~(list "-DITK_USE_GPU=ON"
1355 "-DITK_USE_SYSTEM_LIBRARIES=ON"
1356 "-DITK_USE_SYSTEM_CASTXML=ON"
1357 "-DITK_USE_SYSTEM_SWIG=ON"
1358 (string-append "-DHDF5_DIR="
1359 #$(this-package-input "hdf5") "/lib/cmake")
1360 "-DBUILD_SHARED_LIBS=ON"
1361 ;; Without this flag, there are shared libraries installed
1362 ;; in PY_SITE_PACKAGES_PATH/itk instead of #$output/lib and
1363 ;; RUNPATHs contain the *build directory* of
1364 ;; PY_SITE_PACKAGES_PATH/itk.
1365 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON"
1366 "-DITK_WRAPPING=ON"
1367 "-DITK_WRAP_PYTHON=ON"
1368 "-DITK_DYNAMIC_LOADING=ON"
1369 (let* ((python-version
1370 #$(version-major+minor
1371 (package-version
1372 (this-package-input "python"))))
1373 (python-lib-path (string-append #$output:python
1374 "/lib/python"
1375 python-version
1376 "/site-packages")))
1377 (string-append "-DPY_SITE_PACKAGES_PATH="
1378 python-lib-path))
1379 ;; Python is not built with Py_LIMITED_API.
1380 "-DITK_USE_PYTHON_LIMITED_API=OFF"
1381 "-DModule_MorphologicalContourInterpolation=ON"
1382 "-DModule_SimpleITKFilters=ON"
1383 "-DModule_GenericLabelInterpolator=ON"
1384 "-DModule_AdaptiveDenoising:BOOL=ON"
1385 "-DModule_ITKReview:BOOL=ON"
1386 "-DCMAKE_CXX_STANDARD=17"
1387 "-DBUILD_TESTING=OFF")
1388
1389 #:phases
1390 (with-extensions (list (pyproject-guile-json))
1391 #~(modify-phases %standard-phases
1392 (add-after 'unpack 'do-not-tune
1393 (lambda _
1394 (substitute* "CMake/ITKSetStandardCompilerFlags.cmake"
1395 (("-mtune=native")
1396 ""))))
1397 (add-after 'unpack 'ignore-warnings
1398 (lambda _
1399 (substitute* "Wrapping/Generators/Python/CMakeLists.txt"
1400 (("-Werror")
1401 ""))))
1402 (add-after 'unpack 'exclude-gtest-target
1403 (lambda _
1404 ;; Prevent ITKGoogleTest from being added to
1405 ;; ITK_MODULES_ENABLED in the installed
1406 ;; ITKConfig.cmake, which in turn prevents
1407 ;; 'GTest::GTest' from being added to the
1408 ;; ITK_LIBRARIES variable. This is necessary
1409 ;; because projects that use ITK fail to configure
1410 ;; otherwise. Fixes
1411 ;; <https://codeberg.org/guix/guix/issues/776>.
1412 ;; <https://github.com/microsoft/vcpkg/pull/27187>
1413 (substitute* "Modules/ThirdParty/GoogleTest/itk-module.cmake"
1414 (("DEPENDS")
1415 "DEPENDS\n EXCLUDE_FROM_DEFAULT"))))
1416 (add-after 'unpack 'prepare-remote-modules
1417 (lambda _
1418 ;; ITK module MorphologicalContourInterpolation
1419 ;; is for ITK-SNAP.
1420 (symlink #$(this-package-native-input module-mci-file)
1421 "Modules/Remote/MorphologicalContourInterpolation")
1422 (delete-file
1423 (string-append
1424 "Modules/Remote/"
1425 "MorphologicalContourInterpolation.remote.cmake"))
1426 ;; ITK modules SimpleITKFilters and GenericLabelInterpolator
1427 ;; are for SimpleITK.
1428 (symlink #$(this-package-native-input module-sitkf-file)
1429 "Modules/Remote/SimpleITKFilters")
1430 (delete-file "Modules/Remote/SimpleITKFilters.remote.cmake")
1431 (symlink #$(this-package-native-input module-gli-file)
1432 "Modules/Remote/GenericLabelInterpolator")
1433 (delete-file
1434 "Modules/Remote/GenericLabelInterpolator.remote.cmake")
1435 (symlink #$(this-package-native-input module-ad-file)
1436 "Modules/Remote/AdaptiveDenoising")
1437 (delete-file
1438 "Modules/Remote/AdaptiveDenoising.remote.cmake")))
1439 (add-after 'unpack 'fix-numpy-bool
1440 (lambda _
1441 ;; <https://github.com/InsightSoftwareConsortium/ITK/pull/5402>
1442 (substitute* (string-append "Wrapping/Generators/"
1443 "Python/itk/support/types.py")
1444 (("np\\.bool") "np.bool_"))))
1445 (delete 'check) ;tests require network access and external data
1446 (add-after 'install 'python-sanity-check
1447 (lambda* (#:key inputs outputs tests? #:allow-other-keys)
1448 (when tests?
1449 (py:add-installed-pythonpath inputs outputs)
1450 (invoke "python3" "-c" "import itk"))))))))
1451 (inputs (list eigen
1452 expat
1453 fftw
1454 fftwf
1455 hdf5
1456 libjpeg-turbo
1457 libpng
1458 libtiff
1459 opencl-headers
1460 opencl-icd-loader
1461 perl
1462 python
1463 tbb
1464 vxl-1
1465 zlib))
1466 (native-inputs
1467 (list castxml
1468 gcc-13
1469 git-minimal
1470 pkg-config
1471 python-numpy ;for phase 'python-sanity-check
1472 swig-next
1473 which
1474 (origin
1475 (method git-fetch)
1476 (uri
1477 (git-reference
1478 (url (string-append
1479 "https://github.com/KitwareMedical/"
1480 "ITKMorphologicalContourInterpolation"))
1481 (commit module-mci-commit)))
1482 (file-name module-mci-file)
1483 (sha256
1484 (base32
1485 "00myhgvlk3n062i8bnknz1d10zkv3jlvs7f4jnk24727gd4v2n4i")))
1486 (origin
1487 (method git-fetch)
1488 (uri (git-reference
1489 (url (string-append
1490 "https://github.com/InsightSoftwareConsortium/"
1491 "ITKSimpleITKFilters"))
1492 (commit module-sitkf-commit)))
1493 (file-name module-sitkf-file)
1494 (sha256
1495 (base32
1496 "13nys94wl4k77f89i8y1dm3y4pmgmw3rrc0la1rzl0vi9h1qixii")))
1497 (origin
1498 (method git-fetch)
1499 (uri (git-reference
1500 (url (string-append
1501 "https://github.com/InsightSoftwareConsortium/"
1502 "ITKGenericLabelInterpolator"))
1503 (commit module-gli-commit)))
1504 (file-name module-gli-file)
1505 (sha256
1506 (base32
1507 "1khakqh6pzdg6csli8jypzrhcdr9xmhnzgwz265krv8r5mbnndrg")))
1508 (origin
1509 (method git-fetch)
1510 (uri (git-reference
1511 (url "https://github.com/ntustison/ITKAdaptiveDenoising")
1512 (commit module-ad-commit)))
1513 (file-name module-ad-file)
1514 (sha256
1515 (base32
1516 "0aqvhb4byg0shgbrwmb41nq2h8sbg45xn0gsdy94iiq0v72bw307")))))
1517
1518 ;; The 'CMake/ITKSetStandardCompilerFlags.cmake' file normally sets
1519 ;; '-mtune=native -march=corei7', suggesting there's something to be
1520 ;; gained from CPU-specific optimizations.
1521 (properties '((tunable? . #t)))
1522
1523 (home-page "https://github.com/InsightSoftwareConsortium/ITK/")
1524 (synopsis "Scientific image processing, segmentation and registration")
1525 (description
1526 "The Insight Toolkit (ITK) is a toolkit for N-dimensional
1527scientific image processing, segmentation, and registration. Segmentation is
1528the process of identifying and classifying data found in a digitally sampled
1529representation. Typically the sampled representation is an image acquired
1530from such medical instrumentation as CT or MRI scanners. Registration is the
1531task of aligning or developing correspondences between data. For example, in
1532the medical environment, a CT scan may be aligned with a MRI scan in order to
1533combine the information contained in both.")
1534 (license license:asl2.0))))
1535
1536;; Provide variant of insight-toolkit (ITK) built with ITK_LEGACY_REMOVE=OFF.
1537;; ITK-SNAP version 4.2.2 and 4.4.0-alpha3 require ITK >= 5.4 and for ITK to
1538;; be built this way. Note that enabling Python wrapping forces this option
1539;; to ON, so Python wrapping is not enabled for this build.
1540(define insight-toolkit-legacy
1541 (hidden-package
1542 (package/inherit insight-toolkit
1543 ;; Unfortunately we cannot remove the 'python output because it is
1544 ;; referenced in #:configure-flags below.
1545 (name "insight-toolkit-legacy")
1546 (arguments
1547 (substitute-keyword-arguments (package-arguments insight-toolkit)
1548 ((#:configure-flags cf '())
1549 #~(filter (lambda (flag)
1550 (not (or
1551 ;; Remove these flags to restore the default
1552 ;; ITK_LEGACY_REMOVE=OFF.
1553 (string=? "-DITK_WRAPPING=ON" flag)
1554 (string=? "-DITK_WRAP_PYTHON=ON" flag)
1555 ;; These flags are now unused.
1556 (string-prefix? "-DPY_SITE_PACKAGES_PATH=" flag)
1557 (string-prefix? "-DITK_USE_PYTHON_LIMITED_API=" flag)
1558 (string-prefix? "-DITK_USE_SYSTEM_CASTXML=" flag)
1559 (string-prefix? "-DITK_USE_SYSTEM_SWIG=" flag))))
1560 #$cf))
1561 ((#:phases phases #~%standard-phases)
1562 #~(modify-phases #$phases
1563 (delete 'python-sanity-check)))))
1564 (inputs (modify-inputs (package-inputs insight-toolkit)
1565 (delete "python")))
1566 (native-inputs (modify-inputs (package-native-inputs insight-toolkit)
1567 (delete "castxml")
1568 (delete "python-numpy")
1569 (delete "swig"))))))
1570
1571(define-public itk-snap
1572 ;; The latest release, 4.2.2, segmentation faults on startup.
1573 ;; The commit is version 4.4.0-alpha3.
1574 (let ((commit "65251254d44d68a6c0530984169784e35de020dd")
1575 (revision "0"))
1576 (package
1577 (name "itk-snap")
1578 (version (git-version "4.2.2" revision commit))
1579 (source
1580 (origin
1581 (method git-fetch)
1582 (uri (git-reference
1583 (url "https://github.com/pyushkevich/itksnap")
1584 (commit commit)))
1585 (file-name (git-file-name name version))
1586 (sha256
1587 (base32 "07dgcfklc55yj3ldcq6fc5fil8qfrv7z6c3xhbd293kz7kpjr4yc"))))
1588 (build-system cmake-build-system)
1589 (arguments
1590 (list
1591 #:configure-flags
1592 #~(list "-DSNAP_VERSION_GIT_BRANCH=release"
1593 "-DSNAP_PACKAGE_QT_PLUGINS=OFF")
1594 #:phases
1595 #~(modify-phases %standard-phases
1596 ;; During the installation phase all libraries provided by all
1597 ;; dependencies will be copied to the lib directory. That's insane,
1598 ;; so we disable this.
1599 (add-after 'unpack 'do-not-copy-dependencies
1600 (lambda _
1601 (substitute* "CMakeLists.txt"
1602 (("install_qt5_executable\
1603\\(\\$\\{SNAP_MAIN_INSTALL_DIR\\}/\\$\\{SNAP_EXE\\}\\)")
1604 ""))))
1605 (add-after 'unpack 'disable-gui-tests
1606 (lambda _
1607 ;; The GUI tests just segmentation fault.
1608 (substitute* "CMakeLists.txt"
1609 ((" (Workspace|DiffSpace|ProbeIntensity|RegionCompetition\
1610|RandomForest|RandomForestBailOut|NaNs|4DContinuousRenderingD|EdgeAttraction\
1611|EchoCartesianDicomLoading|LabelSmoothing|PreferencesDialog|MeshImport\
1612|MeshWorkspace|SegmentationMesh|VolumeRendering|Reloading|4DToMC|MCTo4D\
1613|DeformationGrid)")
1614 ""))))
1615 (add-after 'unpack 'make-reproducible
1616 (lambda _
1617 (substitute* "CMakeLists.txt"
1618 (("TODAY\\(SNAP_VERSION_COMPILE_DATE\\)")
1619 "SET(SNAP_VERSION_COMPILE_DATE \"(removed for reproducibility)\")"))))
1620 (add-after 'unpack 'prepare-submodules
1621 (lambda _
1622 (rmdir "Submodules/c3d")
1623 (symlink #$(this-package-native-input "c3d-checkout")
1624 "Submodules/c3d")
1625 (rmdir "Submodules/digestible")
1626 (symlink #$(this-package-native-input "digestible-checkout")
1627 "Submodules/digestible")
1628 (rmdir "Submodules/greedy")
1629 (symlink #$(this-package-native-input "greedy-checkout")
1630 "Submodules/greedy")))
1631 (add-after 'unpack 'remove-bundled-jsoncpp
1632 (lambda _
1633 (substitute* "CMakeLists.txt"
1634 ((" Common/JSon/jsoncpp\\.cpp") ""))))
1635 (add-before 'check 'prepare-tests
1636 (lambda _
1637 ;; Needed by at least one test.
1638 (setenv "HOME" "/tmp")))
1639 (add-after 'install 'wrap-executable
1640 (lambda _
1641 (wrap-program (string-append #$output "/bin/itksnap")
1642 (list
1643 "QT_PLUGIN_PATH"
1644 'suffix
1645 (list (string-append #$(this-package-input "qtbase")
1646 "/lib/qt6/plugins")
1647 (string-append #$(this-package-input "qtdeclarative")
1648 "/lib/qt6/plugins")))))))))
1649 (inputs
1650 (list curl
1651 freetype
1652 glew
1653 glu
1654 insight-toolkit-legacy
1655 jsoncpp
1656 libssh
1657 mesa-opencl
1658 qtbase
1659 qtdeclarative
1660 vtk))
1661 (native-inputs
1662 (list
1663 doxygen
1664 ;; Use the submodule commits in this version of ITK-SNAP.
1665 (origin
1666 (method git-fetch)
1667 (uri (git-reference
1668 (url "https://github.com/pyushkevich/c3d")
1669 (commit "a86a2a32db8635c1535522332fee68bc56eacaa2")))
1670 (file-name "c3d-checkout")
1671 (sha256
1672 (base32 "0da3ikx7pqlrmvhkmzil269j6kyd84pphy1mls8v69gmzl89piis")))
1673 (origin
1674 (method git-fetch)
1675 (uri (git-reference
1676 (url "https://github.com/pyushkevich/digestible")
1677 (commit "1b66709e99c43d280bb472e1a0e36185ef2ea412")))
1678 (file-name "digestible-checkout")
1679 (sha256
1680 (base32 "1m1b954prq6l3byfdgxw2y17xsg81agd516g5n6ps60dqnxw8hqs")))
1681 (origin
1682 (method git-fetch)
1683 (uri (git-reference
1684 (url "https://github.com/pyushkevich/greedy")
1685 (commit "f10152c5374da08ee024c4c60ef8882876bd0808")))
1686 (file-name "greedy-checkout")
1687 (sha256
1688 (base32 "0xk1l0h4wis4nkfwjnvh624bdlhy7l26djibk4l00wzv0vvq21qv")))))
1689 (home-page "https://sourceforge.net/p/itk-snap/")
1690 (synopsis "Medical image segmentation")
1691 (description "ITK-SNAP is a tool for segmenting anatomical structures in
1692medical images. It provides an automatic active contour segmentation
1693pipeline, along with supporting a manual segmentation toolbox. ITK-SNAP has a
1694full-featured UI aimed at clinical researchers.")
1695 ;; This includes the submodules greedy, c3d and digestible.
1696 (license license:gpl3+))))
1697
1698(define-public metapixel
1699 ;; Follow stable branch.
1700 (let ((commit "98ee9daa093b6c334941242e63f90b1c2876eb4f"))
1701 (package
1702 (name "metapixel")
1703 (version (git-version "1.0.2" "1" commit))
1704 (source
1705 (origin
1706 (method git-fetch)
1707 (uri (git-reference
1708 (url "https://github.com/schani/metapixel")
1709 (commit commit)
1710 ;; TODO: Package rwimg and lispreader?
1711 (recursive? #t)))
1712 (file-name (git-file-name name version))
1713 (sha256
1714 (base32 "0r7n3a6bvcxkbpda4mwmrpicii09iql5z69nkjqygkwxw7ny3309"))))
1715 (build-system gnu-build-system)
1716 (arguments
1717 (list
1718 #:tests? #f ; No tests.
1719 #:make-flags
1720 #~(list
1721 (string-append "PREFIX=" #$output)
1722 (format #f "MANPAGE_XSL=~a/xml/xsl/~a-~a/manpages/docbook.xsl"
1723 #$(this-package-native-input "docbook-xsl")
1724 #$(package-name
1725 (this-package-native-input "docbook-xsl"))
1726 #$(package-version
1727 (this-package-native-input "docbook-xsl"))))
1728 #:phases
1729 #~(modify-phases %standard-phases
1730 (delete 'configure)
1731 (add-before 'install 'fix-directory-creation
1732 (lambda _
1733 (mkdir-p (string-append #$output "/share/man/man1")))))))
1734 (inputs
1735 (list giflib libjpeg-turbo libpng
1736 perl))
1737 (native-inputs
1738 (list docbook-xml-4.2 docbook-xsl
1739 libxslt pkg-config))
1740 (home-page "https://www.complang.tuwien.ac.at/schani/metapixel/")
1741 (synopsis "Photomosaics generator")
1742 (description "Metapixel is a program for generating photomosaics. It can
1743generate classical photomosaics, in which the source image is viewed as a
1744matrix of equally sized rectangles for each of which a matching image is
1745substituted, as well as collage-style photomosaics, in which rectangular parts
1746of the source image at arbitrary positions (i.e. not aligned to a matrix) are
1747substituted by matching images.")
1748 (license license:gpl2))))
1749
1750(define-public scantailor-advanced
1751 (let ((commit "3d1e74e6ace413733511086934a66f4e3f7a6027"))
1752 (package
1753 (name "scantailor-advanced")
1754 (version (string-append "1.0.16-" (string-take commit 7)))
1755 (source
1756 (origin
1757 (method git-fetch)
1758 (uri (git-reference
1759 (url "https://github.com/4lex4/scantailor-advanced")
1760 (commit commit)))
1761 (file-name (git-file-name name version))
1762 (sha256
1763 (base32
1764 "0kixwjb2x457dq7927hkh34c803p7yh1pmn6n61rk9shqrcg492h"))))
1765 (build-system qt-build-system)
1766 (native-inputs
1767 (list qttools-5))
1768 (inputs
1769 `(("boost" ,boost)
1770 ("libjpeg" ,libjpeg-turbo)
1771 ("libpng" ,libpng)
1772 ("libtiff" ,libtiff)
1773 ("qtbase" ,qtbase-5)
1774 ("qtsvg-5" ,qtsvg-5)
1775 ("qtwayland-5" ,qtwayland-5)
1776 ("zlib" ,zlib)))
1777 (arguments
1778 `(#:phases
1779 (modify-phases %standard-phases
1780 ;; Some tests require a display and fail with offscreen mode.
1781 (add-after 'unpack 'disable-failing-tests
1782 (lambda _
1783 (setenv "ARGS" "--exclude-regex \"imageproc_.*\"")
1784 #t)))))
1785 (home-page "https://github.com/4lex4/scantailor-advanced")
1786 (synopsis "Clean up scanned pages")
1787 (description "Scan Tailor is an interactive post-processing tool for
1788scanned pages. It performs operations such as page splitting, deskewing,
1789adding/removing borders, and others. You give it raw scans, and you get pages
1790ready to be printed or assembled into a PDF or DJVU file. Scanning, optical
1791character recognition, and assembling multi-page documents are out of scope of
1792this project.
1793
1794Scan Tailer Advanced is a fork of Scan Tailer that merges Scan Tailor Featured
1795and Scan Tailor Enhanced versions as well as including many more bug fixes.")
1796 (license license:gpl3+))))
1797
1798(define-public simpleitk
1799 (package
1800 (name "simpleitk")
1801 (version "2.5.2")
1802 (source
1803 (origin
1804 (method git-fetch)
1805 (uri (git-reference
1806 (url "https://github.com/SimpleITK/SimpleITK")
1807 (commit (string-append "v" version))))
1808 (file-name (git-file-name name version))
1809 (sha256
1810 (base32 "1ykrfrfh2012cg1122689w23pan2y731sszfpb701zhsb6fwv7j7"))))
1811 (build-system cmake-build-system)
1812 (outputs '("out" "python" "r"))
1813 (arguments
1814 (list
1815 #:configure-flags
1816 #~(list "-DBUILD_SHARED_LIBS=ON"
1817 "-DWRAP_LUA=OFF"
1818 "-DWRAP_PYTHON=ON"
1819 "-DWRAP_R=ON"
1820 "-DSimpleITK_PYTHON_USE_VIRTUALENV=OFF")
1821 #:phases
1822 #~(modify-phases %standard-phases
1823 (add-after 'unpack 'early-GTest-discovery
1824 (lambda _
1825 ;; Find GTest before targets link to 'GTest::GTest'.
1826 (substitute* "Testing/Unit/CMakeLists.txt"
1827 (("add_subdirectory\\(TestBase\\)" anchor)
1828 (string-append "find_package(GTest REQUIRED)\n" anchor)))))
1829 (add-after 'unpack 'extract-test-data
1830 (lambda _
1831 (invoke "tar" "xvf"
1832 #$(this-package-native-input
1833 (string-append "SimpleITKData-" version ".tar.gz"))
1834 "--strip-components=1")))
1835 (add-after 'unpack 'fix-runpath
1836 (lambda _
1837 ;; The SWIG-generated shared libraries do not have SimpleITK's
1838 ;; libraries in their RUNPATH.
1839 (define (cmake-snippet start)
1840 (string-append
1841 start
1842 "set_target_properties(${SWIG_MODULE_SimpleITK_TARGET_NAME} "
1843 "PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE "
1844 "INSTALL_RPATH \"" #$output "/lib\")\n"))
1845 (substitute* "Wrapping/Python/CMakeLists.txt"
1846 (("^set\\(SWIG_MODULE_SimpleITKPython.*" anchor)
1847 (cmake-snippet anchor)))
1848 (substitute* "Wrapping/R/CMakeLists.txt"
1849 (("^set\\(SWIG_MODULE_SimpleITKR.*" anchor)
1850 (cmake-snippet anchor)))))
1851 (add-after 'unpack 'patch-cmake-config-itk-path
1852 (lambda _
1853 ;; Allow building SimpleITK C++ projects without ITK installed
1854 ;; in the profile.
1855 #$(let*
1856 ((itk (this-package-input "insight-toolkit"))
1857 (itk-version (package-version itk))
1858 (itk-version-major+minor
1859 (version-major+minor itk-version)))
1860 #~(substitute* "SimpleITKConfig.cmake.in"
1861 (((string-append
1862 "find_package\\(ITK \"@ITK_VERSION@\" "
1863 "EXACT REQUIRED\\)"))
1864 (string-append
1865 "find_package(ITK \"" #$itk-version
1866 "\" EXACT REQUIRED PATHS " #$itk
1867 "/lib/cmake/ITK-"
1868 #$itk-version-major+minor ")"))))))
1869 (add-after 'install 'install-language-extension-modules
1870 (lambda _
1871 (with-directory-excursion "Wrapping/Python"
1872 (invoke "python3" "setup.py" "bdist_wheel")
1873 (apply invoke "pip" "--no-cache-dir" "--no-input" "install"
1874 "--no-deps" "--prefix" #$output:python
1875 (find-files "dist" "\\.whl$")))
1876 (let ((r-package-path
1877 (string-append #$output:r "/site-library/SimpleITK")))
1878 (mkdir-p r-package-path)
1879 (copy-recursively "Wrapping/R/R_libs/SimpleITK"
1880 r-package-path))))
1881 (delete 'check)
1882 (add-after 'install 'check-after-install
1883 ;; Run the tests when the SimpleITK libraries are where the
1884 ;; language extension modules expect them to be.
1885 (assoc-ref %standard-phases 'check)))))
1886 (home-page "https://simpleitk.org")
1887 (inputs (list insight-toolkit python r-minimal))
1888 (native-inputs
1889 (list googletest
1890 lua
1891 nss-certs-for-test ;for 'pip install'
1892 python-numpy ;for tests
1893 python-pip
1894 python-setuptools
1895 python-wheel
1896 swig-next
1897 (origin
1898 (method url-fetch)
1899 (uri (string-append
1900 "https://github.com/SimpleITK/SimpleITK/releases/download/v"
1901 version "/SimpleITKData-" version ".tar.gz"))
1902 (sha256
1903 (base32
1904 "13y44qqsgsvbrm84073i8clhggdgk8f36i6102sjg4j3fq790gal")))))
1905 (synopsis "Simplified interface to @acronym{ITK, Insight Toolkit}")
1906 (description
1907 "SimpleITK is an image analysis toolkit built on top of @acronym{ITK,
1908Insight Toolkit}. It provides a simplified interface to most of the
1909image filters and the input/output and registration frameworks in
1910@acronym{ITK, Insight Toolkit}. It is written in C++ and provides
1911bindings for interpreted languages. This package includes the C++,
1912Python and R interfaces.")
1913 (license license:asl2.0)))
1914
1915(define-public stiff
1916 (package
1917 (name "stiff")
1918 (version "2.4.0")
1919 (source
1920 (origin
1921 (method url-fetch)
1922 (uri (string-append "https://www.astromatic.net/download/stiff/stiff-"
1923 version ".tar.gz"))
1924 (sha256
1925 (base32 "14m92dskzw7bwsr64ha4p0mj3ndv13gwcbfic3qxrs3zq5353s7l"))))
1926 (build-system gnu-build-system)
1927 (inputs
1928 (list libtiff zlib libjpeg-turbo))
1929 (home-page "https://www.astromatic.net/software/stiff")
1930 (synopsis "Convert scientific FITS images to TIFF format")
1931 (description
1932 "STIFF is a program that converts scientific @acronym{FITS, Flexible Image
1933Transport System} images to the more popular TIFF format for illustration
1934purposes.")
1935 (license license:gpl3+)))
1936
1937(define-public python-imgviz
1938 (package
1939 (name "python-imgviz")
1940 (version "1.7.6")
1941 (source
1942 (origin
1943 ;; PyPi tarball lacks tests.
1944 (method git-fetch)
1945 (uri (git-reference
1946 (url "https://github.com/wkentaro/imgviz")
1947 (commit (string-append "v" version))))
1948 (file-name (git-file-name name version))
1949 (sha256
1950 (base32 "0z7nwnvqh3hbbccf7v56398aiiwqs68kyrgc5vsmmh1cp4pwrgnb"))))
1951 (build-system pyproject-build-system)
1952 (arguments
1953 (list #:phases
1954 #~(modify-phases %standard-phases
1955 ;; LookupError: Error getting the version from source `vcs`:
1956 ;; setuptools-scm was unable to detect version for <...>
1957 (add-after 'unpack 'pretend-version
1958 (lambda _
1959 (setenv "SETUPTOOLS_SCM_PRETEND_VERSION" #$version))))))
1960 (native-inputs
1961 (list python-pytest
1962 python-hatchling
1963 python-hatch-vcs
1964 python-hatch-fancy-pypi-readme))
1965 (propagated-inputs
1966 (list python-matplotlib
1967 python-numpy
1968 python-pillow
1969 python-pyyaml))
1970 (home-page "http://github.com/wkentaro/imgviz")
1971 (synopsis "Image Visualization Tools")
1972 (description "Python library for object detection, semantic and instance
1973segmentation.")
1974 (license license:expat)))
1975
1976(define-public python-pims
1977 (package
1978 (name "python-pims")
1979 (version "0.7")
1980 (source
1981 (origin
1982 (method url-fetch)
1983 (uri (pypi-uri "pims" version))
1984 (sha256
1985 (base32 "0swlh8g4kf8p24g0ghkmwcj9y45rc59lmqx459nhhmhj6167m42m"))))
1986 (build-system pyproject-build-system)
1987 (arguments
1988 (list
1989 #:test-flags
1990 ;; We don't have all the (sometimes very large) data files, so we skip
1991 ;; these tests.
1992 '(list "--ignore=pims/tests/test_common.py"
1993 "--ignore=pims/tests/test_imseq.py"
1994 "--ignore=pims/tests/test_norpix.py")
1995 #:phases
1996 #~(modify-phases %standard-phases
1997 (add-after 'unpack 'relax-requirements
1998 (lambda _
1999 (substitute* "setup.py"
2000 (("'slicerator>=.*',")
2001 "'slicerator',")))))))
2002 (native-inputs
2003 (list python-pytest python-setuptools))
2004 (propagated-inputs
2005 (list python-imageio python-numpy python-slicerator))
2006 (home-page "https://github.com/soft-matter/pims")
2007 (synopsis "Python Image Sequence")
2008 (description "Scientific video can be packaged in various ways: familiar
2009video formats like @file{.AVI} and @file{.MOV}, folders full of numbered
2010images, or \"stacks\" of TIFF images. Each of these requires a separate
2011Python module. And, once loaded, they have different methods for accessing
2012individual images, looping through the images in bulk, accessing a specific
2013range, or dealing with multidimensional files. PIMS can do all of these using
2014a consistent interface, handling the differences between different inputs
2015invisibly.")
2016 (license license:bsd-3)))
2017
2018(define-public python-spatial-image
2019 (package
2020 (name "python-spatial-image")
2021 (version "1.0.0")
2022 (source
2023 (origin
2024 (method url-fetch)
2025 (uri (pypi-uri "spatial_image" version))
2026 (sha256
2027 (base32 "0blyjwgv6bqpg7r3f4dcs7x27ysfm8n9y0zk5j7dxj74lma3wdsm"))))
2028 (build-system pyproject-build-system)
2029 (propagated-inputs (list python-numpy python-pytest python-pytest-mypy
2030 python-xarray python-xarray-dataclasses))
2031 (native-inputs (list python-flit-core python-pytest))
2032 (home-page "https://github.com/spatial-image/spatial-image")
2033 (synopsis "Multi-dimensional spatial image data structure")
2034 (description "This package implements a multi-dimensional spatial image
2035data structure for scientific Python.
2036
2037To facilitate:
2038
2039@itemize
2040@item Multi-scale processing and analysis
2041@item Registration
2042@item Resampling
2043@item Subregion parallel processing
2044@item Coupling with meshes, point sets, and annotations
2045@end itemize
2046
2047with scientific images, which are typically multi-dimensional with anisotropic
2048sampling, this package provides a spatial-image data structure. In addition
2049to an N-dimensional array of pixel values, spatial metadata defines the
2050location of the pixel sampling grid in space time. It also labels the array
2051dimensions. This metadata is easily utilized and carried through image
2052processing pipelines.")
2053 (license license:expat)))
2054
2055(define-public labelme
2056 (package
2057 (name "labelme")
2058 ;; It's the latest available version which does not require not packaged
2059 ;; <https://github.com/wkentaro/osam>.
2060 (version "5.2.1")
2061 (source
2062 (origin
2063 ;; PyPi tarball lacks tests.
2064 (method git-fetch)
2065 (uri (git-reference
2066 (url "https://github.com/wkentaro/labelme")
2067 (commit (string-append "v" version))))
2068 (file-name (git-file-name name version))
2069 (sha256
2070 (base32 "1xpyad6rlkxyx51jaai4xhdy15k1gvm62xnkjn152hc1vj1c77sr"))))
2071 (build-system pyproject-build-system)
2072 (arguments
2073 (list
2074 #:test-flags
2075 #~(list "-m" "not gpu"
2076 ;; Fails when invoking help2man for unknown reason.
2077 "--ignore=tests/docs_tests/man_tests/test_labelme_1.py")
2078 #:phases
2079 #~(modify-phases %standard-phases
2080 (add-before 'check 'start-xserver
2081 (lambda* (#:key inputs #:allow-other-keys)
2082 (let ((xorg-server #$(this-package-native-input "xorg-server")))
2083 ;; Options taken from CI workflow.
2084 (system (string-append xorg-server "/bin/Xvfb :99 -screen 0 "
2085 "1920x1200x24 -ac +extension GLX +render "
2086 "-noreset &"))
2087 (setenv "DISPLAY" ":99.0")))))))
2088 (native-inputs
2089 (list python-pytest
2090 python-pytest-qt
2091 python-setuptools
2092 xorg-server-for-tests))
2093 (propagated-inputs
2094 (list python-imgviz
2095 python-matplotlib
2096 python-natsort
2097 python-numpy
2098 python-pillow
2099 python-pyqt
2100 python-pyyaml
2101 python-qtpy
2102 python-termcolor))
2103 (home-page "https://github.com/wkentaro/labelme")
2104 (synopsis "Image Polygonal Annotation")
2105 (description
2106 "Image and video labeling tool supporting different shapes like polygons,
2107rectangles, circles, lines, points and VOC/COCO export.")
2108 (license license:gpl3+)))
2109
2110(define-public charls
2111 (package
2112 (name "charls")
2113 (version "2.4.2")
2114 (source (origin
2115 (method git-fetch)
2116 (uri (git-reference
2117 (url "https://github.com/team-charls/charls/")
2118 (commit (string-append version))))
2119 (file-name (git-file-name name version))
2120 (sha256
2121 (base32
2122 "0vp6mjjm6hi2r1swwvbg86asvn604w58nam7yvqk1qr13aizjl71"))))
2123 (build-system cmake-build-system)
2124 (arguments
2125 `(#:configure-flags '("-DCMAKE_BUILD_TYPE:STRING=Release"
2126 "-DBUILD_SHARED_LIBS=On")))
2127 (native-inputs (list git pkg-config))
2128 (home-page "https://github.com/team-charls/charls")
2129 (synopsis "Library for using JPEG-LS compliant images")
2130 (description
2131 "CharLS is a codec library that can be used to build applications that
2132can handle JPEG-LS compliant images. In the application you are writing you
2133can call the CharLS codec and pass it images (sometimes called raster bitmaps),
2134 to have them encoded to JPEG-LS, or JPEG-LS streams, which CharLS will decode
2135to images.")
2136 (license license:bsd-3)))
2137
2138(define-public libansilove
2139 (package
2140 (name "libansilove")
2141 (version "1.4.1")
2142 (source (origin
2143 (method git-fetch)
2144 (uri (git-reference
2145 (url "https://github.com/ansilove/libansilove")
2146 (commit (string-append version))))
2147 (file-name (git-file-name name version))
2148 (sha256
2149 (base32
2150 "169njlck4a2bmf1kmjas1w594hyda543ykdnwg7fwkviij39l9z6"))))
2151 (build-system cmake-build-system)
2152 (arguments
2153 (list #:tests? #f)) ; No tests included
2154 (native-inputs
2155 (list gd))
2156 (home-page "https://www.ansilove.org/")
2157 (synopsis "Library for converting ANSI, ASCII, and other formats to PNG")
2158 (description
2159 "libansilove is a library for converting artscene file types to PNG images,
2160including ANSI (.ANS) and many others. The library primarily serves to support
2161the ansilove tool.")
2162 (license license:bsd-2)))
2163
2164(define-public ansilove
2165 (package
2166 (name "ansilove")
2167 (version "4.2.0")
2168 (source (origin
2169 (method git-fetch)
2170 (uri (git-reference
2171 (url "https://github.com/ansilove/ansilove")
2172 (commit (string-append version))))
2173 (file-name (git-file-name name version))
2174 (sha256
2175 (base32
2176 "1h9r759krjl8wi68yxs1d46qfrx6v89a8vmmv3aqym8vn9x430kh"))))
2177 (build-system cmake-build-system)
2178 (native-inputs
2179 (list libansilove))
2180 (home-page "https://www.ansilove.org/")
2181 (synopsis "ANSI and ASCII art to PNG converter")
2182 (description
2183 "AnsiLove is an ANSI and ASCII art to PNG converter, allowing to convert
2184ANSI and artscene-related file formats into PNG images, supporting ANSI (.ANS),
2185PCBoard (.PCB), Binary (.BIN), Artworx (.ADF), iCE Draw (.IDF), Tundra (.TND)
2186and XBin (.XB) formats.")
2187 (license license:bsd-2)))