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 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, 2019 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 Efraim Flashner <efraim@flashner.co.il>
11 ;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
12 ;;; Copyright © 2020 Vinicius Monego <monego@posteo.net>
13 ;;; Copyright © 2020 Pierre Neidhardt <mail@ambrevar.xyz>
15 ;;; This file is part of GNU Guix.
17 ;;; GNU Guix is free software; you can redistribute it and/or modify it
18 ;;; under the terms of the GNU General Public License as published by
19 ;;; the Free Software Foundation; either version 3 of the License, or (at
20 ;;; your option) any later version.
22 ;;; GNU Guix is distributed in the hope that it will be useful, but
23 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;;; GNU General Public License for more details.
27 ;;; You should have received a copy of the GNU General Public License
28 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
30 (define-module (gnu packages image-processing)
31 #:use-module ((guix licenses) #:prefix license:)
32 #:use-module (guix packages)
33 #:use-module (guix utils)
34 #:use-module (guix download)
35 #:use-module (guix git-download)
36 #:use-module (guix build-system cmake)
37 #:use-module (guix build-system gnu)
38 #:use-module (gnu packages)
39 #:use-module (gnu packages algebra)
40 #:use-module (gnu packages bison)
41 #:use-module (gnu packages boost)
42 #:use-module (gnu packages check)
43 #:use-module (gnu packages compression)
44 #:use-module (gnu packages curl)
45 #:use-module (gnu packages docbook)
46 #:use-module (gnu packages documentation)
47 #:use-module (gnu packages flex)
48 #:use-module (gnu packages fontutils)
49 #:use-module (gnu packages geo)
50 #:use-module (gnu packages ghostscript)
51 #:use-module (gnu packages gl)
52 #:use-module (gnu packages glib)
53 #:use-module (gnu packages gnome)
54 #:use-module (gnu packages graphics)
55 #:use-module (gnu packages graphviz)
56 #:use-module (gnu packages gstreamer)
57 #:use-module (gnu packages gtk)
58 #:use-module (gnu packages image)
59 #:use-module (gnu packages imagemagick)
60 #:use-module (gnu packages maths)
61 #:use-module (gnu packages pdf)
62 #:use-module (gnu packages perl)
63 #:use-module (gnu packages photo)
64 #:use-module (gnu packages pkg-config)
65 #:use-module (gnu packages protobuf)
66 #:use-module (gnu packages python)
67 #:use-module (gnu packages python-xyz)
68 #:use-module (gnu packages qt)
69 #:use-module (gnu packages serialization)
70 #:use-module (gnu packages tbb)
71 #:use-module (gnu packages tls)
72 #:use-module (gnu packages video)
73 #:use-module (gnu packages xiph)
74 #:use-module (gnu packages xml)
75 #:use-module (gnu packages xorg)
76 #:use-module (ice-9 match)
77 #:use-module (srfi srfi-1))
87 (string-append "ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/"
88 "dcmtk" (string-join (string-split version #\.) "")
89 "/dcmtk-" version ".tar.gz"))
91 (base32 "1fdyz5wwjp4grys61mxb2ia9fi6i3ax6s43l16xnv291bxk7hld0"))))
92 (build-system cmake-build-system)
94 `(;; Our ICU is too recent: “error: ‘UChar’ does not name a type“.
96 ("libjpeg" ,libjpeg-turbo)
103 `(("doxygen" ,doxygen))) ; for HTML documentation
104 (home-page "https://dcmtk.org")
105 (synopsis "Libraries and programs implementing parts of the DICOM standard")
106 (description "DCMTK is a collection of libraries and applications
107 implementing large parts the DICOM standard. It includes software for
108 examining, constructing and converting DICOM image files, handling offline
109 media, sending and receiving images over a network connection, as well as
110 demonstrative image storage and worklist servers.")
111 (license (license:fsf-free
113 "A union of the Apache 2.0 licence and various non-copyleft
114 licences similar to the Modified BSD licence."))))
122 (uri (string-append "mirror://sourceforge/mia/mia/"
123 (version-major+minor version)
124 "/mia-" version ".tar.xz"))
127 "0j4nd5z7i3v199jh7hqqhwd4g7snchizkc7rhzanpvngqg91m1pb"))))
128 (build-system cmake-build-system)
131 (list "-DMIA_CREATE_NIPYPE_INTERFACES=0"
132 "-DCMAKE_CXX_FLAGS=-fpermissive")))
144 ("libjpeg" ,libjpeg-turbo)
148 ("libxml++" ,libxml++)
150 ("niftilib" ,niftilib)
153 ("python-lxml" ,python2-lxml)
156 `(("pkg-config" ,pkg-config)
157 ("python" ,python-2)))
158 (home-page "http://mia.sourceforge.net")
159 (synopsis "Toolkit for gray scale medical image analysis")
160 (description "MIA provides a combination of command line tools, plug-ins,
161 and libraries that make it possible run image processing tasks interactively
162 in a command shell and to prototype using the shell's scripting language. It
163 is built around a plug-in structure that makes it easy to add functionality
164 without compromising the original code base and it makes use of a wide variety
165 of external libraries that provide additional functionality.")
166 (license license:gpl3+)))
174 (uri (string-append "https://vtk.org/files/release/"
175 (version-major+minor version)
176 "/VTK-" version ".tar.gz"))
179 "1fspgp8k0myr6p2a6wkc21ldcswb4bvmb484m12mxgk1a9vxrhrl"))))
180 (build-system cmake-build-system)
182 '(#:build-type "Release" ;Build without '-g' to save space.
183 ;; -DVTK_USE_SYSTEM_NETCDF:BOOL=TRUE requires netcdf_cxx
184 #:configure-flags '("-DVTK_USE_SYSTEM_EXPAT:BOOL=TRUE"
185 "-DVTK_USE_SYSTEM_FREETYPE:BOOL=TRUE"
186 "-DVTK_USE_SYSTEM_HDF5:BOOL=TRUE"
187 "-DVTK_USE_SYSTEM_JPEG:BOOL=TRUE"
188 "-DVTK_USE_SYSTEM_JSONCPP:BOOL=TRUE"
189 "-DVTK_USE_SYSTEM_LIBXML2:BOOL=TRUE"
190 "-DVTK_USE_SYSTEM_OGGTHEORA:BOOL=TRUE"
191 "-DVTK_USE_SYSTEM_PNG:BOOL=TRUE"
192 "-DVTK_USE_SYSTEM_TIFF:BOOL=TRUE"
193 "-DVTK_USE_SYSTEM_ZLIB:BOOL=TRUE")
194 #:tests? #f)) ;XXX: no "test" target
197 ("xorgproto" ,xorgproto)
203 ("freetype" ,freetype)
205 ("jpeg" ,libjpeg-turbo)
208 ("libtheora" ,libtheora)
212 (home-page "https://vtk.org/")
213 (synopsis "Libraries for 3D computer graphics")
215 "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
216 image processing and visualization. It supports a wide variety of
217 visualization algorithms including: scalar, vector, tensor, texture, and
218 volumetric methods; and advanced modeling techniques such as: implicit
219 modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay
220 triangulation. VTK has an extensive information visualization framework, has
221 a suite of 3D interaction widgets, supports parallel processing, and
222 integrates with various databases on GUI toolkits such as Qt and Tk.")
223 (license license:bsd-3)))
225 ;; itksnap needs an older variant of VTK.
227 (package (inherit vtk)
231 (uri (string-append "https://vtk.org/files/release/"
232 (version-major+minor version)
233 "/VTK-" version ".tar.gz"))
236 "0pla1r5mvkgl4sl213gfdhzrypdgai0h3z5mfgm6p9jz9hsr794j"))))
238 `(("jsoncpp" ,jsoncpp-for-tensorflow)
239 ,@(alist-delete "jsoncpp" (package-inputs vtk))))))
241 (define-public opencv
248 (url "https://github.com/opencv/opencv")
250 (file-name (git-file-name name version))
253 "06bc61r8myym4s8im10brdjfg4wxkrvsbhhl7vr1msdan2xddzi3"))
254 (modules '((guix build utils)))
257 ;; Remove external libraries. We have all available in Guix:
258 (delete-file-recursively "3rdparty")
260 ;; Milky icon set is non-free:
261 (delete-file-recursively "modules/highgui/src/files_Qt/Milky")
264 (for-each delete-file
265 '("modules/java/test/pure_test/lib/junit-4.11.jar"
266 "samples/java/sbt/sbt/sbt-launch.jar"))
268 (build-system cmake-build-system)
271 (list "-DWITH_IPP=OFF"
273 "-DWITH_CAROTENE=OFF" ; only visible on arm/aarch64
274 "-DENABLE_PRECOMPILED_HEADERS=OFF"
277 ;; See cmake/OpenCVCompilerOptimizations.cmake
278 ;; (CPU_ALL_OPTIMIZATIONS) for a list of all optimizations
279 ;; BASELINE is the minimum optimization all CPUs must support
281 ;; DISPATCH is the list of optional dispatches.
282 "-DCPU_BASELINE=SSE2"
284 ,@(match (%current-system)
286 '("-DCPU_DISPATCH=NEON;VFPV3;FP16;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX"
287 "-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2"))
289 '("-DCPU_BASELINE_DISABLE=NEON")) ; causes build failures
291 '("-DCPU_BASELINE=NEON"
292 "-DCPU_DISPATCH=NEON;VFPV3;FP16"))
295 "-DBUILD_PERF_TESTS=OFF"
298 (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
299 "/opencv-contrib/modules")
302 (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
303 "/opencv-extra/testdata")
305 ;; Is ON by default and would try to rebuild 3rd-party protobuf,
306 ;; which we had removed, which would lead to an error:
307 "-DBUILD_PROTOBUF=OFF"
309 ;; Rebuild protobuf files, because we have a slightly different
310 ;; version than the included one. If we would not update, we
311 ;; would get a compile error later:
312 "-DPROTOBUF_UPDATE_FILES=ON"
314 ;; xfeatures2d disabled, because it downloads extra binaries from
315 ;; https://github.com/opencv/opencv_3rdparty
316 ;; defined in xfeatures2d/cmake/download_{vgg|bootdesc}.cmake
317 ;; Cmp this bug entry:
318 ;; https://github.com/opencv/opencv_contrib/issues/1131
319 "-DBUILD_opencv_xfeatures2d=OFF")
321 (modify-phases %standard-phases
322 (add-after 'unpack 'disable-broken-tests
324 ;; These tests fails with:
325 ;; vtkXOpenGLRenderWindow (0x723990): Could not find a decent config
326 ;; I think we have no OpenGL support with the Xvfb.
327 (substitute* '("modules/viz/test/test_tutorial3.cpp"
328 "modules/viz/test/test_main.cpp"
329 "modules/viz/test/tests_simple.cpp"
330 "modules/viz/test/test_viz3d.cpp")
331 (("(TEST\\(Viz, )([a-z].*\\).*)" all pre post)
332 (string-append pre "DISABLED_" post)))
334 ;; This one fails with "unknown file: Failure"
335 ;; But I couldn't figure out which file was missing:
336 (substitute* "../opencv-contrib/modules/face/test/test_face_align.cpp"
337 (("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)"
339 (string-append pre "DISABLED_" post)))
341 ;; Failure reason: Bad accuracy
342 ;; Incorrect count of accurate poses [2nd case]: 90.000000 / 94.000000
343 (substitute* "../opencv-contrib/modules/rgbd/test/test_odometry.cpp"
344 (("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post)
345 (string-append pre "DISABLED_" post)))
348 (add-after 'unpack 'unpack-submodule-sources
349 (lambda* (#:key inputs #:allow-other-keys)
350 (mkdir "../opencv-extra")
351 (mkdir "../opencv-contrib")
352 (copy-recursively (assoc-ref inputs "opencv-extra")
355 (assoc-ref inputs "opencv-contrib")
356 "--strip-components=1"
357 "-C" "../opencv-contrib")))
359 (add-after 'set-paths 'add-ilmbase-include-path
360 (lambda* (#:key inputs #:allow-other-keys)
361 ;; OpenEXR propagates ilmbase, but its include files do not appear
362 ;; in the CPATH, so we need to add "$ilmbase/include/OpenEXR/" to
363 ;; the CPATH to satisfy the dependency on "ImathVec.h".
365 (string-append (assoc-ref inputs "ilmbase")
367 ":" (or (getenv "CPATH") "")))
369 (add-before 'check 'start-xserver
370 (lambda* (#:key inputs #:allow-other-keys)
371 (let ((xorg-server (assoc-ref inputs "xorg-server"))
373 (setenv "HOME" (getcwd))
374 (setenv "DISPLAY" disp)
375 ;; There must be a running X server and make check doesn't start one.
376 ;; Therefore we must do it.
377 (zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp)))))))))
379 `(("pkg-config" ,pkg-config)
380 ("xorg-server" ,xorg-server-for-tests) ; For running the tests
385 (url "https://github.com/opencv/opencv_extra")
387 (file-name (git-file-name "opencv_extra" version))
389 (base32 "08p5xnq8n1jw8svvz0fnirfg7q8dm3p4a5dl7527s5xj0f9qn7lp"))))
394 (url "https://github.com/opencv/opencv_contrib")
396 (file-name (git-file-name "opencv_contrib" version))
397 (patches (search-patches "opencv-rgbd-aarch64-test-fix.patch"))
399 (base32 "1f334glf39nk42mpqq6j732h3ql2mpz89jd4mcl678s8n73nfjh2"))))))
400 (inputs `(("libjpeg" ,libjpeg-turbo)
403 ;; ffmpeg 4.0 causes core dumps in tests.
404 ("ffmpeg" ,ffmpeg-3.4)
407 ("libgphoto2" ,libgphoto2)
410 ("gtkglext" ,gtkglext)
414 ("python-numpy" ,python-numpy)
415 ("protobuf" ,protobuf)
418 ;; These three CVEs are not a problem of OpenCV, see:
419 ;; https://github.com/opencv/opencv/issues/10998
420 (properties '((lint-hidden-cve . ("CVE-2018-7712"
423 (synopsis "Computer vision library")
424 (description "OpenCV is a library aimed at
425 real-time computer vision, including several hundred computer
426 vision algorithms. It can be used to do things like:
429 @item image and video input and output
430 @item image and video processing
432 @item feature recognition
434 @item facial recognition
436 @item structure from motion
437 @item augmented reality
438 @item machine learning
440 (home-page "https://opencv.org/")
441 (license license:bsd-3)))
451 "https://github.com/libvips/libvips/releases/download/v"
452 version "/vips-" version ".tar.gz"))
454 (base32 "01gjhcrl6zj7mcj1al717v5jsniahplqhz1xkfh2j78vyfl1hxff"))))
455 (build-system gnu-build-system)
457 `(("pkg-config" ,pkg-config)
458 ("gobject-introspection" ,gobject-introspection)))
461 ("libjpeg" ,libjpeg-turbo)
474 ("niftilib" ,niftilib)
477 ("imagemagick" ,imagemagick)
481 (home-page "https://libvips.github.io/libvips/")
482 (synopsis "Multithreaded image processing system with low memory needs")
484 "VIPS is a demand-driven, horizontally threaded image processing library.
485 It's particularly good at processing large images, working with colour,
486 scientific analysis, and general research & development.
488 Compared to most image processing libraries VIPS needs little RAM and runs
489 quickly, especially on machines with more than one CPU core. This is primarily
490 due to its architecture which automatically parallelises the image workflows.")
491 (license license:lgpl2.1+)))
500 (uri (string-append "https://gmic.eu/files/source/gmic_"
503 (base32 "13axx7nwchn6ysgpvlw3fib474q4nrwv3qn20g3q03ldid0xvjah"))))
504 (build-system cmake-build-system)
506 `(#:tests? #f)) ;there are no tests
508 `(("pkg-config" ,pkg-config)))
512 ("graphicsmagick" ,graphicsmagick)
513 ("libjpeg-turbo" ,libjpeg-turbo)
517 ;;("opencv" ,opencv) ;OpenCV is currently broken in the CI
520 (home-page "https://gmic.eu/")
521 (synopsis "Full-featured framework for digital image processing")
522 (description "G'MIC is a full-featured framework for digital image
523 processing. It provides several user interfaces to convert / manipulate
524 / filter / visualize generic image datasets, ranging from 1D scalar
525 signals to 3D+t sequences of multi-spectral volumetric images, hence
526 including 2D color images.")
527 ;; Dual-licensed, either license applies.
528 (license (list license:cecill license:cecill-c))))
537 (uri (string-append "https://github.com/libvips/nip2/releases/download/v"
538 version "/nip2-" version ".tar.gz" ))
540 (base32 "0l7n427njif53npqn02gfjjly8y3khbrkzqxp10j5vp9h97psgiw"))))
541 (build-system gnu-build-system)
544 (modify-phases %standard-phases
545 ;; test_conv.ws keep failing so disabling for now.
546 (add-after 'unpack 'disable-test-conv
548 (delete-file "test/workspaces/test_conv.ws")
550 (add-before 'check 'set-home
552 (setenv "HOME" "/tmp") #t)))))
560 ("libjpeg" ,libjpeg-turbo) ;required by vips.pc
564 ("imagemagick" ,imagemagick)
575 ("pkg-config" ,pkg-config)))
576 (home-page "https://github.com/libvips/nip2")
577 (synopsis "Spreadsheet-like GUI for libvips")
578 (description "This package provide a graphical user interface (GUI) for
579 the VIPS image processing library. It's a little like a spreadsheet: you
580 create a set of formula connecting your objects together, and on a change nip2
582 (license license:gpl2+)))
592 (url "https://github.com/vxl/vxl")
593 (commit (string-append "v" version))))
594 (file-name (git-file-name name version))
596 (base32 "0949hw57szq8943f1whwqaz591xjmb19kj803hcv74hdai2b0ycg"))
597 (modules '((guix build utils)))
598 ;; TODO: vxl includes an old version of dcmtk. It won't build with
602 (for-each delete-file-recursively
609 (substitute* "v3p/CMakeLists.txt"
610 (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
613 (build-system cmake-build-system)
615 `(("libgeotiff" ,libgeotiff)
617 ("libjpeg" ,libjpeg-turbo)
620 (home-page "https://github.com/vxl/vxl/")
621 (synopsis "Collection of C++ libraries for computer vision")
622 (description "VXL (the Vision-something-Libraries) is a collection of C++
623 libraries designed for computer vision research and implementation.")
624 (license license:bsd-3)))
627 (package (inherit vxl)
634 (url "https://github.com/vxl/vxl")
635 (commit (string-append "v" version))))
636 (file-name (git-file-name name version))
638 (base32 "1g4mr2cc58jwm0vasscbd4y5380wj3ahkvq121z4gs83fhavvxgz"))
639 (modules '((guix build utils)))
642 (for-each delete-file-recursively
648 (substitute* "v3p/CMakeLists.txt"
649 (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
654 ;; Needed for itk-snap
655 (list "-DVNL_CONFIG_LEGACY_METHODS=ON")))))
657 (define-public insight-toolkit
659 (name "insight-toolkit")
664 (uri (string-append "https://github.com/InsightSoftwareConsortium/ITK/"
665 "releases/download/v" version "/InsightToolkit-"
668 (base32 "0bs63mk4q8jmx38f031jy5w5n9yy5ng9x8ijwinvjyvas8cichqi"))))
669 (build-system cmake-build-system)
671 `(#:tests? #f ; tests require network access and external data
674 "-DITK_USE_SYSTEM_LIBRARIES=ON"
675 "-DITK_USE_SYSTEM_GOOGLETEST=ON"
676 "-DITK_BUILD_SHARED=ON"
677 ;; This prevents "GTest::GTest" from being added to the ITK_LIBRARIES
678 ;; variable in the installed CMake files. This is necessary as other
679 ;; packages using insight-toolkit could not be configured otherwise.
680 "-DGTEST_ROOT=gtest")
682 (modify-phases %standard-phases
683 (add-after 'unpack 'do-not-tune
685 (substitute* "CMake/ITKSetStandardCompilerFlags.cmake"
686 (("-mute=native") ""))
694 ("libjpeg" ,libjpeg-turbo)
697 ("mesa" ,mesa-opencl)
704 `(("googletest" ,googletest)
705 ("pkg-config" ,pkg-config)))
706 (home-page "https://github.com/InsightSoftwareConsortium/ITK/")
707 (synopsis "Scientific image processing, segmentation and registration")
708 (description "The Insight Toolkit (ITK) is a toolkit for N-dimensional
709 scientific image processing, segmentation, and registration. Segmentation is
710 the process of identifying and classifying data found in a digitally sampled
711 representation. Typically the sampled representation is an image acquired
712 from such medical instrumentation as CT or MRI scanners. Registration is the
713 task of aligning or developing correspondences between data. For example, in
714 the medical environment, a CT scan may be aligned with a MRI scan in order to
715 combine the information contained in both.")
716 (license license:asl2.0)))
718 (define-public insight-toolkit-4
719 (package (inherit insight-toolkit)
724 (uri (string-append "https://github.com/InsightSoftwareConsortium/ITK/"
725 "releases/download/v" version "/InsightToolkit-"
728 (base32 "19cgfpd63gqrvc3m27m394gy2d7w79g5y6lvznb5qqr49lihbgns"))))
730 `(#:tests? #f ; tests require network access and external data
732 '("-DITKV3_COMPATIBILITY=ON" ; needed for itk-snap
734 "-DITK_USE_SYSTEM_LIBRARIES=ON"
735 "-DITK_USE_SYSTEM_GOOGLETEST=ON"
736 "-DITK_USE_SYSTEM_VXL=ON")))))
738 (define-public insight-toolkit-4.12
739 (package (inherit insight-toolkit-4)
744 (uri (string-append "mirror://sourceforge/itk/itk/4.12/"
745 "InsightToolkit-" version ".tar.xz"))
747 (base32 "1qw9mxbh083siljygahl4gdfv91xvfd8hfl7ghwii19f60xrvn2w"))))))
749 (define-public itk-snap
757 (url "https://git.code.sf.net/p/itk-snap/src")
758 (commit (string-append "v" version))))
759 (file-name (git-file-name name version))
761 (base32 "15i5ixpryfrbf3vrrb5rici8fb585f25k0v1ljds16bp1f1msr4q"))))
762 (build-system cmake-build-system)
765 (list "-DSNAP_VERSION_GIT_SHA1=release"
766 "-DSNAP_VERSION_GIT_BRANCH=release"
767 "-DSNAP_VERSION_GIT_TIMESTAMP=0"
768 "-DSNAP_PACKAGE_QT_PLUGINS=OFF"
769 "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
771 (modify-phases %standard-phases
772 ;; During the installation phase all libraries provided by all
773 ;; dependencies will be copied to the lib directory. That's insane,
774 ;; so we disable this.
775 (add-after 'unpack 'do-not-copy-dependencies
777 (substitute* "CMakeLists.txt"
778 (("install_qt5_executable\
779 \\(\\$\\{SNAP_MAIN_INSTALL_DIR\\}/\\$\\{SNAP_EXE\\}\\)")
782 (add-after 'unpack 'disable-gui-tests
784 ;; The GUI tests just time out.
785 (substitute* "CMakeLists.txt"
786 ((" (Workspace|DiffSpace|ProbeIntensity|RegionCompetition\
787 |RandomForest|RandomForestBailOut)")
790 (add-after 'unpack 'make-reproducible
792 (substitute* "CMakeLists.txt"
793 (("TODAY\\(SNAP_VERSION_COMPILE_DATE\\)")
794 "SET(SNAP_VERSION_COMPILE_DATE \"(removed for reproducibility)\")"))
796 (add-after 'unpack 'prepare-submodules
797 (lambda* (#:key inputs #:allow-other-keys)
798 (rmdir "Submodules/c3d")
799 (copy-recursively (assoc-ref inputs "c3d-src")
801 (substitute* '("Submodules/c3d/adapters/BiasFieldCorrectionN4.cxx"
802 "Submodules/c3d/adapters/ApplyMetric.cxx")
804 (rmdir "Submodules/greedy")
805 (symlink (assoc-ref inputs "greedy-src")
808 (add-after 'unpack 'fix-includes
810 (substitute* "GUI/Model/RegistrationModel.cxx"
811 (("<vnl_symmetric_eigensystem.h>")
812 "<vnl/algo/vnl_symmetric_eigensystem.h>"))
814 (add-before 'check 'prepare-tests
816 ;; Needed by at least one test.
817 (setenv "HOME" "/tmp")
819 (add-after 'install 'wrap-executable
820 (lambda* (#:key inputs outputs #:allow-other-keys)
821 (let ((out (assoc-ref outputs "out")))
822 (wrap-program (string-append out "/bin/itksnap")
823 `("QT_PLUGIN_PATH" ":" prefix
824 ,(map (lambda (label)
825 (string-append (assoc-ref inputs label)
827 '("qtbase" "qtdeclarative"))))
835 ("mesa" ,mesa-opencl)
836 ;; This package does not build with either insight-toolkit 5.0.0 and
837 ;; not with 4.13. It really needs to be 4.12.
838 ("itk" ,insight-toolkit-4.12)
841 ("qtdeclarative" ,qtdeclarative)
845 `(("googletest" ,googletest)
847 ("pkg-config" ,pkg-config)
849 ,(let* ((commit "f521358db26e00002c911cc47bf463b043942ad3")
851 (version (git-version "0" revision commit)))
855 (url "https://github.com/pyushkevich/c3d")
857 (file-name (git-file-name "c3d" version))
860 "0kyv3rxrxwr8c3sa9zv01lsnhk95b27gx1s870k3yi8qp52h7bx3")))))
861 ;; We are using an arbitrary commit from 2017 because the latest
862 ;; version breaks the build...
864 ,(let* ((commit "97e340f7e8e66597599144947775e6039e79a0d3")
866 (version (git-version "0" revision commit)))
870 (url "https://github.com/pyushkevich/greedy")
872 (file-name (git-file-name "greedy" version))
875 "0k5bc9za4jrc8z9dj08z1rkcp5xf0gnd1d2jmi1w9ny4vxh2q2ab")))))))
876 (home-page "https://sourceforge.net/p/itk-snap/")
877 (synopsis "Medical image segmentation")
878 (description "ITK-SNAP is a tool for segmenting anatomical structures in
879 medical images. It provides an automatic active contour segmentation
880 pipeline, along with supporting a manual segmentation toolbox. ITK-SNAP has a
881 full-featured UI aimed at clinical researchers.")
882 ;; This includes the submodules greedy and c3d.
883 (license license:gpl3+)))
885 (define-public metapixel
886 ;; Follow stable branch.
887 (let ((commit "98ee9daa093b6c334941242e63f90b1c2876eb4f"))
890 (version (git-version "1.0.2" "1" commit))
895 (url "https://github.com/schani/metapixel")
897 ;; TODO: Package rwimg and lispreader?
899 (file-name (git-file-name name version))
901 (base32 "0r7n3a6bvcxkbpda4mwmrpicii09iql5z69nkjqygkwxw7ny3309"))))
902 (build-system gnu-build-system)
905 ("libjpeg" ,libjpeg-turbo)
909 `(("pkg-config" ,pkg-config)
910 ("docbook-xml" ,docbook-xml)
911 ("docbook-xsl" ,docbook-xsl)
912 ("xsltproc" ,libxslt)))
914 `(#:tests? #f ; No tests.
916 (string-append "PREFIX=" (assoc-ref %outputs "out"))
917 (string-append "MANPAGE_XSL="
918 (assoc-ref %build-inputs "docbook-xsl")
919 "/xml/xsl/docbook-xsl-*/manpages/docbook.xsl"))
921 (modify-phases %standard-phases
923 (add-before 'install 'make-local-docbook-xml
924 (lambda* (#:key inputs #:allow-other-keys)
925 (substitute* "metapixel.xml"
926 (("http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd")
927 (string-append (assoc-ref inputs "docbook-xml")
928 "/xml/dtd/docbook/docbookx.dtd")))
930 (add-before 'install 'fix-directory-creation
931 (lambda* (#:key outputs #:allow-other-keys)
932 (mkdir-p (string-append (assoc-ref outputs "out") "/share/man/man1"))
934 (home-page "https://www.complang.tuwien.ac.at/schani/metapixel/")
935 (synopsis "Photomosaics generator")
936 (description "Metapixel is a program for generating photomosaics. It can
937 generate classical photomosaics, in which the source image is viewed as a
938 matrix of equally sized rectangles for each of which a matching image is
939 substitued, as well as collage-style photomosaics, in which rectangular parts
940 of the source image at arbitrary positions (i.e. not aligned to a matrix) are
941 substituted by matching images.")
942 (license license:gpl2))))