gnu: Add stiff.
[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 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 (build-system cmake-build-system)
257 (arguments
258 '(#:build-type "Release" ;Build without '-g' to save space.
259 ;; -DVTK_USE_SYSTEM_NETCDF:BOOL=TRUE requires netcdf_cxx
260 #:configure-flags '("-DVTK_USE_SYSTEM_EXPAT:BOOL=TRUE"
261 "-DVTK_USE_SYSTEM_FREETYPE:BOOL=TRUE"
262 "-DVTK_USE_SYSTEM_HDF5:BOOL=TRUE"
263 "-DVTK_USE_SYSTEM_JPEG:BOOL=TRUE"
264 "-DVTK_USE_SYSTEM_JSONCPP:BOOL=TRUE"
265 "-DVTK_USE_SYSTEM_LIBXML2:BOOL=TRUE"
266 "-DVTK_USE_SYSTEM_OGGTHEORA:BOOL=TRUE"
267 "-DVTK_USE_SYSTEM_PNG:BOOL=TRUE"
268 "-DVTK_USE_SYSTEM_TIFF:BOOL=TRUE"
269 "-DVTK_USE_SYSTEM_ZLIB:BOOL=TRUE")
270 #:tests? #f)) ;XXX: no "test" target
271 (inputs
272 `(("libXt" ,libxt)
273 ("xorgproto" ,xorgproto)
274 ("libX11" ,libx11)
275 ("libxml2" ,libxml2)
276 ("mesa" ,mesa)
277 ("glu" ,glu)
278 ("expat" ,expat)
279 ("freetype" ,freetype)
280 ("hdf5" ,hdf5)
281 ("jpeg" ,libjpeg-turbo)
282 ("jsoncpp" ,jsoncpp)
283 ("libogg" ,libogg)
284 ("libtheora" ,libtheora)
285 ("png" ,libpng)
286 ("tiff" ,libtiff)
287 ("zlib" ,zlib)))
288 (home-page "https://vtk.org/")
289 (synopsis "Libraries for 3D computer graphics")
290 (description
291 "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
292 image processing and visualization. It supports a wide variety of
293 visualization algorithms including: scalar, vector, tensor, texture, and
294 volumetric methods; and advanced modeling techniques such as: implicit
295 modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay
296 triangulation. VTK has an extensive information visualization framework, has
297 a suite of 3D interaction widgets, supports parallel processing, and
298 integrates with various databases on GUI toolkits such as Qt and Tk.")
299 (license license:bsd-3)))
300
301 ;; itksnap needs an older variant of VTK.
302 (define-public vtk-6
303 (package (inherit vtk)
304 (version "6.3.0")
305 (source (origin
306 (method url-fetch)
307 (uri (string-append "https://vtk.org/files/release/"
308 (version-major+minor version)
309 "/VTK-" version ".tar.gz"))
310 (sha256
311 (base32
312 "0pla1r5mvkgl4sl213gfdhzrypdgai0h3z5mfgm6p9jz9hsr794j"))))
313 (inputs
314 `(("jsoncpp" ,jsoncpp-for-tensorflow)
315 ,@(alist-delete "jsoncpp" (package-inputs vtk))))))
316
317 (define-public opencv
318 (package
319 (name "opencv")
320 (version "3.4.3")
321 (source (origin
322 (method git-fetch)
323 (uri (git-reference
324 (url "https://github.com/opencv/opencv")
325 (commit version)))
326 (file-name (git-file-name name version))
327 (sha256
328 (base32
329 "06bc61r8myym4s8im10brdjfg4wxkrvsbhhl7vr1msdan2xddzi3"))
330 (patches
331 (search-patches "opencv-fix-build-of-grfmt_jpeg2000.cpp.patch"))
332 (modules '((guix build utils)))
333 (snippet
334 '(begin
335 ;; Remove external libraries. We have all available in Guix:
336 (delete-file-recursively "3rdparty")
337
338 ;; Milky icon set is non-free:
339 (delete-file-recursively "modules/highgui/src/files_Qt/Milky")
340
341 ;; Some jars found:
342 (for-each delete-file
343 '("modules/java/test/pure_test/lib/junit-4.11.jar"
344 "samples/java/sbt/sbt/sbt-launch.jar"))
345 #t))))
346 (build-system cmake-build-system)
347 (arguments
348 `(#:configure-flags
349 (list "-DWITH_IPP=OFF"
350 "-DWITH_ITT=OFF"
351 "-DWITH_CAROTENE=OFF" ; only visible on arm/aarch64
352 "-DENABLE_PRECOMPILED_HEADERS=OFF"
353
354 ;; CPU-Features:
355 ;; See cmake/OpenCVCompilerOptimizations.cmake
356 ;; (CPU_ALL_OPTIMIZATIONS) for a list of all optimizations
357 ;; BASELINE is the minimum optimization all CPUs must support
358 ;;
359 ;; DISPATCH is the list of optional dispatches.
360 "-DCPU_BASELINE=SSE2"
361
362 ,@(match (%current-system)
363 ("x86_64-linux"
364 '("-DCPU_DISPATCH=NEON;VFPV3;FP16;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX"
365 "-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2"))
366 ("armhf-linux"
367 '("-DCPU_BASELINE_DISABLE=NEON")) ; causes build failures
368 ("aarch64-linux"
369 '("-DCPU_BASELINE=NEON"
370 "-DCPU_DISPATCH=NEON;VFPV3;FP16"))
371 (_ '()))
372
373 "-DBUILD_PERF_TESTS=OFF"
374 "-DBUILD_TESTS=ON"
375
376 (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
377 "/opencv-contrib/modules")
378
379 ;;Define test data:
380 (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
381 "/opencv-extra/testdata")
382
383 ;; Is ON by default and would try to rebuild 3rd-party protobuf,
384 ;; which we had removed, which would lead to an error:
385 "-DBUILD_PROTOBUF=OFF"
386
387 ;; Rebuild protobuf files, because we have a slightly different
388 ;; version than the included one. If we would not update, we
389 ;; would get a compile error later:
390 "-DPROTOBUF_UPDATE_FILES=ON"
391
392 ;; xfeatures2d disabled, because it downloads extra binaries from
393 ;; https://github.com/opencv/opencv_3rdparty
394 ;; defined in xfeatures2d/cmake/download_{vgg|bootdesc}.cmake
395 ;; Cmp this bug entry:
396 ;; https://github.com/opencv/opencv_contrib/issues/1131
397 "-DBUILD_opencv_xfeatures2d=OFF")
398 #:phases
399 (modify-phases %standard-phases
400 (add-after 'unpack 'disable-broken-tests
401 (lambda _
402 ;; These tests fails with:
403 ;; vtkXOpenGLRenderWindow (0x723990): Could not find a decent config
404 ;; I think we have no OpenGL support with the Xvfb.
405 (substitute* '("modules/viz/test/test_tutorial3.cpp"
406 "modules/viz/test/test_main.cpp"
407 "modules/viz/test/tests_simple.cpp"
408 "modules/viz/test/test_viz3d.cpp")
409 (("(TEST\\(Viz, )([a-z].*\\).*)" all pre post)
410 (string-append pre "DISABLED_" post)))
411
412 ;; This one fails with "unknown file: Failure"
413 ;; But I couldn't figure out which file was missing:
414 (substitute* "../opencv-contrib/modules/face/test/test_face_align.cpp"
415 (("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)"
416 all pre post)
417 (string-append pre "DISABLED_" post)))
418
419 ;; Failure reason: Bad accuracy
420 ;; Incorrect count of accurate poses [2nd case]: 90.000000 / 94.000000
421 (substitute* "../opencv-contrib/modules/rgbd/test/test_odometry.cpp"
422 (("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post)
423 (string-append pre "DISABLED_" post)))
424 #t))
425
426 (add-after 'unpack 'unpack-submodule-sources
427 (lambda* (#:key inputs #:allow-other-keys)
428 (mkdir "../opencv-extra")
429 (mkdir "../opencv-contrib")
430 (copy-recursively (assoc-ref inputs "opencv-extra")
431 "../opencv-extra")
432 (invoke "tar" "xvf"
433 (assoc-ref inputs "opencv-contrib")
434 "--strip-components=1"
435 "-C" "../opencv-contrib")))
436
437 (add-after 'set-paths 'add-ilmbase-include-path
438 (lambda* (#:key inputs #:allow-other-keys)
439 ;; OpenEXR propagates ilmbase, but its include files do not appear
440 ;; in the CPATH, so we need to add "$ilmbase/include/OpenEXR/" to
441 ;; the CPATH to satisfy the dependency on "ImathVec.h".
442 (setenv "CPATH"
443 (string-append (assoc-ref inputs "ilmbase")
444 "/include/OpenEXR"
445 ":" (or (getenv "CPATH") "")))
446 #t))
447 (add-before 'check 'start-xserver
448 (lambda* (#:key inputs #:allow-other-keys)
449 (let ((xorg-server (assoc-ref inputs "xorg-server"))
450 (disp ":1"))
451 (setenv "HOME" (getcwd))
452 (setenv "DISPLAY" disp)
453 ;; There must be a running X server and make check doesn't start one.
454 ;; Therefore we must do it.
455 (zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp)))))))))
456 (native-inputs
457 `(("pkg-config" ,pkg-config)
458 ("xorg-server" ,xorg-server-for-tests) ; For running the tests
459 ("opencv-extra"
460 ,(origin
461 (method git-fetch)
462 (uri (git-reference
463 (url "https://github.com/opencv/opencv_extra")
464 (commit version)))
465 (file-name (git-file-name "opencv_extra" version))
466 (sha256
467 (base32 "08p5xnq8n1jw8svvz0fnirfg7q8dm3p4a5dl7527s5xj0f9qn7lp"))))
468 ("opencv-contrib"
469 ,(origin
470 (method git-fetch)
471 (uri (git-reference
472 (url "https://github.com/opencv/opencv_contrib")
473 (commit version)))
474 (file-name (git-file-name "opencv_contrib" version))
475 (patches (search-patches "opencv-rgbd-aarch64-test-fix.patch"))
476 (sha256
477 (base32 "1f334glf39nk42mpqq6j732h3ql2mpz89jd4mcl678s8n73nfjh2"))))))
478 (inputs `(("libjpeg" ,libjpeg-turbo)
479 ("libpng" ,libpng)
480 ("jasper" ,jasper)
481 ;; ffmpeg 4.0 causes core dumps in tests.
482 ("ffmpeg" ,ffmpeg-3.4)
483 ("libtiff" ,libtiff)
484 ("hdf5" ,hdf5)
485 ("libgphoto2" ,libgphoto2)
486 ("libwebp" ,libwebp)
487 ("zlib" ,zlib)
488 ("gtkglext" ,gtkglext)
489 ("openexr" ,openexr)
490 ("ilmbase" ,ilmbase)
491 ("gtk+" ,gtk+-2)
492 ("python-numpy" ,python-numpy)
493 ("protobuf" ,protobuf)
494 ("vtk" ,vtk)
495 ("python" ,python)))
496 ;; These three CVEs are not a problem of OpenCV, see:
497 ;; https://github.com/opencv/opencv/issues/10998
498 (properties '((lint-hidden-cve . ("CVE-2018-7712"
499 "CVE-2018-7713"
500 "CVE-2018-7714"))))
501 (synopsis "Computer vision library")
502 (description "OpenCV is a library aimed at
503 real-time computer vision, including several hundred computer
504 vision algorithms. It can be used to do things like:
505
506 @itemize
507 @item image and video input and output
508 @item image and video processing
509 @item displaying
510 @item feature recognition
511 @item segmentation
512 @item facial recognition
513 @item stereo vision
514 @item structure from motion
515 @item augmented reality
516 @item machine learning
517 @end itemize\n")
518 (home-page "https://opencv.org/")
519 (license license:bsd-3)))
520
521 (define-public vips
522 (package
523 (name "vips")
524 (version "8.10.5")
525 (source
526 (origin
527 (method url-fetch)
528 (uri (string-append
529 "https://github.com/libvips/libvips/releases/download/v"
530 version "/vips-" version ".tar.gz"))
531 (sha256
532 (base32 "1n6gw7cw66rfn1wdb92ydpkv7gfmjiinsg6d6gqxpdja6gsz5vm4"))))
533 (build-system gnu-build-system)
534 (native-inputs
535 `(("gobject-introspection" ,gobject-introspection)
536 ("pkg-config" ,pkg-config)))
537 (inputs
538 `(("expat" ,expat)
539 ("fftw" ,fftw)
540 ("giflib" ,giflib)
541 ("glib" ,glib)
542 ("hdf5" ,hdf5)
543 ("imagemagick" ,imagemagick)
544 ("lcms" ,lcms)
545 ("libexif" ,libexif)
546 ("libgsf" ,libgsf)
547 ("libjpeg" ,libjpeg-turbo)
548 ("libpng" ,libpng)
549 ("librsvg" ,librsvg)
550 ("libtiff" ,libtiff)
551 ("libxml2" ,libxml2)
552 ("libwebp" ,libwebp)
553 ("matio" ,matio)
554 ("niftilib" ,niftilib)
555 ("openexr" ,openexr)
556 ("orc" ,orc)
557 ("pango" ,pango)
558 ("poppler" ,poppler)))
559 (home-page "https://libvips.github.io/libvips/")
560 (synopsis "Multithreaded image processing system with low memory needs")
561 (description
562 "VIPS is a demand-driven, horizontally threaded image processing library.
563 It's particularly good at processing large images, working with colour,
564 scientific analysis, and general research & development.
565
566 Compared to most image processing libraries VIPS needs little RAM and runs
567 quickly, especially on machines with more than one CPU core. This is primarily
568 due to its architecture which automatically parallelises the image workflows.")
569 (license license:lgpl2.1+)))
570
571 (define-public gmic
572 (package
573 (name "gmic")
574 (version "2.9.2")
575 (source
576 (origin
577 (method url-fetch)
578 (uri (string-append "https://gmic.eu/files/source/gmic_"
579 version ".tar.gz"))
580 (sha256
581 (base32 "14acph914a8lp6qqfmp319ggqjg3i3hmalmnpk3mp07m7vpv2p9q"))))
582 (build-system cmake-build-system)
583 (arguments
584 `(#:tests? #f)) ;there are no tests
585 (native-inputs
586 `(("pkg-config" ,pkg-config)))
587 (inputs
588 `(("curl" ,curl)
589 ("fftw" ,fftw)
590 ("graphicsmagick" ,graphicsmagick)
591 ("libjpeg-turbo" ,libjpeg-turbo)
592 ("libpng" ,libpng)
593 ("libtiff" ,libtiff)
594 ("libx11" ,libx11)
595 ;;("opencv" ,opencv) ;OpenCV is currently broken in the CI
596 ("openexr" ,openexr)
597 ("zlib" ,zlib)))
598 (home-page "https://gmic.eu/")
599 (synopsis "Full-featured framework for digital image processing")
600 (description "G'MIC is a full-featured framework for digital image
601 processing. It provides several user interfaces to convert / manipulate
602 / filter / visualize generic image datasets, ranging from 1D scalar
603 signals to 3D+t sequences of multi-spectral volumetric images, hence
604 including 2D color images.")
605 ;; Dual-licensed, either license applies.
606 (license (list license:cecill license:cecill-c))))
607
608 (define-public nip2
609 (package
610 (name "nip2")
611 (version "8.7.1")
612 (source
613 (origin
614 (method url-fetch)
615 (uri (string-append "https://github.com/libvips/nip2/releases/download/v"
616 version "/nip2-" version ".tar.gz" ))
617 (sha256
618 (base32 "0l7n427njif53npqn02gfjjly8y3khbrkzqxp10j5vp9h97psgiw"))))
619 (build-system gnu-build-system)
620 (arguments
621 `(#:phases
622 (modify-phases %standard-phases
623 ;; test_conv.ws keep failing so disabling for now.
624 (add-after 'unpack 'disable-test-conv
625 (lambda _
626 (delete-file "test/workspaces/test_conv.ws")
627 #t))
628 (add-before 'check 'set-home
629 (lambda _
630 (setenv "HOME" "/tmp") #t)))))
631 (inputs
632 `(("vips" ,vips)
633 ("glib" ,glib)
634 ("libtiff" ,libtiff)
635 ("gtk+-2" ,gtk+-2)
636 ("libxml2" ,libxml2)
637 ("libexif" ,libexif)
638 ("libjpeg" ,libjpeg-turbo) ;required by vips.pc
639 ("librsvg" ,librsvg)
640 ("fftw" ,fftw)
641 ("libgsf" ,libgsf)
642 ("imagemagick" ,imagemagick)
643 ("orc" ,orc)
644 ("matio" ,matio)
645 ("lcms" ,lcms)
646 ("libwebp" ,libwebp)
647 ("openexr" ,openexr)
648 ("poppler" ,poppler)
649 ("gsl" ,gsl)))
650 (native-inputs
651 `(("flex" ,flex)
652 ("bison" ,bison)
653 ("pkg-config" ,pkg-config)))
654 (home-page "https://github.com/libvips/nip2")
655 (synopsis "Spreadsheet-like GUI for libvips")
656 (description "This package provide a graphical user interface (GUI) for
657 the VIPS image processing library. It's a little like a spreadsheet: you
658 create a set of formula connecting your objects together, and on a change nip2
659 recalculates.")
660 (license license:gpl2+)))
661
662 (define-public vxl
663 (package
664 (name "vxl")
665 (version "2.0.2")
666 (source
667 (origin
668 (method git-fetch)
669 (uri (git-reference
670 (url "https://github.com/vxl/vxl")
671 (commit (string-append "v" version))))
672 (file-name (git-file-name name version))
673 (sha256
674 (base32 "0949hw57szq8943f1whwqaz591xjmb19kj803hcv74hdai2b0ycg"))
675 (modules '((guix build utils)))
676 ;; TODO: vxl includes an old version of dcmtk. It won't build with
677 ;; version 3.6.x.
678 (snippet
679 '(begin
680 (for-each delete-file-recursively
681 '("v3p/bzlib/"
682 "v3p/geotiff/"
683 "v3p/jpeg/"
684 "v3p/png/"
685 "v3p/tiff/"
686 "v3p/zlib/"))
687 (substitute* "v3p/CMakeLists.txt"
688 (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
689 ""))
690 #t))))
691 (build-system cmake-build-system)
692 (inputs
693 `(("libgeotiff" ,libgeotiff)
694 ("libtiff" ,libtiff)
695 ("libjpeg" ,libjpeg-turbo)
696 ("libpng" ,libpng)
697 ("zlib" ,zlib)))
698 (home-page "https://github.com/vxl/vxl/")
699 (synopsis "Collection of C++ libraries for computer vision")
700 (description "VXL (the Vision-something-Libraries) is a collection of C++
701 libraries designed for computer vision research and implementation.")
702 (license license:bsd-3)))
703
704 (define-public vxl-1
705 (package (inherit vxl)
706 (name "vxl")
707 (version "1.18.0")
708 (source
709 (origin
710 (method git-fetch)
711 (uri (git-reference
712 (url "https://github.com/vxl/vxl")
713 (commit (string-append "v" version))))
714 (file-name (git-file-name name version))
715 (sha256
716 (base32 "1g4mr2cc58jwm0vasscbd4y5380wj3ahkvq121z4gs83fhavvxgz"))
717 (modules '((guix build utils)))
718 (snippet
719 '(begin
720 (for-each delete-file-recursively
721 '("v3p/bzlib/"
722 "v3p/geotiff/"
723 "v3p/png/"
724 "v3p/tiff/"
725 "v3p/zlib/"))
726 (substitute* "v3p/CMakeLists.txt"
727 (("add_subdirectory\\((tiff|png|jpeg|zlib|bzlib|geotiff)\\)")
728 ""))
729 #t))))
730 (arguments
731 `(#:configure-flags
732 ;; Needed for itk-snap
733 (list "-DVNL_CONFIG_LEGACY_METHODS=ON")))))
734
735 (define-public insight-toolkit
736 (package
737 (name "insight-toolkit")
738 (version "5.0.0")
739 (source
740 (origin
741 (method url-fetch)
742 (uri (string-append "https://github.com/InsightSoftwareConsortium/ITK/"
743 "releases/download/v" version "/InsightToolkit-"
744 version ".tar.xz"))
745 (sha256
746 (base32 "0bs63mk4q8jmx38f031jy5w5n9yy5ng9x8ijwinvjyvas8cichqi"))))
747 (build-system cmake-build-system)
748 (arguments
749 `(#:tests? #f ; tests require network access and external data
750 #:configure-flags
751 '("-DITK_USE_GPU=ON"
752 "-DITK_USE_SYSTEM_LIBRARIES=ON"
753 "-DITK_USE_SYSTEM_GOOGLETEST=ON"
754 "-DITK_BUILD_SHARED=ON"
755 ;; This prevents "GTest::GTest" from being added to the ITK_LIBRARIES
756 ;; variable in the installed CMake files. This is necessary as other
757 ;; packages using insight-toolkit could not be configured otherwise.
758 "-DGTEST_ROOT=gtest")
759 #:phases
760 (modify-phases %standard-phases
761 (add-after 'unpack 'do-not-tune
762 (lambda _
763 (substitute* "CMake/ITKSetStandardCompilerFlags.cmake"
764 (("-mute=native") ""))
765 #t)))))
766 (inputs
767 `(("eigen" ,eigen)
768 ("expat" ,expat)
769 ("fftw" ,fftw)
770 ("fftwf" ,fftwf)
771 ("hdf5" ,hdf5)
772 ("libjpeg" ,libjpeg-turbo)
773 ("libpng" ,libpng)
774 ("libtiff" ,libtiff)
775 ("mesa" ,mesa-opencl)
776 ("perl" ,perl)
777 ("python" ,python)
778 ("tbb" ,tbb)
779 ("vxl" ,vxl-1)
780 ("zlib" ,zlib)))
781 (native-inputs
782 `(("googletest" ,googletest)
783 ("pkg-config" ,pkg-config)))
784 (home-page "https://github.com/InsightSoftwareConsortium/ITK/")
785 (synopsis "Scientific image processing, segmentation and registration")
786 (description "The Insight Toolkit (ITK) is a toolkit for N-dimensional
787 scientific image processing, segmentation, and registration. Segmentation is
788 the process of identifying and classifying data found in a digitally sampled
789 representation. Typically the sampled representation is an image acquired
790 from such medical instrumentation as CT or MRI scanners. Registration is the
791 task of aligning or developing correspondences between data. For example, in
792 the medical environment, a CT scan may be aligned with a MRI scan in order to
793 combine the information contained in both.")
794 (license license:asl2.0)))
795
796 (define-public insight-toolkit-4
797 (package (inherit insight-toolkit)
798 (version "4.13.2")
799 (source
800 (origin
801 (method url-fetch)
802 (uri (string-append "https://github.com/InsightSoftwareConsortium/ITK/"
803 "releases/download/v" version "/InsightToolkit-"
804 version ".tar.xz"))
805 (sha256
806 (base32 "19cgfpd63gqrvc3m27m394gy2d7w79g5y6lvznb5qqr49lihbgns"))))
807 (arguments
808 `(#:tests? #f ; tests require network access and external data
809 #:configure-flags
810 '("-DITKV3_COMPATIBILITY=ON" ; needed for itk-snap
811 "-DITK_USE_GPU=ON"
812 "-DITK_USE_SYSTEM_LIBRARIES=ON"
813 "-DITK_USE_SYSTEM_GOOGLETEST=ON"
814 "-DITK_USE_SYSTEM_VXL=ON")))))
815
816 (define-public insight-toolkit-4.12
817 (package (inherit insight-toolkit-4)
818 (version "4.12.2")
819 (source
820 (origin
821 (method url-fetch)
822 (uri (string-append "mirror://sourceforge/itk/itk/4.12/"
823 "InsightToolkit-" version ".tar.xz"))
824 (sha256
825 (base32 "1qw9mxbh083siljygahl4gdfv91xvfd8hfl7ghwii19f60xrvn2w"))))))
826
827 (define-public itk-snap
828 (package
829 (name "itk-snap")
830 (version "3.8.0")
831 (source
832 (origin
833 (method git-fetch)
834 (uri (git-reference
835 (url "https://git.code.sf.net/p/itk-snap/src")
836 (commit (string-append "v" version))))
837 (file-name (git-file-name name version))
838 (sha256
839 (base32 "15i5ixpryfrbf3vrrb5rici8fb585f25k0v1ljds16bp1f1msr4q"))))
840 (build-system cmake-build-system)
841 (arguments
842 `(#:configure-flags
843 (list "-DSNAP_VERSION_GIT_SHA1=release"
844 "-DSNAP_VERSION_GIT_BRANCH=release"
845 "-DSNAP_VERSION_GIT_TIMESTAMP=0"
846 "-DSNAP_PACKAGE_QT_PLUGINS=OFF"
847 "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
848 #:phases
849 (modify-phases %standard-phases
850 ;; During the installation phase all libraries provided by all
851 ;; dependencies will be copied to the lib directory. That's insane,
852 ;; so we disable this.
853 (add-after 'unpack 'do-not-copy-dependencies
854 (lambda _
855 (substitute* "CMakeLists.txt"
856 (("install_qt5_executable\
857 \\(\\$\\{SNAP_MAIN_INSTALL_DIR\\}/\\$\\{SNAP_EXE\\}\\)")
858 ""))
859 #t))
860 (add-after 'unpack 'disable-gui-tests
861 (lambda _
862 ;; The GUI tests just time out.
863 (substitute* "CMakeLists.txt"
864 ((" (Workspace|DiffSpace|ProbeIntensity|RegionCompetition\
865 |RandomForest|RandomForestBailOut)")
866 ""))
867 #t))
868 (add-after 'unpack 'make-reproducible
869 (lambda _
870 (substitute* "CMakeLists.txt"
871 (("TODAY\\(SNAP_VERSION_COMPILE_DATE\\)")
872 "SET(SNAP_VERSION_COMPILE_DATE \"(removed for reproducibility)\")"))
873 #t))
874 (add-after 'unpack 'prepare-submodules
875 (lambda* (#:key inputs #:allow-other-keys)
876 (rmdir "Submodules/c3d")
877 (copy-recursively (assoc-ref inputs "c3d-src")
878 "Submodules/c3d")
879 (substitute* '("Submodules/c3d/adapters/BiasFieldCorrectionN4.cxx"
880 "Submodules/c3d/adapters/ApplyMetric.cxx")
881 (("vcl_") "std::"))
882 (rmdir "Submodules/greedy")
883 (symlink (assoc-ref inputs "greedy-src")
884 "Submodules/greedy")
885 #t))
886 (add-after 'unpack 'fix-includes
887 (lambda _
888 (substitute* "GUI/Model/RegistrationModel.cxx"
889 (("<vnl_symmetric_eigensystem.h>")
890 "<vnl/algo/vnl_symmetric_eigensystem.h>"))
891 #t))
892 (add-before 'check 'prepare-tests
893 (lambda _
894 ;; Needed by at least one test.
895 (setenv "HOME" "/tmp")
896 #t))
897 (add-after 'install 'wrap-executable
898 (lambda* (#:key inputs outputs #:allow-other-keys)
899 (let ((out (assoc-ref outputs "out")))
900 (wrap-program (string-append out "/bin/itksnap")
901 `("QT_PLUGIN_PATH" ":" prefix
902 ,(map (lambda (label)
903 (string-append (assoc-ref inputs label)
904 "/lib/qt5/plugins"))
905 '("qtbase" "qtdeclarative"))))
906 #t))))))
907 (inputs
908 `(("curl" ,curl)
909 ("fftw" ,fftw)
910 ("fftwf" ,fftwf)
911 ("glu" ,glu)
912 ("hdf5" ,hdf5)
913 ("mesa" ,mesa-opencl)
914 ;; This package does not build with either insight-toolkit 5.0.0 and
915 ;; not with 4.13. It really needs to be 4.12.
916 ("itk" ,insight-toolkit-4.12)
917 ("vtk" ,vtk-6)
918 ("qtbase" ,qtbase)
919 ("qtdeclarative" ,qtdeclarative)
920 ("vxl" ,vxl-1)
921 ("zlib" ,zlib)))
922 (native-inputs
923 `(("googletest" ,googletest)
924 ("qttools" ,qttools)
925 ("pkg-config" ,pkg-config)
926 ("c3d-src"
927 ,(let* ((commit "f521358db26e00002c911cc47bf463b043942ad3")
928 (revision "1")
929 (version (git-version "0" revision commit)))
930 (origin
931 (method git-fetch)
932 (uri (git-reference
933 (url "https://github.com/pyushkevich/c3d")
934 (commit commit)))
935 (file-name (git-file-name "c3d" version))
936 (sha256
937 (base32
938 "0kyv3rxrxwr8c3sa9zv01lsnhk95b27gx1s870k3yi8qp52h7bx3")))))
939 ;; We are using an arbitrary commit from 2017 because the latest
940 ;; version breaks the build...
941 ("greedy-src"
942 ,(let* ((commit "97e340f7e8e66597599144947775e6039e79a0d3")
943 (revision "1")
944 (version (git-version "0" revision commit)))
945 (origin
946 (method git-fetch)
947 (uri (git-reference
948 (url "https://github.com/pyushkevich/greedy")
949 (commit commit)))
950 (file-name (git-file-name "greedy" version))
951 (sha256
952 (base32
953 "0k5bc9za4jrc8z9dj08z1rkcp5xf0gnd1d2jmi1w9ny4vxh2q2ab")))))))
954 (home-page "https://sourceforge.net/p/itk-snap/")
955 (synopsis "Medical image segmentation")
956 (description "ITK-SNAP is a tool for segmenting anatomical structures in
957 medical images. It provides an automatic active contour segmentation
958 pipeline, along with supporting a manual segmentation toolbox. ITK-SNAP has a
959 full-featured UI aimed at clinical researchers.")
960 ;; This includes the submodules greedy and c3d.
961 (license license:gpl3+)))
962
963 (define-public metapixel
964 ;; Follow stable branch.
965 (let ((commit "98ee9daa093b6c334941242e63f90b1c2876eb4f"))
966 (package
967 (name "metapixel")
968 (version (git-version "1.0.2" "1" commit))
969 (source
970 (origin
971 (method git-fetch)
972 (uri (git-reference
973 (url "https://github.com/schani/metapixel")
974 (commit commit)
975 ;; TODO: Package rwimg and lispreader?
976 (recursive? #t)))
977 (file-name (git-file-name name version))
978 (sha256
979 (base32 "0r7n3a6bvcxkbpda4mwmrpicii09iql5z69nkjqygkwxw7ny3309"))))
980 (build-system gnu-build-system)
981 (inputs
982 `(("giflib" ,giflib)
983 ("libjpeg" ,libjpeg-turbo)
984 ("libpng" ,libpng)
985 ("perl" ,perl)))
986 (native-inputs
987 `(("pkg-config" ,pkg-config)
988 ("docbook-xml" ,docbook-xml)
989 ("docbook-xsl" ,docbook-xsl)
990 ("xsltproc" ,libxslt)))
991 (arguments
992 `(#:tests? #f ; No tests.
993 #:make-flags (list
994 (string-append "PREFIX=" (assoc-ref %outputs "out"))
995 (string-append "MANPAGE_XSL="
996 (assoc-ref %build-inputs "docbook-xsl")
997 "/xml/xsl/docbook-xsl-*/manpages/docbook.xsl"))
998 #:phases
999 (modify-phases %standard-phases
1000 (delete 'configure)
1001 (add-before 'install 'make-local-docbook-xml
1002 (lambda* (#:key inputs #:allow-other-keys)
1003 (substitute* "metapixel.xml"
1004 (("http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd")
1005 (string-append (assoc-ref inputs "docbook-xml")
1006 "/xml/dtd/docbook/docbookx.dtd")))
1007 #t))
1008 (add-before 'install 'fix-directory-creation
1009 (lambda* (#:key outputs #:allow-other-keys)
1010 (mkdir-p (string-append (assoc-ref outputs "out") "/share/man/man1"))
1011 #t)))))
1012 (home-page "https://www.complang.tuwien.ac.at/schani/metapixel/")
1013 (synopsis "Photomosaics generator")
1014 (description "Metapixel is a program for generating photomosaics. It can
1015 generate classical photomosaics, in which the source image is viewed as a
1016 matrix of equally sized rectangles for each of which a matching image is
1017 substituted, as well as collage-style photomosaics, in which rectangular parts
1018 of the source image at arbitrary positions (i.e. not aligned to a matrix) are
1019 substituted by matching images.")
1020 (license license:gpl2))))
1021
1022 (define-public scantailor-advanced
1023 (let ((commit "3d1e74e6ace413733511086934a66f4e3f7a6027"))
1024 (package
1025 (name "scantailor-advanced")
1026 (version (string-append "1.0.16-" (string-take commit 7)))
1027 (source
1028 (origin
1029 (method git-fetch)
1030 (uri (git-reference
1031 (url "https://github.com/4lex4/scantailor-advanced")
1032 (commit commit)))
1033 (file-name (git-file-name name version))
1034 (sha256
1035 (base32
1036 "0kixwjb2x457dq7927hkh34c803p7yh1pmn6n61rk9shqrcg492h"))))
1037 (build-system qt-build-system)
1038 (native-inputs
1039 `(("qttools" ,qttools)))
1040 (inputs
1041 `(("boost" ,boost)
1042 ("libjpeg" ,libjpeg-turbo)
1043 ("libpng" ,libpng)
1044 ("libtiff" ,libtiff)
1045 ("qtbase" ,qtbase)
1046 ("qtsvg" ,qtsvg)
1047 ("zlib" ,zlib)))
1048 (arguments
1049 `(#:phases
1050 (modify-phases %standard-phases
1051 ;; Some tests require a display and fail with offscreen mode.
1052 (add-after 'unpack 'disable-failing-tests
1053 (lambda _
1054 (setenv "ARGS" "--exclude-regex \"imageproc_.*\"")
1055 #t)))))
1056 (home-page "https://github.com/4lex4/scantailor-advanced")
1057 (synopsis "Clean up scanned pages")
1058 (description "Scan Tailor is an interactive post-processing tool for
1059 scanned pages. It performs operations such as page splitting, deskewing,
1060 adding/removing borders, and others. You give it raw scans, and you get pages
1061 ready to be printed or assembled into a PDF or DJVU file. Scanning, optical
1062 character recognition, and assembling multi-page documents are out of scope of
1063 this project.
1064
1065 Scan Tailer Advanced is a fork of Scan Tailer that merges Scan Tailor Featured
1066 and Scan Tailor Enhanced versions as well as including many more bug fixes.")
1067 (license license:gpl3+))))
1068
1069 (define-public stiff
1070 (package
1071 (name "stiff")
1072 (version "2.4.0")
1073 (source
1074 (origin
1075 (method url-fetch)
1076 (uri (string-append "https://www.astromatic.net/download/stiff/stiff-"
1077 version ".tar.gz"))
1078 (sha256
1079 (base32 "14m92dskzw7bwsr64ha4p0mj3ndv13gwcbfic3qxrs3zq5353s7l"))))
1080 (build-system gnu-build-system)
1081 (inputs
1082 `(("libtiff" ,libtiff)
1083 ("zlib" ,zlib)
1084 ("libjpeg-turbo" ,libjpeg-turbo)))
1085 (home-page "https://www.astromatic.net/software/stiff")
1086 (synopsis "Convert scientific FITS images to TIFF format")
1087 (description
1088 "STIFF is a program that converts scientific @acronym{FITS, Flexible Image
1089 Transport System} images to the more popular TIFF format for illustration
1090 purposes.")
1091 (license license:gpl3+)))