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