1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 John Darrington <jmd@gnu.org>
3 ;;; Copyright © 2017, 2019 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2014, 2021 Ludovic Courtès <ludo@gnu.org>
5 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
7 ;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <me@tobias.gr>
8 ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
9 ;;; Copyright © 2018 Lprndn <guix@lprndn.info>
10 ;;; Copyright © 2019, 2021 Efraim Flashner <efraim@flashner.co.il>
11 ;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
12 ;;; Copyright © 2020, 2021 Vinicius Monego <monego@posteo.net>
13 ;;; Copyright © 2020 Pierre Neidhardt <mail@ambrevar.xyz>
14 ;;; Copyright © 2020 Brendan Tildesley <mail@brendan.scot>
15 ;;; Copyright © 2021 Oleh Malyi <astroclubzp@gmail.com>
16 ;;; Copyright © 2021 Felix Gruber <felgru@posteo.net>
17 ;;; Copyright © 2021 Andy Tai <atai@atai.org>
18 ;;; Copyright © 2021 Ekaitz Zarraga <ekaitz@elenq.tech>
19 ;;; Copyright © 2021 Paul Garlick <pgarlick@tourbillion-technology.com>
20 ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
21 ;;; Copyright © 2021 Ivan Gankevich <i.gankevich@spbu.ru>
23 ;;; This file is part of GNU Guix.
25 ;;; GNU Guix is free software; you can redistribute it and/or modify it
26 ;;; under the terms of the GNU General Public License as published by
27 ;;; the Free Software Foundation; either version 3 of the License, or (at
28 ;;; your option) any later version.
30 ;;; GNU Guix is distributed in the hope that it will be useful, but
31 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
32 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 ;;; GNU General Public License for more details.
35 ;;; You should have received a copy of the GNU General Public License
36 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
38 (define-module (gnu packages image-processing)
39 #:use-module ((guix licenses) #:prefix license:)
40 #:use-module (guix packages)
41 #:use-module (guix utils)
42 #:use-module (guix download)
43 #:use-module (guix git-download)
44 #:use-module (guix build-system qt)
45 #:use-module (guix build-system cmake)
46 #:use-module (guix build-system gnu)
47 #:use-module (guix build-system python)
48 #:use-module (gnu packages)
49 #:use-module (gnu packages algebra)
50 #:use-module (gnu packages bison)
51 #:use-module (gnu packages boost)
52 #:use-module (gnu packages check)
53 #:use-module (gnu packages compression)
54 #:use-module (gnu packages curl)
55 #:use-module (gnu packages docbook)
56 #:use-module (gnu packages documentation)
57 #:use-module (gnu packages flex)
58 #:use-module (gnu packages fontutils)
59 #:use-module (gnu packages geo)
60 #:use-module (gnu packages ghostscript)
61 #:use-module (gnu packages gimp)
62 #:use-module (gnu packages gl)
63 #:use-module (gnu packages glib)
64 #:use-module (gnu packages gnome)
65 #:use-module (gnu packages graphics)
66 #:use-module (gnu packages graphviz)
67 #:use-module (gnu packages gstreamer)
68 #:use-module (gnu packages gtk)
69 #:use-module (gnu packages icu4c)
70 #:use-module (gnu packages image)
71 #:use-module (gnu packages imagemagick)
72 #:use-module (gnu packages maths)
73 #:use-module (gnu packages pdf)
74 #:use-module (gnu packages perl)
75 #:use-module (gnu packages photo)
76 #:use-module (gnu packages pkg-config)
77 #:use-module (gnu packages protobuf)
78 #:use-module (gnu packages python)
79 #:use-module (gnu packages python-check)
80 #:use-module (gnu packages python-xyz)
81 #:use-module (gnu packages qt)
82 #:use-module (gnu packages serialization)
83 #:use-module (gnu packages sqlite)
84 #:use-module (gnu packages tbb)
85 #:use-module (gnu packages tls)
86 #:use-module (gnu packages version-control)
87 #:use-module (gnu packages video)
88 #:use-module (gnu packages xiph)
89 #:use-module (gnu packages xml)
90 #:use-module (gnu packages xorg)
91 #:use-module (ice-9 match)
92 #:use-module (srfi srfi-1))
102 (string-append "ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/"
103 "dcmtk" (string-join (string-split version #\.) "")
104 "/dcmtk-" version ".tar.gz"))
106 (base32 "13j5yf3p6qj3mr17d77r3kcqchf055hgvk1w15vmdr8f54mwcnb8"))))
107 (build-system cmake-build-system)
117 (list doxygen)) ; for HTML documentation
118 (home-page "https://dcmtk.org")
119 (synopsis "Libraries and programs implementing parts of the DICOM standard")
120 (description "DCMTK is a collection of libraries and applications
121 implementing large parts the DICOM standard. It includes software for
122 examining, constructing and converting DICOM image files, handling offline
123 media, sending and receiving images over a network connection, as well as
124 demonstrative image storage and worklist servers.")
125 (license (license:fsf-free
127 "A union of the Apache 2.0 licence and various non-copyleft
128 licences similar to the Modified BSD licence."))))
136 (uri (string-append "mirror://sourceforge/mia/mia/"
137 (version-major+minor version)
138 "/mia-" version ".tar.xz"))
141 "0j4nd5z7i3v199jh7hqqhwd4g7snchizkc7rhzanpvngqg91m1pb"))))
142 (build-system cmake-build-system)
145 (list "-DMIA_CREATE_NIPYPE_INTERFACES=0"
146 "-DCMAKE_CXX_FLAGS=-fpermissive")))
158 ("libjpeg" ,libjpeg-turbo)
162 ("libxml++" ,libxml++)
164 ("niftilib" ,niftilib)
166 ("openexr" ,openexr-2)
167 ("python-lxml" ,python2-lxml)
170 `(("pkg-config" ,pkg-config)
171 ("python" ,python-2)))
172 (home-page "http://mia.sourceforge.net")
173 (synopsis "Toolkit for gray scale medical image analysis")
174 (description "MIA provides a combination of command line tools, plug-ins,
175 and libraries that make it possible run image processing tasks interactively
176 in a command shell and to prototype using the shell's scripting language. It
177 is built around a plug-in structure that makes it easy to add functionality
178 without compromising the original code base and it makes use of a wide variety
179 of external libraries that provide additional functionality.")
180 (license license:gpl3+)))
182 (define-public opencolorio
190 (url "https://github.com/AcademySoftwareFoundation/OpenColorIO")
191 (commit (string-append "v" version))))
193 (base32 "12srvxca51czpfjl0gabpidj9n84mw78ivxy5w75qhq2mmc798sb"))
194 (file-name (git-file-name name version))
195 (modules '((guix build utils)))
198 ;; Remove bundled tarballs, patches, and .jars(!). XXX: Upstream
199 ;; claims to have fixed USE_EXTERNAL_YAML, but it still fails with:
200 ;; https://github.com/AcademySoftwareFoundation/OpenColorIO/issues/517
201 ;; When removing it, also remove it from the licence field comment.
202 (for-each delete-file-recursively
205 (let ((file (basename full-name)))
206 (not (or (string-prefix? "yaml-cpp-0.3" file)
207 (string=? "unittest.h" file)))))
208 (find-files "ext" ".*")))
211 (build-system cmake-build-system)
214 (list (string-append "-DCMAKE_CXX_FLAGS="
215 "-Wno-error=deprecated-declarations "
216 "-Wno-error=unused-function")
217 "-DOCIO_BUILD_STATIC=OFF"
218 ;; "-DUSE_EXTERNAL_YAML=ON"
219 "-DUSE_EXTERNAL_TINYXML=ON"
220 "-DUSE_EXTERNAL_LCMS=ON")
222 (modify-phases %standard-phases
223 (add-after 'unpack 'patch-test-suite
225 (substitute* "src/core_tests/CMakeLists.txt"
226 (("/bin/sh") (which "bash")))
229 (list git pkg-config))
231 ;; XXX Adding freeglut, glew, ilmbase, mesa, and openimageio for
232 ;; ocioconvert fails: error: conflicting declaration ?typedef void
233 ;; (* PFNGLGETFRAGMENTMATERIALFVSGIXPROC)(GLenum, GLenum, GLfloat*)
234 (list lcms openexr-2 tinyxml))
235 (home-page "https://opencolorio.org")
236 (synopsis "Color management for visual effects and animation")
238 "OpenColorIO, or OCIO, is a complete color management solution geared
239 towards motion picture production, with an emphasis on visual effects and
240 computer animation. It provides a straightforward and consistent user
241 experience across all supporting applications while allowing for sophisticated
242 back-end configuration options suitable for high-end production usage.
244 OCIO is compatible with the @acronym{ACES, Academy Color Encoding
245 Specification} and is @acronym{LUT, look-up table}-format agnostic, supporting
246 many popular formats.")
247 (license (list license:expat ; docs/ociotheme/static, ext/yaml-cpp-*
248 license:zlib ; src/core/md5
249 license:bsd-3)))) ; the rest
257 (uri (string-append "https://vtk.org/files/release/"
258 (version-major+minor version)
259 "/VTK-" version ".tar.gz"))
262 "1ir2lq9i45ls374lcmjzw0nrm5l5hnm1w47lg8g8d0n2j7hsaf8v"))
264 (search-patches "vtk-fix-freetypetools-build-failure.patch"))
265 (modules '((guix build utils)))
270 (delete-file-recursively
271 (string-append "ThirdParty/" dir "/vtk" dir)))
272 ;; pugixml depended upon unconditionally
273 '("doubleconversion" "eigen" "expat" "freetype" "gl2ps"
274 "glew" "hdf5" "jpeg" "jsoncpp" "libproj" "libxml2" "lz4"
275 "netcdf" "ogg" "png" "sqlite" "theora" "tiff" "zlib"))
277 (properties `((release-monitoring-url . "https://vtk.org/download/")))
278 (build-system cmake-build-system)
280 '(#:build-type "Release" ;Build without '-g' to save space.
281 #:configure-flags '(;"-DBUILD_TESTING:BOOL=TRUE"
283 "-DVTK_USE_EXTERNAL=OFF" ;; default
284 "-DVTK_MODULE_USE_EXTERNAL_VTK_doubleconversion=ON"
285 "-DVTK_MODULE_USE_EXTERNAL_VTK_eigen=ON"
286 "-DVTK_MODULE_USE_EXTERNAL_VTK_expat=ON"
287 "-DVTK_MODULE_USE_EXTERNAL_VTK_freetype=ON"
288 "-DVTK_MODULE_USE_EXTERNAL_VTK_gl2ps=ON"
289 "-DVTK_MODULE_USE_EXTERNAL_VTK_glew=ON"
290 "-DVTK_MODULE_USE_EXTERNAL_VTK_hdf5=ON"
291 "-DVTK_MODULE_USE_EXTERNAL_VTK_jpeg=ON"
292 "-DVTK_MODULE_USE_EXTERNAL_VTK_jsoncpp=ON"
293 "-DVTK_MODULE_USE_EXTERNAL_VTK_libproj=ON"
294 "-DVTK_MODULE_USE_EXTERNAL_VTK_libxml2=ON"
295 "-DVTK_MODULE_USE_EXTERNAL_VTK_lz4=ON"
296 "-DVTK_MODULE_USE_EXTERNAL_VTK_netcdf=ON"
297 "-DVTK_MODULE_USE_EXTERNAL_VTK_ogg=ON"
298 "-DVTK_MODULE_USE_EXTERNAL_VTK_png=ON"
299 ;"-DVTK_MODULE_USE_EXTERNAL_VTK_pugixml=ON" ; breaks IO/CityGML
300 "-DVTK_MODULE_USE_EXTERNAL_VTK_sqlite=ON"
301 "-DVTK_MODULE_USE_EXTERNAL_VTK_theora=ON"
302 "-DVTK_MODULE_USE_EXTERNAL_VTK_tiff=ON"
303 "-DVTK_MODULE_USE_EXTERNAL_VTK_zlib=ON"
304 "-DVTK_WRAP_PYTHON=ON"
305 "-DVTK_PYTHON_VERSION:STRING=3"
308 (modify-phases %standard-phases
309 (add-after 'unpack 'patch-sources
311 (substitute* "Common/Core/vtkFloatingPointExceptions.cxx"
312 (("<fenv.h>") "<cfenv>"))
313 (substitute* "Common/Core/CMakeLists.txt"
314 (("fenv.h") "cfenv")))))
315 #:tests? #f)) ;XXX: test data not included
317 `(("double-conversion" ,double-conversion)
320 ("freetype" ,freetype)
325 ("jpeg" ,libjpeg-turbo)
327 ("libtheora" ,libtheora)
337 ;("pugixml" ,pugixml)
340 ("xorgproto" ,xorgproto)
343 ;; VTK's 'VTK-vtk-module-find-packages.cmake' calls
344 ;; 'find_package(THEORA)', which in turns looks for libogg.
346 (home-page "https://vtk.org/")
347 (synopsis "Libraries for 3D computer graphics")
349 "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
350 image processing and visualization. It supports a wide variety of
351 visualization algorithms including: scalar, vector, tensor, texture, and
352 volumetric methods; and advanced modeling techniques such as: implicit
353 modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay
354 triangulation. VTK has an extensive information visualization framework, has
355 a suite of 3D interaction widgets, supports parallel processing, and
356 integrates with various databases on GUI toolkits such as Qt and Tk.")
357 (license license:bsd-3)))
359 ;; itksnap needs an older variant of VTK.
361 (package (inherit vtk)
365 (uri (string-append "https://vtk.org/files/release/"
366 (version-major+minor version)
367 "/VTK-" version ".tar.gz"))
370 "0pla1r5mvkgl4sl213gfdhzrypdgai0h3z5mfgm6p9jz9hsr794j"))))
372 (modify-inputs (package-inputs vtk)
373 (replace "jsoncpp" jsoncpp-for-tensorflow)))))
375 (define-public opencv
382 (url "https://github.com/opencv/opencv")
384 (file-name (git-file-name name version))
387 "06bc61r8myym4s8im10brdjfg4wxkrvsbhhl7vr1msdan2xddzi3"))
389 (search-patches "opencv-fix-build-of-grfmt_jpeg2000.cpp.patch"))
390 (modules '((guix build utils)))
393 ;; Remove external libraries. We have all available in Guix:
394 (delete-file-recursively "3rdparty")
396 ;; Milky icon set is non-free:
397 (delete-file-recursively "modules/highgui/src/files_Qt/Milky")
400 (for-each delete-file
401 '("modules/java/test/pure_test/lib/junit-4.11.jar"
402 "samples/java/sbt/sbt/sbt-launch.jar"))
404 (build-system cmake-build-system)
407 (list "-DWITH_IPP=OFF"
409 "-DWITH_CAROTENE=OFF" ; only visible on arm/aarch64
410 "-DENABLE_PRECOMPILED_HEADERS=OFF"
413 ;; See cmake/OpenCVCompilerOptimizations.cmake
414 ;; (CPU_ALL_OPTIMIZATIONS) for a list of all optimizations
415 ;; BASELINE is the minimum optimization all CPUs must support
417 ;; DISPATCH is the list of optional dispatches.
418 "-DCPU_BASELINE=SSE2"
420 ,@(match (%current-system)
422 '("-DCPU_DISPATCH=NEON;VFPV3;FP16;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX"
423 "-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2"))
425 '("-DCPU_BASELINE_DISABLE=NEON")) ; causes build failures
427 '("-DCPU_BASELINE=NEON"
428 "-DCPU_DISPATCH=NEON;VFPV3;FP16"))
431 "-DBUILD_PERF_TESTS=OFF"
434 (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
435 "/opencv-contrib/modules")
438 (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
439 "/opencv-extra/testdata")
441 ;; Is ON by default and would try to rebuild 3rd-party protobuf,
442 ;; which we had removed, which would lead to an error:
443 "-DBUILD_PROTOBUF=OFF"
445 ;; Rebuild protobuf files, because we have a slightly different
446 ;; version than the included one. If we would not update, we
447 ;; would get a compile error later:
448 "-DPROTOBUF_UPDATE_FILES=ON"
450 ;; xfeatures2d disabled, because it downloads extra binaries from
451 ;; https://github.com/opencv/opencv_3rdparty
452 ;; defined in xfeatures2d/cmake/download_{vgg|bootdesc}.cmake
453 ;; Cmp this bug entry:
454 ;; https://github.com/opencv/opencv_contrib/issues/1131
455 "-DBUILD_opencv_xfeatures2d=OFF")
457 (modify-phases %standard-phases
458 (add-after 'unpack 'disable-broken-tests
460 ;; These tests fails with:
461 ;; vtkXOpenGLRenderWindow (0x723990): Could not find a decent config
462 ;; I think we have no OpenGL support with the Xvfb.
463 (substitute* '("modules/viz/test/test_tutorial3.cpp"
464 "modules/viz/test/test_main.cpp"
465 "modules/viz/test/tests_simple.cpp"
466 "modules/viz/test/test_viz3d.cpp")
467 (("(TEST\\(Viz, )([a-z].*\\).*)" all pre post)
468 (string-append pre "DISABLED_" post)))
470 ;; This one fails with "unknown file: Failure"
471 ;; But I couldn't figure out which file was missing:
472 (substitute* "../opencv-contrib/modules/face/test/test_face_align.cpp"
473 (("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)"
475 (string-append pre "DISABLED_" post)))
477 ;; Failure reason: Bad accuracy
478 ;; Incorrect count of accurate poses [2nd case]: 90.000000 / 94.000000
479 (substitute* "../opencv-contrib/modules/rgbd/test/test_odometry.cpp"
480 (("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post)
481 (string-append pre "DISABLED_" post)))
484 (add-after 'unpack 'unpack-submodule-sources
485 (lambda* (#:key inputs #:allow-other-keys)
486 (mkdir "../opencv-extra")
487 (mkdir "../opencv-contrib")
488 (copy-recursively (assoc-ref inputs "opencv-extra")
490 (copy-recursively (assoc-ref inputs "opencv-contrib")
491 "../opencv-contrib")))
493 (add-after 'set-paths 'add-ilmbase-include-path
494 (lambda* (#:key inputs #:allow-other-keys)
495 ;; OpenEXR propagates ilmbase, but its include files do not appear
496 ;; in the CPATH, so we need to add "$ilmbase/include/OpenEXR/" to
497 ;; the CPATH to satisfy the dependency on "ImathVec.h".
501 (search-input-file inputs "include/OpenEXR/ImathVec.h")
503 ":" (or (getenv "CPATH") "")))))
504 (add-before 'check 'start-xserver
505 (lambda* (#:key inputs #:allow-other-keys)
506 (let ((xorg-server (assoc-ref inputs "xorg-server"))
508 (setenv "HOME" (getcwd))
509 (setenv "DISPLAY" disp)
510 ;; There must be a running X server and make check doesn't start one.
511 ;; Therefore we must do it.
512 (zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp)))))))))
514 `(("pkg-config" ,pkg-config)
515 ("xorg-server" ,xorg-server-for-tests) ; For running the tests
520 (url "https://github.com/opencv/opencv_extra")
522 (file-name (git-file-name "opencv_extra" version))
524 (base32 "08p5xnq8n1jw8svvz0fnirfg7q8dm3p4a5dl7527s5xj0f9qn7lp"))))
529 (url "https://github.com/opencv/opencv_contrib")
531 (file-name (git-file-name "opencv_contrib" version))
532 (patches (search-patches "opencv-rgbd-aarch64-test-fix.patch"))
534 (base32 "1f334glf39nk42mpqq6j732h3ql2mpz89jd4mcl678s8n73nfjh2"))))))
535 (inputs `(("libjpeg" ,libjpeg-turbo)
538 ;; ffmpeg 4.0 causes core dumps in tests.
539 ("ffmpeg" ,ffmpeg-3.4)
542 ("libgphoto2" ,libgphoto2)
545 ("gtkglext" ,gtkglext)
546 ("openexr" ,openexr-2)
549 ("python-numpy" ,python-numpy)
550 ("protobuf" ,protobuf)
553 ;; These three CVEs are not a problem of OpenCV, see:
554 ;; https://github.com/opencv/opencv/issues/10998
555 (properties '((lint-hidden-cve . ("CVE-2018-7712"
558 (synopsis "Computer vision library")
559 (description "OpenCV is a library aimed at
560 real-time computer vision, including several hundred computer
561 vision algorithms. It can be used to do things like:
564 @item image and video input and output
565 @item image and video processing
567 @item feature recognition
569 @item facial recognition
571 @item structure from motion
572 @item augmented reality
573 @item machine learning
575 (home-page "https://opencv.org/")
576 (license license:bsd-3)))
586 "https://github.com/libvips/libvips/releases/download/v"
587 version "/vips-" version ".tar.gz"))
589 (base32 "0vjsh3i0861f6h9as3bch956cidz824zz499pvhjs3lfjn6hhs14"))))
590 (build-system gnu-build-system)
592 (list gobject-introspection pkg-config))
615 (home-page "https://libvips.github.io/libvips/")
616 (synopsis "Multithreaded image processing system with low memory needs")
618 "VIPS is a demand-driven, horizontally threaded image processing library.
619 It's particularly good at processing large images, working with colour,
620 scientific analysis, and general research & development.
622 Compared to most image processing libraries VIPS needs little RAM and runs
623 quickly, especially on machines with more than one CPU core. This is primarily
624 due to its architecture which automatically parallelises the image workflows.")
625 (license license:lgpl2.1+)))
634 (uri (string-append "https://gmic.eu/files/source/gmic_"
637 (base32 "05kzaplsl5qvxs7v6g73q0lq8dii8g6v77ap609188m7gr43f9cl"))))
638 (build-system cmake-build-system)
640 `(#:tests? #f ;there are no tests
641 #:configure-flags '("-DBUILD_LIB_STATIC=OFF"
642 "-DENABLE_DYNAMIC_LINKING=ON"
645 (modify-phases %standard-phases
646 (add-before 'configure 'set-LDFLAGS
647 (lambda* (#:key inputs outputs #:allow-other-keys)
651 (assoc-ref outputs "out") "/lib")))))))
662 ;;("opencv" ,opencv) ;OpenCV is currently broken in the CI
665 (home-page "https://gmic.eu/")
666 (synopsis "Full-featured framework for digital image processing")
667 (description "G'MIC is a full-featured framework for digital image
668 processing. It provides several user interfaces to convert / manipulate
669 / filter / visualize generic image datasets, ranging from 1D scalar
670 signals to 3D+t sequences of multi-spectral volumetric images, hence
671 including 2D color images.")
672 ;; Dual-licensed, either license applies.
673 (license (list license:cecill license:cecill-c))))
675 (define-public gmic-qt
680 (substitute-keyword-arguments (package-arguments gmic)
681 ((#:configure-flags _)
682 `(list "-DGMIC_QT_HOST=none" "-DENABLE_DYNAMIC_LINKING=ON"
683 (string-append "-DGMIC_LIB_PATH="
684 (assoc-ref %build-inputs "gmic") "/lib")))
686 `(modify-phases ,phases
687 (add-after 'unpack 'qt-chdir
688 (lambda _ (chdir "gmic-qt") #t))))))
690 (list pkg-config qttools))
692 (modify-inputs (package-inputs gmic)
693 (prepend gmic qtbase-5)))
694 (synopsis "Qt frontend for the G'MIC image processing framework")
695 (license license:gpl3+)))
697 (define-public gmic-qt-krita
700 (name "gmic-qt-krita")
702 (substitute-keyword-arguments (package-arguments gmic-qt)
703 ((#:configure-flags flags)
704 '(list "-DGMIC_QT_HOST=krita" "-DENABLE_DYNAMIC_LINKING=ON"
705 (string-append "-DGMIC_LIB_PATH="
706 (assoc-ref %build-inputs "gmic") "/lib")))))
707 (synopsis "Krita plugin for the G'MIC image processing framework")))
709 (define-public gmic-qt-gimp
712 (name "gmic-qt-gimp")
714 ;; GIMP and its dependencies.
715 (modify-inputs (package-inputs gmic-qt)
716 (prepend gimp gdk-pixbuf cairo gegl)))
718 (substitute-keyword-arguments (package-arguments gmic-qt)
719 ((#:configure-flags flags)
720 '(list "-DGMIC_QT_HOST=gimp" "-DENABLE_DYNAMIC_LINKING=ON"
721 (string-append "-DGMIC_LIB_PATH="
722 (assoc-ref %build-inputs "gmic") "/lib")))))
723 (synopsis "GIMP plugin for the G'MIC image processing framework")))
732 (uri (string-append "https://github.com/libvips/nip2/releases/download/v"
733 version "/nip2-" version ".tar.gz" ))
735 (base32 "0l7n427njif53npqn02gfjjly8y3khbrkzqxp10j5vp9h97psgiw"))))
736 (build-system gnu-build-system)
739 (modify-phases %standard-phases
740 ;; test_conv.ws keep failing so disabling for now.
741 (add-after 'unpack 'disable-test-conv
743 (delete-file "test/workspaces/test_conv.ws")
745 (add-before 'check 'set-home
747 (setenv "HOME" "/tmp") #t)))))
755 ("libjpeg" ,libjpeg-turbo) ;required by vips.pc
759 ("imagemagick" ,imagemagick)
764 ("openexr" ,openexr-2)
768 (list flex bison pkg-config))
769 (home-page "https://github.com/libvips/nip2")
770 (synopsis "Spreadsheet-like GUI for libvips")
771 (description "This package provide a graphical user interface (GUI) for
772 the VIPS image processing library. It's a little like a spreadsheet: you
773 create a set of formula connecting your objects together, and on a change nip2
775 (license license:gpl2+)))
785 (url "https://github.com/vxl/vxl")
786 (commit (string-append "v" version))))
787 (file-name (git-file-name name version))
789 (base32 "0949hw57szq8943f1whwqaz591xjmb19kj803hcv74hdai2b0ycg"))
790 (modules '((guix build utils)))
791 ;; TODO: vxl includes an old version of dcmtk. It won't build with
795 (for-each delete-file-recursively
802 (substitute* "v3p/CMakeLists.txt"
803 (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
806 (build-system cmake-build-system)
808 (list libgeotiff libtiff libjpeg-turbo libpng zlib))
809 (home-page "https://github.com/vxl/vxl/")
810 (synopsis "Collection of C++ libraries for computer vision")
811 (description "VXL (the Vision-something-Libraries) is a collection of C++
812 libraries designed for computer vision research and implementation.")
813 (license license:bsd-3)))
816 (package (inherit vxl)
823 (url "https://github.com/vxl/vxl")
824 (commit (string-append "v" version))))
825 (file-name (git-file-name name version))
827 (base32 "1g4mr2cc58jwm0vasscbd4y5380wj3ahkvq121z4gs83fhavvxgz"))
828 (modules '((guix build utils)))
831 (for-each delete-file-recursively
837 (substitute* "v3p/CMakeLists.txt"
838 (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
843 ;; Needed for itk-snap
844 (list "-DVNL_CONFIG_LEGACY_METHODS=ON")))))
846 (define-public insight-toolkit
848 (name "insight-toolkit")
853 (uri (string-append "https://github.com/InsightSoftwareConsortium/ITK/"
854 "releases/download/v" version "/InsightToolkit-"
857 (base32 "0bs63mk4q8jmx38f031jy5w5n9yy5ng9x8ijwinvjyvas8cichqi"))))
858 (build-system cmake-build-system)
860 `(#:tests? #f ; tests require network access and external data
863 "-DITK_USE_SYSTEM_LIBRARIES=ON"
864 "-DITK_USE_SYSTEM_GOOGLETEST=ON"
865 "-DITK_BUILD_SHARED=ON"
866 ;; This prevents "GTest::GTest" from being added to the ITK_LIBRARIES
867 ;; variable in the installed CMake files. This is necessary as other
868 ;; packages using insight-toolkit could not be configured otherwise.
869 "-DGTEST_ROOT=gtest")
872 (modify-phases %standard-phases
873 (add-after 'unpack 'do-not-tune
875 (substitute* "CMake/ITKSetStandardCompilerFlags.cmake"
876 (("-mute=native") ""))
884 ("libjpeg" ,libjpeg-turbo)
887 ("mesa" ,mesa-opencl)
894 (list googletest pkg-config))
895 (home-page "https://github.com/InsightSoftwareConsortium/ITK/")
896 (synopsis "Scientific image processing, segmentation and registration")
897 (description "The Insight Toolkit (ITK) is a toolkit for N-dimensional
898 scientific image processing, segmentation, and registration. Segmentation is
899 the process of identifying and classifying data found in a digitally sampled
900 representation. Typically the sampled representation is an image acquired
901 from such medical instrumentation as CT or MRI scanners. Registration is the
902 task of aligning or developing correspondences between data. For example, in
903 the medical environment, a CT scan may be aligned with a MRI scan in order to
904 combine the information contained in both.")
905 (license license:asl2.0)))
907 (define-public insight-toolkit-4
908 (package (inherit insight-toolkit)
913 (uri (string-append "https://github.com/InsightSoftwareConsortium/ITK/"
914 "releases/download/v" version "/InsightToolkit-"
917 (base32 "19cgfpd63gqrvc3m27m394gy2d7w79g5y6lvznb5qqr49lihbgns"))))
919 `(#:tests? #f ; tests require network access and external data
921 '("-DITKV3_COMPATIBILITY=ON" ; needed for itk-snap
923 "-DITK_USE_SYSTEM_LIBRARIES=ON"
924 "-DITK_USE_SYSTEM_GOOGLETEST=ON"
925 "-DITK_USE_SYSTEM_VXL=ON")))))
927 (define-public insight-toolkit-4.12
928 (package (inherit insight-toolkit-4)
933 (uri (string-append "mirror://sourceforge/itk/itk/4.12/"
934 "InsightToolkit-" version ".tar.xz"))
936 (base32 "1qw9mxbh083siljygahl4gdfv91xvfd8hfl7ghwii19f60xrvn2w"))))))
938 (define-public itk-snap
946 (url "https://git.code.sf.net/p/itk-snap/src")
947 (commit (string-append "v" version))))
948 (file-name (git-file-name name version))
950 (base32 "15i5ixpryfrbf3vrrb5rici8fb585f25k0v1ljds16bp1f1msr4q"))))
951 (build-system cmake-build-system)
954 (list "-DSNAP_VERSION_GIT_SHA1=release"
955 "-DSNAP_VERSION_GIT_BRANCH=release"
956 "-DSNAP_VERSION_GIT_TIMESTAMP=0"
957 "-DSNAP_PACKAGE_QT_PLUGINS=OFF"
958 "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
960 (modify-phases %standard-phases
961 ;; During the installation phase all libraries provided by all
962 ;; dependencies will be copied to the lib directory. That's insane,
963 ;; so we disable this.
964 (add-after 'unpack 'do-not-copy-dependencies
966 (substitute* "CMakeLists.txt"
967 (("install_qt5_executable\
968 \\(\\$\\{SNAP_MAIN_INSTALL_DIR\\}/\\$\\{SNAP_EXE\\}\\)")
971 (add-after 'unpack 'disable-gui-tests
973 ;; The GUI tests just time out.
974 (substitute* "CMakeLists.txt"
975 ((" (Workspace|DiffSpace|ProbeIntensity|RegionCompetition\
976 |RandomForest|RandomForestBailOut)")
979 (add-after 'unpack 'make-reproducible
981 (substitute* "CMakeLists.txt"
982 (("TODAY\\(SNAP_VERSION_COMPILE_DATE\\)")
983 "SET(SNAP_VERSION_COMPILE_DATE \"(removed for reproducibility)\")"))
985 (add-after 'unpack 'prepare-submodules
986 (lambda* (#:key inputs #:allow-other-keys)
987 (rmdir "Submodules/c3d")
988 (copy-recursively (assoc-ref inputs "c3d-src")
990 (substitute* '("Submodules/c3d/adapters/BiasFieldCorrectionN4.cxx"
991 "Submodules/c3d/adapters/ApplyMetric.cxx")
993 (rmdir "Submodules/greedy")
994 (symlink (assoc-ref inputs "greedy-src")
997 (add-after 'unpack 'fix-includes
999 (substitute* "GUI/Model/RegistrationModel.cxx"
1000 (("<vnl_symmetric_eigensystem.h>")
1001 "<vnl/algo/vnl_symmetric_eigensystem.h>"))
1003 (add-before 'check 'prepare-tests
1005 ;; Needed by at least one test.
1006 (setenv "HOME" "/tmp")
1008 (add-after 'install 'wrap-executable
1009 (lambda* (#:key inputs outputs #:allow-other-keys)
1010 (let ((out (assoc-ref outputs "out")))
1011 (wrap-program (string-append out "/bin/itksnap")
1012 `("QT_PLUGIN_PATH" ":" prefix
1013 ,(map (lambda (label)
1014 (string-append (assoc-ref inputs label)
1015 "/lib/qt5/plugins"))
1016 '("qtbase" "qtdeclarative"))))
1024 ("mesa" ,mesa-opencl)
1025 ;; This package does not build with either insight-toolkit 5.0.0 and
1026 ;; not with 4.13. It really needs to be 4.12.
1027 ("itk" ,insight-toolkit-4.12)
1029 ("qtbase" ,qtbase-5)
1030 ("qtdeclarative" ,qtdeclarative)
1034 `(("googletest" ,googletest)
1035 ("qttools" ,qttools)
1036 ("pkg-config" ,pkg-config)
1038 ,(let* ((commit "f521358db26e00002c911cc47bf463b043942ad3")
1040 (version (git-version "0" revision commit)))
1044 (url "https://github.com/pyushkevich/c3d")
1046 (file-name (git-file-name "c3d" version))
1049 "0kyv3rxrxwr8c3sa9zv01lsnhk95b27gx1s870k3yi8qp52h7bx3")))))
1050 ;; We are using an arbitrary commit from 2017 because the latest
1051 ;; version breaks the build...
1053 ,(let* ((commit "97e340f7e8e66597599144947775e6039e79a0d3")
1055 (version (git-version "0" revision commit)))
1059 (url "https://github.com/pyushkevich/greedy")
1061 (file-name (git-file-name "greedy" version))
1064 "0k5bc9za4jrc8z9dj08z1rkcp5xf0gnd1d2jmi1w9ny4vxh2q2ab")))))))
1065 (home-page "https://sourceforge.net/p/itk-snap/")
1066 (synopsis "Medical image segmentation")
1067 (description "ITK-SNAP is a tool for segmenting anatomical structures in
1068 medical images. It provides an automatic active contour segmentation
1069 pipeline, along with supporting a manual segmentation toolbox. ITK-SNAP has a
1070 full-featured UI aimed at clinical researchers.")
1071 ;; This includes the submodules greedy and c3d.
1072 (license license:gpl3+)))
1074 (define-public metapixel
1075 ;; Follow stable branch.
1076 (let ((commit "98ee9daa093b6c334941242e63f90b1c2876eb4f"))
1079 (version (git-version "1.0.2" "1" commit))
1084 (url "https://github.com/schani/metapixel")
1086 ;; TODO: Package rwimg and lispreader?
1088 (file-name (git-file-name name version))
1090 (base32 "0r7n3a6bvcxkbpda4mwmrpicii09iql5z69nkjqygkwxw7ny3309"))))
1091 (build-system gnu-build-system)
1093 `(("giflib" ,giflib)
1094 ("libjpeg" ,libjpeg-turbo)
1098 `(("pkg-config" ,pkg-config)
1099 ("docbook-xml" ,docbook-xml)
1100 ("docbook-xsl" ,docbook-xsl)
1101 ("xsltproc" ,libxslt)))
1103 `(#:tests? #f ; No tests.
1105 (string-append "PREFIX=" (assoc-ref %outputs "out"))
1106 (string-append "MANPAGE_XSL="
1107 (assoc-ref %build-inputs "docbook-xsl")
1108 "/xml/xsl/docbook-xsl-*/manpages/docbook.xsl"))
1110 (modify-phases %standard-phases
1112 (add-before 'install 'make-local-docbook-xml
1113 (lambda* (#:key inputs #:allow-other-keys)
1114 (substitute* "metapixel.xml"
1115 (("http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd")
1116 (string-append (assoc-ref inputs "docbook-xml")
1117 "/xml/dtd/docbook/docbookx.dtd")))
1119 (add-before 'install 'fix-directory-creation
1120 (lambda* (#:key outputs #:allow-other-keys)
1121 (mkdir-p (string-append (assoc-ref outputs "out") "/share/man/man1"))
1123 (home-page "https://www.complang.tuwien.ac.at/schani/metapixel/")
1124 (synopsis "Photomosaics generator")
1125 (description "Metapixel is a program for generating photomosaics. It can
1126 generate classical photomosaics, in which the source image is viewed as a
1127 matrix of equally sized rectangles for each of which a matching image is
1128 substituted, as well as collage-style photomosaics, in which rectangular parts
1129 of the source image at arbitrary positions (i.e. not aligned to a matrix) are
1130 substituted by matching images.")
1131 (license license:gpl2))))
1133 (define-public scantailor-advanced
1134 (let ((commit "3d1e74e6ace413733511086934a66f4e3f7a6027"))
1136 (name "scantailor-advanced")
1137 (version (string-append "1.0.16-" (string-take commit 7)))
1142 (url "https://github.com/4lex4/scantailor-advanced")
1144 (file-name (git-file-name name version))
1147 "0kixwjb2x457dq7927hkh34c803p7yh1pmn6n61rk9shqrcg492h"))))
1148 (build-system qt-build-system)
1153 ("libjpeg" ,libjpeg-turbo)
1155 ("libtiff" ,libtiff)
1156 ("qtbase" ,qtbase-5)
1161 (modify-phases %standard-phases
1162 ;; Some tests require a display and fail with offscreen mode.
1163 (add-after 'unpack 'disable-failing-tests
1165 (setenv "ARGS" "--exclude-regex \"imageproc_.*\"")
1167 (home-page "https://github.com/4lex4/scantailor-advanced")
1168 (synopsis "Clean up scanned pages")
1169 (description "Scan Tailor is an interactive post-processing tool for
1170 scanned pages. It performs operations such as page splitting, deskewing,
1171 adding/removing borders, and others. You give it raw scans, and you get pages
1172 ready to be printed or assembled into a PDF or DJVU file. Scanning, optical
1173 character recognition, and assembling multi-page documents are out of scope of
1176 Scan Tailer Advanced is a fork of Scan Tailer that merges Scan Tailor Featured
1177 and Scan Tailor Enhanced versions as well as including many more bug fixes.")
1178 (license license:gpl3+))))
1180 (define-public stiff
1187 (uri (string-append "https://www.astromatic.net/download/stiff/stiff-"
1190 (base32 "14m92dskzw7bwsr64ha4p0mj3ndv13gwcbfic3qxrs3zq5353s7l"))))
1191 (build-system gnu-build-system)
1193 (list libtiff zlib libjpeg-turbo))
1194 (home-page "https://www.astromatic.net/software/stiff")
1195 (synopsis "Convert scientific FITS images to TIFF format")
1197 "STIFF is a program that converts scientific @acronym{FITS, Flexible Image
1198 Transport System} images to the more popular TIFF format for illustration
1200 (license license:gpl3+)))
1202 (define-public python-imgviz
1204 (name "python-imgviz")
1208 ;; PyPi tarball lacks tests.
1211 (url "https://github.com/wkentaro/imgviz.git")
1212 (commit (string-append "v" version))))
1213 (file-name (git-file-name name version))
1215 (base32 "1bm0wdv5p26i8nl4kx3145cz553v401sgbpgc96sddzjfmfiydcw"))))
1216 (build-system python-build-system)
1219 (modify-phases %standard-phases
1221 (lambda* (#:key inputs outputs tests? #:allow-other-keys)
1223 (add-installed-pythonpath inputs outputs)
1224 (invoke "pytest" "-v" "tests"))
1227 (list python-matplotlib python-numpy python-pillow python-pyyaml))
1228 (native-inputs (list python-pytest))
1229 (home-page "http://github.com/wkentaro/imgviz")
1230 (synopsis "Image Visualization Tools")
1231 (description "Python library for object detection, semantic and instance
1233 (license license:expat)))
1235 (define-public labelme
1241 ;; PyPi tarball lacks tests.
1244 (url "https://github.com/wkentaro/labelme.git")
1245 (commit (string-append "v" version))))
1246 (file-name (git-file-name name version))
1248 (base32 "0cmi2xb4dgh7738l259rgwhn9l134f0vnaaqc2gflc5yr3lqhrv2"))))
1249 (build-system python-build-system)
1252 (modify-phases %standard-phases
1253 (add-after 'unpack 'loosen-requirements
1255 ;; Don't require an outdated version of matplotlib.
1256 (substitute* "setup.py"
1257 (("matplotlib<3\\.3")
1259 (add-before 'check 'start-xserver
1260 (lambda* (#:key inputs #:allow-other-keys)
1261 (let ((xorg-server (assoc-ref inputs "xorg-server")))
1262 ;; Options taken from CI workflow.
1263 (system (string-append xorg-server "/bin/Xvfb :99 -screen 0 "
1264 "1920x1200x24 -ac +extension GLX +render "
1266 (setenv "DISPLAY" ":99.0"))))
1268 (lambda* (#:key inputs outputs tests? #:allow-other-keys)
1270 (add-installed-pythonpath inputs outputs)
1271 ;; Fails when invoking help2man for unknown reason.
1272 (delete-file "tests/docs_tests/man_tests/test_labelme_1.py")
1274 (delete-file "tests/labelme_tests/widgets_tests/test_label_dialog.py")
1275 ;; Calls incompatible function signatures.
1276 (delete-file "tests/labelme_tests/widgets_tests/test_label_list_widget.py")
1277 (setenv "MPLBACKEND" "agg")
1278 (invoke "pytest" "-v" "tests" "-m" "not gpu")))))))
1288 (list python-pytest python-pytest-qt xorg-server-for-tests))
1289 (home-page "https://github.com/wkentaro/labelme")
1291 "Image Polygonal Annotation")
1293 "Image and video labeling tool supporting different shapes like
1294 polygons, rectangles, circles, lines, points and VOC/COCO export.")
1295 (license license:gpl3+)))