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, 2020 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>
14 ;;; Copyright © 2020 Brendan Tildesley <mail@brendan.scot>
16 ;;; This file is part of GNU Guix.
18 ;;; GNU Guix is free software; you can redistribute it and/or modify it
19 ;;; under the terms of the GNU General Public License as published by
20 ;;; the Free Software Foundation; either version 3 of the License, or (at
21 ;;; your option) any later version.
23 ;;; GNU Guix is distributed in the hope that it will be useful, but
24 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
25 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 ;;; GNU General Public License for more details.
28 ;;; You should have received a copy of the GNU General Public License
29 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
31 (define-module (gnu packages image-processing)
32 #:use-module ((guix licenses) #:prefix license:)
33 #:use-module (guix packages)
34 #:use-module (guix utils)
35 #:use-module (guix download)
36 #:use-module (guix git-download)
37 #:use-module (guix build-system qt)
38 #:use-module (guix build-system cmake)
39 #:use-module (guix build-system gnu)
40 #:use-module (gnu packages)
41 #:use-module (gnu packages algebra)
42 #:use-module (gnu packages bison)
43 #:use-module (gnu packages boost)
44 #:use-module (gnu packages check)
45 #:use-module (gnu packages compression)
46 #:use-module (gnu packages curl)
47 #:use-module (gnu packages docbook)
48 #:use-module (gnu packages documentation)
49 #:use-module (gnu packages flex)
50 #:use-module (gnu packages fontutils)
51 #:use-module (gnu packages geo)
52 #:use-module (gnu packages ghostscript)
53 #:use-module (gnu packages gl)
54 #:use-module (gnu packages glib)
55 #:use-module (gnu packages gnome)
56 #:use-module (gnu packages graphics)
57 #:use-module (gnu packages graphviz)
58 #:use-module (gnu packages gstreamer)
59 #:use-module (gnu packages gtk)
60 #:use-module (gnu packages image)
61 #:use-module (gnu packages imagemagick)
62 #:use-module (gnu packages maths)
63 #:use-module (gnu packages pdf)
64 #:use-module (gnu packages perl)
65 #:use-module (gnu packages photo)
66 #:use-module (gnu packages pkg-config)
67 #:use-module (gnu packages protobuf)
68 #:use-module (gnu packages python)
69 #:use-module (gnu packages python-xyz)
70 #:use-module (gnu packages qt)
71 #:use-module (gnu packages serialization)
72 #:use-module (gnu packages tbb)
73 #:use-module (gnu packages tls)
74 #:use-module (gnu packages version-control)
75 #:use-module (gnu packages video)
76 #:use-module (gnu packages xiph)
77 #:use-module (gnu packages xml)
78 #:use-module (gnu packages xorg)
79 #:use-module (ice-9 match)
80 #:use-module (srfi srfi-1))
90 (string-append "ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/"
91 "dcmtk" (string-join (string-split version #\.) "")
92 "/dcmtk-" version ".tar.gz"))
94 (base32 "1fdyz5wwjp4grys61mxb2ia9fi6i3ax6s43l16xnv291bxk7hld0"))))
95 (build-system cmake-build-system)
97 `(;; Our ICU is too recent: “error: ‘UChar’ does not name a type“.
99 ("libjpeg" ,libjpeg-turbo)
106 `(("doxygen" ,doxygen))) ; for HTML documentation
107 (home-page "https://dcmtk.org")
108 (synopsis "Libraries and programs implementing parts of the DICOM standard")
109 (description "DCMTK is a collection of libraries and applications
110 implementing large parts the DICOM standard. It includes software for
111 examining, constructing and converting DICOM image files, handling offline
112 media, sending and receiving images over a network connection, as well as
113 demonstrative image storage and worklist servers.")
114 (license (license:fsf-free
116 "A union of the Apache 2.0 licence and various non-copyleft
117 licences similar to the Modified BSD licence."))))
125 (uri (string-append "mirror://sourceforge/mia/mia/"
126 (version-major+minor version)
127 "/mia-" version ".tar.xz"))
130 "0j4nd5z7i3v199jh7hqqhwd4g7snchizkc7rhzanpvngqg91m1pb"))))
131 (build-system cmake-build-system)
134 (list "-DMIA_CREATE_NIPYPE_INTERFACES=0"
135 "-DCMAKE_CXX_FLAGS=-fpermissive")))
147 ("libjpeg" ,libjpeg-turbo)
151 ("libxml++" ,libxml++)
153 ("niftilib" ,niftilib)
156 ("python-lxml" ,python2-lxml)
159 `(("pkg-config" ,pkg-config)
160 ("python" ,python-2)))
161 (home-page "http://mia.sourceforge.net")
162 (synopsis "Toolkit for gray scale medical image analysis")
163 (description "MIA provides a combination of command line tools, plug-ins,
164 and libraries that make it possible run image processing tasks interactively
165 in a command shell and to prototype using the shell's scripting language. It
166 is built around a plug-in structure that makes it easy to add functionality
167 without compromising the original code base and it makes use of a wide variety
168 of external libraries that provide additional functionality.")
169 (license license:gpl3+)))
171 (define-public opencolorio
179 (url "https://github.com/AcademySoftwareFoundation/OpenColorIO")
180 (commit (string-append "v" version))))
182 (base32 "12srvxca51czpfjl0gabpidj9n84mw78ivxy5w75qhq2mmc798sb"))
183 (file-name (git-file-name name version))
184 (modules '((guix build utils)))
187 ;; Remove bundled tarballs, patches, and .jars(!). XXX: Upstream
188 ;; claims to have fixed USE_EXTERNAL_YAML, but it still fails with:
189 ;; https://github.com/AcademySoftwareFoundation/OpenColorIO/issues/517
190 ;; When removing it, also remove it from the licence field comment.
191 (for-each delete-file-recursively
194 (let ((file (basename full-name)))
195 (not (or (string-prefix? "yaml-cpp-0.3" file)
196 (string=? "unittest.h" file)))))
197 (find-files "ext" ".*")))
200 (build-system cmake-build-system)
203 (list (string-append "-DCMAKE_CXX_FLAGS="
204 "-Wno-error=deprecated-declarations "
205 "-Wno-error=unused-function")
206 "-DOCIO_BUILD_STATIC=OFF"
207 ;; "-DUSE_EXTERNAL_YAML=ON"
208 "-DUSE_EXTERNAL_TINYXML=ON"
209 "-DUSE_EXTERNAL_LCMS=ON")
211 (modify-phases %standard-phases
212 (add-after 'unpack 'patch-test-suite
214 (substitute* "src/core_tests/CMakeLists.txt"
215 (("/bin/sh") (which "bash")))
219 ("pkg-config" ,pkg-config)))
221 ;; XXX Adding freeglut, glew, ilmbase, mesa, and openimageio for
222 ;; ocioconvert fails: error: conflicting declaration ?typedef void
223 ;; (* PFNGLGETFRAGMENTMATERIALFVSGIXPROC)(GLenum, GLenum, GLfloat*)
226 ("tinyxml" ,tinyxml)))
227 (home-page "https://opencolorio.org")
228 (synopsis "Color management for visual effects and animation")
230 "OpenColorIO, or OCIO, is a complete color management solution geared
231 towards motion picture production, with an emphasis on visual effects and
232 computer animation. It provides a straightforward and consistent user
233 experience across all supporting applications while allowing for sophisticated
234 back-end configuration options suitable for high-end production usage.
236 OCIO is compatible with the @acronym{ACES, Academy Color Encoding
237 Specification} and is @acronym{LUT, look-up table}-format agnostic, supporting
238 many popular formats.")
239 (license (list license:expat ; docs/ociotheme/static, ext/yaml-cpp-*
240 license:zlib ; src/core/md5
241 license:bsd-3)))) ; the rest
249 (uri (string-append "https://vtk.org/files/release/"
250 (version-major+minor version)
251 "/VTK-" version ".tar.gz"))
254 "1fspgp8k0myr6p2a6wkc21ldcswb4bvmb484m12mxgk1a9vxrhrl"))))
255 (build-system cmake-build-system)
257 '(#:build-type "Release" ;Build without '-g' to save space.
258 ;; -DVTK_USE_SYSTEM_NETCDF:BOOL=TRUE requires netcdf_cxx
259 #:configure-flags '("-DVTK_USE_SYSTEM_EXPAT:BOOL=TRUE"
260 "-DVTK_USE_SYSTEM_FREETYPE:BOOL=TRUE"
261 "-DVTK_USE_SYSTEM_HDF5:BOOL=TRUE"
262 "-DVTK_USE_SYSTEM_JPEG:BOOL=TRUE"
263 "-DVTK_USE_SYSTEM_JSONCPP:BOOL=TRUE"
264 "-DVTK_USE_SYSTEM_LIBXML2:BOOL=TRUE"
265 "-DVTK_USE_SYSTEM_OGGTHEORA:BOOL=TRUE"
266 "-DVTK_USE_SYSTEM_PNG:BOOL=TRUE"
267 "-DVTK_USE_SYSTEM_TIFF:BOOL=TRUE"
268 "-DVTK_USE_SYSTEM_ZLIB:BOOL=TRUE")
269 #:tests? #f)) ;XXX: no "test" target
272 ("xorgproto" ,xorgproto)
278 ("freetype" ,freetype)
280 ("jpeg" ,libjpeg-turbo)
283 ("libtheora" ,libtheora)
287 (home-page "https://vtk.org/")
288 (synopsis "Libraries for 3D computer graphics")
290 "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
291 image processing and visualization. It supports a wide variety of
292 visualization algorithms including: scalar, vector, tensor, texture, and
293 volumetric methods; and advanced modeling techniques such as: implicit
294 modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay
295 triangulation. VTK has an extensive information visualization framework, has
296 a suite of 3D interaction widgets, supports parallel processing, and
297 integrates with various databases on GUI toolkits such as Qt and Tk.")
298 (license license:bsd-3)))
300 ;; itksnap needs an older variant of VTK.
302 (package (inherit vtk)
306 (uri (string-append "https://vtk.org/files/release/"
307 (version-major+minor version)
308 "/VTK-" version ".tar.gz"))
311 "0pla1r5mvkgl4sl213gfdhzrypdgai0h3z5mfgm6p9jz9hsr794j"))))
313 `(("jsoncpp" ,jsoncpp-for-tensorflow)
314 ,@(alist-delete "jsoncpp" (package-inputs vtk))))))
316 (define-public opencv
323 (url "https://github.com/opencv/opencv")
325 (file-name (git-file-name name version))
328 "06bc61r8myym4s8im10brdjfg4wxkrvsbhhl7vr1msdan2xddzi3"))
330 (search-patches "opencv-fix-build-of-grfmt_jpeg2000.cpp.patch"))
331 (modules '((guix build utils)))
334 ;; Remove external libraries. We have all available in Guix:
335 (delete-file-recursively "3rdparty")
337 ;; Milky icon set is non-free:
338 (delete-file-recursively "modules/highgui/src/files_Qt/Milky")
341 (for-each delete-file
342 '("modules/java/test/pure_test/lib/junit-4.11.jar"
343 "samples/java/sbt/sbt/sbt-launch.jar"))
345 (build-system cmake-build-system)
348 (list "-DWITH_IPP=OFF"
350 "-DWITH_CAROTENE=OFF" ; only visible on arm/aarch64
351 "-DENABLE_PRECOMPILED_HEADERS=OFF"
354 ;; See cmake/OpenCVCompilerOptimizations.cmake
355 ;; (CPU_ALL_OPTIMIZATIONS) for a list of all optimizations
356 ;; BASELINE is the minimum optimization all CPUs must support
358 ;; DISPATCH is the list of optional dispatches.
359 "-DCPU_BASELINE=SSE2"
361 ,@(match (%current-system)
363 '("-DCPU_DISPATCH=NEON;VFPV3;FP16;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX"
364 "-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2"))
366 '("-DCPU_BASELINE_DISABLE=NEON")) ; causes build failures
368 '("-DCPU_BASELINE=NEON"
369 "-DCPU_DISPATCH=NEON;VFPV3;FP16"))
372 "-DBUILD_PERF_TESTS=OFF"
375 (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
376 "/opencv-contrib/modules")
379 (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
380 "/opencv-extra/testdata")
382 ;; Is ON by default and would try to rebuild 3rd-party protobuf,
383 ;; which we had removed, which would lead to an error:
384 "-DBUILD_PROTOBUF=OFF"
386 ;; Rebuild protobuf files, because we have a slightly different
387 ;; version than the included one. If we would not update, we
388 ;; would get a compile error later:
389 "-DPROTOBUF_UPDATE_FILES=ON"
391 ;; xfeatures2d disabled, because it downloads extra binaries from
392 ;; https://github.com/opencv/opencv_3rdparty
393 ;; defined in xfeatures2d/cmake/download_{vgg|bootdesc}.cmake
394 ;; Cmp this bug entry:
395 ;; https://github.com/opencv/opencv_contrib/issues/1131
396 "-DBUILD_opencv_xfeatures2d=OFF")
398 (modify-phases %standard-phases
399 (add-after 'unpack 'disable-broken-tests
401 ;; These tests fails with:
402 ;; vtkXOpenGLRenderWindow (0x723990): Could not find a decent config
403 ;; I think we have no OpenGL support with the Xvfb.
404 (substitute* '("modules/viz/test/test_tutorial3.cpp"
405 "modules/viz/test/test_main.cpp"
406 "modules/viz/test/tests_simple.cpp"
407 "modules/viz/test/test_viz3d.cpp")
408 (("(TEST\\(Viz, )([a-z].*\\).*)" all pre post)
409 (string-append pre "DISABLED_" post)))
411 ;; This one fails with "unknown file: Failure"
412 ;; But I couldn't figure out which file was missing:
413 (substitute* "../opencv-contrib/modules/face/test/test_face_align.cpp"
414 (("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)"
416 (string-append pre "DISABLED_" post)))
418 ;; Failure reason: Bad accuracy
419 ;; Incorrect count of accurate poses [2nd case]: 90.000000 / 94.000000
420 (substitute* "../opencv-contrib/modules/rgbd/test/test_odometry.cpp"
421 (("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post)
422 (string-append pre "DISABLED_" post)))
425 (add-after 'unpack 'unpack-submodule-sources
426 (lambda* (#:key inputs #:allow-other-keys)
427 (mkdir "../opencv-extra")
428 (mkdir "../opencv-contrib")
429 (copy-recursively (assoc-ref inputs "opencv-extra")
432 (assoc-ref inputs "opencv-contrib")
433 "--strip-components=1"
434 "-C" "../opencv-contrib")))
436 (add-after 'set-paths 'add-ilmbase-include-path
437 (lambda* (#:key inputs #:allow-other-keys)
438 ;; OpenEXR propagates ilmbase, but its include files do not appear
439 ;; in the CPATH, so we need to add "$ilmbase/include/OpenEXR/" to
440 ;; the CPATH to satisfy the dependency on "ImathVec.h".
442 (string-append (assoc-ref inputs "ilmbase")
444 ":" (or (getenv "CPATH") "")))
446 (add-before 'check 'start-xserver
447 (lambda* (#:key inputs #:allow-other-keys)
448 (let ((xorg-server (assoc-ref inputs "xorg-server"))
450 (setenv "HOME" (getcwd))
451 (setenv "DISPLAY" disp)
452 ;; There must be a running X server and make check doesn't start one.
453 ;; Therefore we must do it.
454 (zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp)))))))))
456 `(("pkg-config" ,pkg-config)
457 ("xorg-server" ,xorg-server-for-tests) ; For running the tests
462 (url "https://github.com/opencv/opencv_extra")
464 (file-name (git-file-name "opencv_extra" version))
466 (base32 "08p5xnq8n1jw8svvz0fnirfg7q8dm3p4a5dl7527s5xj0f9qn7lp"))))
471 (url "https://github.com/opencv/opencv_contrib")
473 (file-name (git-file-name "opencv_contrib" version))
474 (patches (search-patches "opencv-rgbd-aarch64-test-fix.patch"))
476 (base32 "1f334glf39nk42mpqq6j732h3ql2mpz89jd4mcl678s8n73nfjh2"))))))
477 (inputs `(("libjpeg" ,libjpeg-turbo)
480 ;; ffmpeg 4.0 causes core dumps in tests.
481 ("ffmpeg" ,ffmpeg-3.4)
484 ("libgphoto2" ,libgphoto2)
487 ("gtkglext" ,gtkglext)
491 ("python-numpy" ,python-numpy)
492 ("protobuf" ,protobuf)
495 ;; These three CVEs are not a problem of OpenCV, see:
496 ;; https://github.com/opencv/opencv/issues/10998
497 (properties '((lint-hidden-cve . ("CVE-2018-7712"
500 (synopsis "Computer vision library")
501 (description "OpenCV is a library aimed at
502 real-time computer vision, including several hundred computer
503 vision algorithms. It can be used to do things like:
506 @item image and video input and output
507 @item image and video processing
509 @item feature recognition
511 @item facial recognition
513 @item structure from motion
514 @item augmented reality
515 @item machine learning
517 (home-page "https://opencv.org/")
518 (license license:bsd-3)))
528 "https://github.com/libvips/libvips/releases/download/v"
529 version "/vips-" version ".tar.gz"))
531 (base32 "01gjhcrl6zj7mcj1al717v5jsniahplqhz1xkfh2j78vyfl1hxff"))))
532 (build-system gnu-build-system)
534 `(("pkg-config" ,pkg-config)
535 ("gobject-introspection" ,gobject-introspection)))
538 ("libjpeg" ,libjpeg-turbo)
551 ("niftilib" ,niftilib)
554 ("imagemagick" ,imagemagick)
558 (home-page "https://libvips.github.io/libvips/")
559 (synopsis "Multithreaded image processing system with low memory needs")
561 "VIPS is a demand-driven, horizontally threaded image processing library.
562 It's particularly good at processing large images, working with colour,
563 scientific analysis, and general research & development.
565 Compared to most image processing libraries VIPS needs little RAM and runs
566 quickly, especially on machines with more than one CPU core. This is primarily
567 due to its architecture which automatically parallelises the image workflows.")
568 (license license:lgpl2.1+)))
577 (uri (string-append "https://gmic.eu/files/source/gmic_"
580 (base32 "14acph914a8lp6qqfmp319ggqjg3i3hmalmnpk3mp07m7vpv2p9q"))))
581 (build-system cmake-build-system)
583 `(#:tests? #f)) ;there are no tests
585 `(("pkg-config" ,pkg-config)))
589 ("graphicsmagick" ,graphicsmagick)
590 ("libjpeg-turbo" ,libjpeg-turbo)
594 ;;("opencv" ,opencv) ;OpenCV is currently broken in the CI
597 (home-page "https://gmic.eu/")
598 (synopsis "Full-featured framework for digital image processing")
599 (description "G'MIC is a full-featured framework for digital image
600 processing. It provides several user interfaces to convert / manipulate
601 / filter / visualize generic image datasets, ranging from 1D scalar
602 signals to 3D+t sequences of multi-spectral volumetric images, hence
603 including 2D color images.")
604 ;; Dual-licensed, either license applies.
605 (license (list license:cecill license:cecill-c))))
614 (uri (string-append "https://github.com/libvips/nip2/releases/download/v"
615 version "/nip2-" version ".tar.gz" ))
617 (base32 "0l7n427njif53npqn02gfjjly8y3khbrkzqxp10j5vp9h97psgiw"))))
618 (build-system gnu-build-system)
621 (modify-phases %standard-phases
622 ;; test_conv.ws keep failing so disabling for now.
623 (add-after 'unpack 'disable-test-conv
625 (delete-file "test/workspaces/test_conv.ws")
627 (add-before 'check 'set-home
629 (setenv "HOME" "/tmp") #t)))))
637 ("libjpeg" ,libjpeg-turbo) ;required by vips.pc
641 ("imagemagick" ,imagemagick)
652 ("pkg-config" ,pkg-config)))
653 (home-page "https://github.com/libvips/nip2")
654 (synopsis "Spreadsheet-like GUI for libvips")
655 (description "This package provide a graphical user interface (GUI) for
656 the VIPS image processing library. It's a little like a spreadsheet: you
657 create a set of formula connecting your objects together, and on a change nip2
659 (license license:gpl2+)))
669 (url "https://github.com/vxl/vxl")
670 (commit (string-append "v" version))))
671 (file-name (git-file-name name version))
673 (base32 "0949hw57szq8943f1whwqaz591xjmb19kj803hcv74hdai2b0ycg"))
674 (modules '((guix build utils)))
675 ;; TODO: vxl includes an old version of dcmtk. It won't build with
679 (for-each delete-file-recursively
686 (substitute* "v3p/CMakeLists.txt"
687 (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
690 (build-system cmake-build-system)
692 `(("libgeotiff" ,libgeotiff)
694 ("libjpeg" ,libjpeg-turbo)
697 (home-page "https://github.com/vxl/vxl/")
698 (synopsis "Collection of C++ libraries for computer vision")
699 (description "VXL (the Vision-something-Libraries) is a collection of C++
700 libraries designed for computer vision research and implementation.")
701 (license license:bsd-3)))
704 (package (inherit vxl)
711 (url "https://github.com/vxl/vxl")
712 (commit (string-append "v" version))))
713 (file-name (git-file-name name version))
715 (base32 "1g4mr2cc58jwm0vasscbd4y5380wj3ahkvq121z4gs83fhavvxgz"))
716 (modules '((guix build utils)))
719 (for-each delete-file-recursively
725 (substitute* "v3p/CMakeLists.txt"
726 (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
731 ;; Needed for itk-snap
732 (list "-DVNL_CONFIG_LEGACY_METHODS=ON")))))
734 (define-public insight-toolkit
736 (name "insight-toolkit")
741 (uri (string-append "https://github.com/InsightSoftwareConsortium/ITK/"
742 "releases/download/v" version "/InsightToolkit-"
745 (base32 "0bs63mk4q8jmx38f031jy5w5n9yy5ng9x8ijwinvjyvas8cichqi"))))
746 (build-system cmake-build-system)
748 `(#:tests? #f ; tests require network access and external data
751 "-DITK_USE_SYSTEM_LIBRARIES=ON"
752 "-DITK_USE_SYSTEM_GOOGLETEST=ON"
753 "-DITK_BUILD_SHARED=ON"
754 ;; This prevents "GTest::GTest" from being added to the ITK_LIBRARIES
755 ;; variable in the installed CMake files. This is necessary as other
756 ;; packages using insight-toolkit could not be configured otherwise.
757 "-DGTEST_ROOT=gtest")
759 (modify-phases %standard-phases
760 (add-after 'unpack 'do-not-tune
762 (substitute* "CMake/ITKSetStandardCompilerFlags.cmake"
763 (("-mute=native") ""))
771 ("libjpeg" ,libjpeg-turbo)
774 ("mesa" ,mesa-opencl)
781 `(("googletest" ,googletest)
782 ("pkg-config" ,pkg-config)))
783 (home-page "https://github.com/InsightSoftwareConsortium/ITK/")
784 (synopsis "Scientific image processing, segmentation and registration")
785 (description "The Insight Toolkit (ITK) is a toolkit for N-dimensional
786 scientific image processing, segmentation, and registration. Segmentation is
787 the process of identifying and classifying data found in a digitally sampled
788 representation. Typically the sampled representation is an image acquired
789 from such medical instrumentation as CT or MRI scanners. Registration is the
790 task of aligning or developing correspondences between data. For example, in
791 the medical environment, a CT scan may be aligned with a MRI scan in order to
792 combine the information contained in both.")
793 (license license:asl2.0)))
795 (define-public insight-toolkit-4
796 (package (inherit insight-toolkit)
801 (uri (string-append "https://github.com/InsightSoftwareConsortium/ITK/"
802 "releases/download/v" version "/InsightToolkit-"
805 (base32 "19cgfpd63gqrvc3m27m394gy2d7w79g5y6lvznb5qqr49lihbgns"))))
807 `(#:tests? #f ; tests require network access and external data
809 '("-DITKV3_COMPATIBILITY=ON" ; needed for itk-snap
811 "-DITK_USE_SYSTEM_LIBRARIES=ON"
812 "-DITK_USE_SYSTEM_GOOGLETEST=ON"
813 "-DITK_USE_SYSTEM_VXL=ON")))))
815 (define-public insight-toolkit-4.12
816 (package (inherit insight-toolkit-4)
821 (uri (string-append "mirror://sourceforge/itk/itk/4.12/"
822 "InsightToolkit-" version ".tar.xz"))
824 (base32 "1qw9mxbh083siljygahl4gdfv91xvfd8hfl7ghwii19f60xrvn2w"))))))
826 (define-public itk-snap
834 (url "https://git.code.sf.net/p/itk-snap/src")
835 (commit (string-append "v" version))))
836 (file-name (git-file-name name version))
838 (base32 "15i5ixpryfrbf3vrrb5rici8fb585f25k0v1ljds16bp1f1msr4q"))))
839 (build-system cmake-build-system)
842 (list "-DSNAP_VERSION_GIT_SHA1=release"
843 "-DSNAP_VERSION_GIT_BRANCH=release"
844 "-DSNAP_VERSION_GIT_TIMESTAMP=0"
845 "-DSNAP_PACKAGE_QT_PLUGINS=OFF"
846 "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
848 (modify-phases %standard-phases
849 ;; During the installation phase all libraries provided by all
850 ;; dependencies will be copied to the lib directory. That's insane,
851 ;; so we disable this.
852 (add-after 'unpack 'do-not-copy-dependencies
854 (substitute* "CMakeLists.txt"
855 (("install_qt5_executable\
856 \\(\\$\\{SNAP_MAIN_INSTALL_DIR\\}/\\$\\{SNAP_EXE\\}\\)")
859 (add-after 'unpack 'disable-gui-tests
861 ;; The GUI tests just time out.
862 (substitute* "CMakeLists.txt"
863 ((" (Workspace|DiffSpace|ProbeIntensity|RegionCompetition\
864 |RandomForest|RandomForestBailOut)")
867 (add-after 'unpack 'make-reproducible
869 (substitute* "CMakeLists.txt"
870 (("TODAY\\(SNAP_VERSION_COMPILE_DATE\\)")
871 "SET(SNAP_VERSION_COMPILE_DATE \"(removed for reproducibility)\")"))
873 (add-after 'unpack 'prepare-submodules
874 (lambda* (#:key inputs #:allow-other-keys)
875 (rmdir "Submodules/c3d")
876 (copy-recursively (assoc-ref inputs "c3d-src")
878 (substitute* '("Submodules/c3d/adapters/BiasFieldCorrectionN4.cxx"
879 "Submodules/c3d/adapters/ApplyMetric.cxx")
881 (rmdir "Submodules/greedy")
882 (symlink (assoc-ref inputs "greedy-src")
885 (add-after 'unpack 'fix-includes
887 (substitute* "GUI/Model/RegistrationModel.cxx"
888 (("<vnl_symmetric_eigensystem.h>")
889 "<vnl/algo/vnl_symmetric_eigensystem.h>"))
891 (add-before 'check 'prepare-tests
893 ;; Needed by at least one test.
894 (setenv "HOME" "/tmp")
896 (add-after 'install 'wrap-executable
897 (lambda* (#:key inputs outputs #:allow-other-keys)
898 (let ((out (assoc-ref outputs "out")))
899 (wrap-program (string-append out "/bin/itksnap")
900 `("QT_PLUGIN_PATH" ":" prefix
901 ,(map (lambda (label)
902 (string-append (assoc-ref inputs label)
904 '("qtbase" "qtdeclarative"))))
912 ("mesa" ,mesa-opencl)
913 ;; This package does not build with either insight-toolkit 5.0.0 and
914 ;; not with 4.13. It really needs to be 4.12.
915 ("itk" ,insight-toolkit-4.12)
918 ("qtdeclarative" ,qtdeclarative)
922 `(("googletest" ,googletest)
924 ("pkg-config" ,pkg-config)
926 ,(let* ((commit "f521358db26e00002c911cc47bf463b043942ad3")
928 (version (git-version "0" revision commit)))
932 (url "https://github.com/pyushkevich/c3d")
934 (file-name (git-file-name "c3d" version))
937 "0kyv3rxrxwr8c3sa9zv01lsnhk95b27gx1s870k3yi8qp52h7bx3")))))
938 ;; We are using an arbitrary commit from 2017 because the latest
939 ;; version breaks the build...
941 ,(let* ((commit "97e340f7e8e66597599144947775e6039e79a0d3")
943 (version (git-version "0" revision commit)))
947 (url "https://github.com/pyushkevich/greedy")
949 (file-name (git-file-name "greedy" version))
952 "0k5bc9za4jrc8z9dj08z1rkcp5xf0gnd1d2jmi1w9ny4vxh2q2ab")))))))
953 (home-page "https://sourceforge.net/p/itk-snap/")
954 (synopsis "Medical image segmentation")
955 (description "ITK-SNAP is a tool for segmenting anatomical structures in
956 medical images. It provides an automatic active contour segmentation
957 pipeline, along with supporting a manual segmentation toolbox. ITK-SNAP has a
958 full-featured UI aimed at clinical researchers.")
959 ;; This includes the submodules greedy and c3d.
960 (license license:gpl3+)))
962 (define-public metapixel
963 ;; Follow stable branch.
964 (let ((commit "98ee9daa093b6c334941242e63f90b1c2876eb4f"))
967 (version (git-version "1.0.2" "1" commit))
972 (url "https://github.com/schani/metapixel")
974 ;; TODO: Package rwimg and lispreader?
976 (file-name (git-file-name name version))
978 (base32 "0r7n3a6bvcxkbpda4mwmrpicii09iql5z69nkjqygkwxw7ny3309"))))
979 (build-system gnu-build-system)
982 ("libjpeg" ,libjpeg-turbo)
986 `(("pkg-config" ,pkg-config)
987 ("docbook-xml" ,docbook-xml)
988 ("docbook-xsl" ,docbook-xsl)
989 ("xsltproc" ,libxslt)))
991 `(#:tests? #f ; No tests.
993 (string-append "PREFIX=" (assoc-ref %outputs "out"))
994 (string-append "MANPAGE_XSL="
995 (assoc-ref %build-inputs "docbook-xsl")
996 "/xml/xsl/docbook-xsl-*/manpages/docbook.xsl"))
998 (modify-phases %standard-phases
1000 (add-before 'install 'make-local-docbook-xml
1001 (lambda* (#:key inputs #:allow-other-keys)
1002 (substitute* "metapixel.xml"
1003 (("http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd")
1004 (string-append (assoc-ref inputs "docbook-xml")
1005 "/xml/dtd/docbook/docbookx.dtd")))
1007 (add-before 'install 'fix-directory-creation
1008 (lambda* (#:key outputs #:allow-other-keys)
1009 (mkdir-p (string-append (assoc-ref outputs "out") "/share/man/man1"))
1011 (home-page "https://www.complang.tuwien.ac.at/schani/metapixel/")
1012 (synopsis "Photomosaics generator")
1013 (description "Metapixel is a program for generating photomosaics. It can
1014 generate classical photomosaics, in which the source image is viewed as a
1015 matrix of equally sized rectangles for each of which a matching image is
1016 substituted, as well as collage-style photomosaics, in which rectangular parts
1017 of the source image at arbitrary positions (i.e. not aligned to a matrix) are
1018 substituted by matching images.")
1019 (license license:gpl2))))
1021 (define-public scantailor-advanced
1022 (let ((commit "3d1e74e6ace413733511086934a66f4e3f7a6027"))
1024 (name "scantailor-advanced")
1025 (version (string-append "1.0.16-" (string-take commit 7)))
1030 (url "https://github.com/4lex4/scantailor-advanced")
1032 (file-name (git-file-name name version))
1035 "0kixwjb2x457dq7927hkh34c803p7yh1pmn6n61rk9shqrcg492h"))))
1036 (build-system qt-build-system)
1038 `(("qttools" ,qttools)))
1041 ("libjpeg" ,libjpeg-turbo)
1043 ("libtiff" ,libtiff)
1049 (modify-phases %standard-phases
1050 ;; Some tests require a display and fail with offscreen mode.
1051 (add-after 'unpack 'disable-failing-tests
1053 (setenv "ARGS" "--exclude-regex \"imageproc_.*\"")
1055 (home-page "https://github.com/4lex4/scantailor-advanced")
1056 (synopsis "Clean up scanned pages")
1057 (description "Scan Tailor is an interactive post-processing tool for
1058 scanned pages. It performs operations such as page splitting, deskewing,
1059 adding/removing borders, and others. You give it raw scans, and you get pages
1060 ready to be printed or assembled into a PDF or DJVU file. Scanning, optical
1061 character recognition, and assembling multi-page documents are out of scope of
1064 Scan Tailer Advanced is a fork of Scan Tailer that merges Scan Tailor Featured
1065 and Scan Tailor Enhanced versions as well as including many more bug fixes.")
1066 (license license:gpl3+))))