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