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