gnu: dcmtk: Update to 3.6.4.
[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 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 ;;;
12 ;;; This file is part of GNU Guix.
13 ;;;
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
18 ;;;
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27 (define-module (gnu packages image-processing)
28 #:use-module ((guix licenses) #:prefix license:)
29 #:use-module (guix packages)
30 #:use-module (guix utils)
31 #:use-module (guix download)
32 #:use-module (guix git-download)
33 #:use-module (guix build-system cmake)
34 #:use-module (guix build-system gnu)
35 #:use-module (gnu packages)
36 #:use-module (gnu packages algebra)
37 #:use-module (gnu packages bison)
38 #:use-module (gnu packages boost)
39 #:use-module (gnu packages compression)
40 #:use-module (gnu packages documentation)
41 #:use-module (gnu packages flex)
42 #:use-module (gnu packages fontutils)
43 #:use-module (gnu packages ghostscript)
44 #:use-module (gnu packages gl)
45 #:use-module (gnu packages glib)
46 #:use-module (gnu packages gnome)
47 #:use-module (gnu packages graphics)
48 #:use-module (gnu packages graphviz)
49 #:use-module (gnu packages gstreamer)
50 #:use-module (gnu packages gtk)
51 #:use-module (gnu packages image)
52 #:use-module (gnu packages imagemagick)
53 #:use-module (gnu packages maths)
54 #:use-module (gnu packages pdf)
55 #:use-module (gnu packages perl)
56 #:use-module (gnu packages photo)
57 #:use-module (gnu packages pkg-config)
58 #:use-module (gnu packages protobuf)
59 #:use-module (gnu packages python)
60 #:use-module (gnu packages python-xyz)
61 #:use-module (gnu packages serialization)
62 #:use-module (gnu packages video)
63 #:use-module (gnu packages xiph)
64 #:use-module (gnu packages xml)
65 #:use-module (gnu packages xorg)
66 #:use-module (ice-9 match))
67
68 (define-public dcmtk
69 (package
70 (name "dcmtk")
71 (version "3.6.4")
72 (source
73 (origin
74 (method url-fetch)
75 (uri
76 (string-append "ftp://dicom.offis.de/pub/dicom/offis/software/dcmtk/"
77 "dcmtk" (string-join (string-split version #\.) "")
78 "/dcmtk-" version ".tar.gz"))
79 (sha256
80 (base32 "1h22z8g0kmvhg8lgkbikyzyphhvxvq6018a00yd6i4g0z9ag6gx9"))))
81 (build-system cmake-build-system)
82 (inputs
83 `(("libjpeg" ,libjpeg)
84 ("libpng" ,libpng)
85 ("libtiff" ,libtiff)
86 ("zlib" ,zlib)))
87 (native-inputs
88 `(("doxygen" ,doxygen))) ; for HTML documentation
89 (home-page "https://dcmtk.org")
90 (synopsis "Libraries and programs implementing parts of the DICOM standard")
91 (description "DCMTK is a collection of libraries and applications
92 implementing large parts the DICOM standard. It includes software for
93 examining, constructing and converting DICOM image files, handling offline
94 media, sending and receiving images over a network connection, as well as
95 demonstrative image storage and worklist servers.")
96 (license (license:fsf-free
97 "file://COPYRIGHT"
98 "A union of the Apache 2.0 licence and various non-copyleft
99 licences similar to the Modified BSD licence."))))
100
101 (define-public mia
102 (package
103 (name "mia")
104 (version "2.4.6")
105 (source (origin
106 (method url-fetch)
107 (uri (string-append "mirror://sourceforge/mia/mia/"
108 (version-major+minor version)
109 "/mia-" version ".tar.xz"))
110 (sha256
111 (base32
112 "0j4nd5z7i3v199jh7hqqhwd4g7snchizkc7rhzanpvngqg91m1pb"))))
113 (build-system cmake-build-system)
114 (arguments
115 `(#:configure-flags
116 (list "-DMIA_CREATE_NIPYPE_INTERFACES=0"
117 "-DCMAKE_CXX_FLAGS=-fpermissive")))
118 (inputs
119 `(("boost" ,boost)
120 ("dcmtk" ,dcmtk)
121 ("doxygen" ,doxygen)
122 ("eigen" ,eigen)
123 ("fftw" ,fftw)
124 ("fftwf" ,fftwf)
125 ("gsl" ,gsl)
126 ("gts" ,gts)
127 ("hdf5" ,hdf5)
128 ("itpp" ,itpp)
129 ("libjpeg" ,libjpeg)
130 ("libpng" ,libpng)
131 ("libtiff" ,libtiff)
132 ("libxml" ,libxml2)
133 ("libxml++" ,libxml++)
134 ("maxflow" ,maxflow)
135 ("niftilib" ,niftilib)
136 ("nlopt" ,nlopt)
137 ("openexr" ,openexr)
138 ("python-lxml" ,python2-lxml)
139 ("vtk" ,vtk)))
140 (native-inputs
141 `(("pkg-config" ,pkg-config)
142 ("python" ,python-2)))
143 (home-page "http://mia.sourceforge.net")
144 (synopsis "Toolkit for gray scale medical image analysis")
145 (description "MIA provides a combination of command line tools, plug-ins,
146 and libraries that make it possible run image processing tasks interactively
147 in a command shell and to prototype using the shell's scripting language. It
148 is built around a plug-in structure that makes it easy to add functionality
149 without compromising the original code base and it makes use of a wide variety
150 of external libraries that provide additional functionality.")
151 (license license:gpl3+)))
152
153 (define-public vtk
154 (package
155 (name "vtk")
156 (version "8.2.0")
157 (source (origin
158 (method url-fetch)
159 (uri (string-append "https://vtk.org/files/release/"
160 (version-major+minor version)
161 "/VTK-" version ".tar.gz"))
162 (sha256
163 (base32
164 "1fspgp8k0myr6p2a6wkc21ldcswb4bvmb484m12mxgk1a9vxrhrl"))))
165 (build-system cmake-build-system)
166 (arguments
167 '(#:build-type "Release" ;Build without '-g' to save space.
168 ;; -DVTK_USE_SYSTEM_NETCDF:BOOL=TRUE requires netcdf_cxx
169 #:configure-flags '("-DVTK_USE_SYSTEM_EXPAT:BOOL=TRUE"
170 "-DVTK_USE_SYSTEM_FREETYPE:BOOL=TRUE"
171 "-DVTK_USE_SYSTEM_HDF5:BOOL=TRUE"
172 "-DVTK_USE_SYSTEM_JPEG:BOOL=TRUE"
173 "-DVTK_USE_SYSTEM_JSONCPP:BOOL=TRUE"
174 "-DVTK_USE_SYSTEM_LIBXML2:BOOL=TRUE"
175 "-DVTK_USE_SYSTEM_OGGTHEORA:BOOL=TRUE"
176 "-DVTK_USE_SYSTEM_PNG:BOOL=TRUE"
177 "-DVTK_USE_SYSTEM_TIFF:BOOL=TRUE"
178 "-DVTK_USE_SYSTEM_ZLIB:BOOL=TRUE")
179 #:tests? #f)) ;XXX: no "test" target
180 (inputs
181 `(("libXt" ,libxt)
182 ("xorgproto" ,xorgproto)
183 ("libX11" ,libx11)
184 ("libxml2" ,libxml2)
185 ("mesa" ,mesa)
186 ("glu" ,glu)
187 ("expat" ,expat)
188 ("freetype" ,freetype)
189 ("hdf5" ,hdf5)
190 ("jpeg" ,libjpeg)
191 ("jsoncpp" ,jsoncpp)
192 ("libogg" ,libogg)
193 ("libtheora" ,libtheora)
194 ("png" ,libpng)
195 ("tiff" ,libtiff)
196 ("zlib" ,zlib)))
197 (home-page "https://vtk.org/")
198 (synopsis "Libraries for 3D computer graphics")
199 (description
200 "The Visualization Toolkit (VTK) is a C++ library for 3D computer graphics,
201 image processing and visualization. It supports a wide variety of
202 visualization algorithms including: scalar, vector, tensor, texture, and
203 volumetric methods; and advanced modeling techniques such as: implicit
204 modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay
205 triangulation. VTK has an extensive information visualization framework, has
206 a suite of 3D interaction widgets, supports parallel processing, and
207 integrates with various databases on GUI toolkits such as Qt and Tk.")
208 (license license:bsd-3)))
209
210 (define-public opencv
211 (package
212 (name "opencv")
213 (version "3.4.3")
214 (source (origin
215 (method git-fetch)
216 (uri (git-reference
217 (url "https://github.com/opencv/opencv")
218 (commit version)))
219 (file-name (git-file-name name version))
220 (sha256
221 (base32
222 "06bc61r8myym4s8im10brdjfg4wxkrvsbhhl7vr1msdan2xddzi3"))
223 (modules '((guix build utils)))
224 (snippet
225 '(begin
226 ;; Remove external libraries. We have all available in Guix:
227 (delete-file-recursively "3rdparty")
228
229 ;; Milky icon set is non-free:
230 (delete-file-recursively "modules/highgui/src/files_Qt/Milky")
231
232 ;; Some jars found:
233 (for-each delete-file
234 '("modules/java/test/pure_test/lib/junit-4.11.jar"
235 "samples/java/sbt/sbt/sbt-launch.jar"))
236 #t))))
237 (build-system cmake-build-system)
238 (arguments
239 `(#:configure-flags
240 (list "-DWITH_IPP=OFF"
241 "-DWITH_ITT=OFF"
242 "-DWITH_CAROTENE=OFF" ; only visible on arm/aarch64
243 "-DENABLE_PRECOMPILED_HEADERS=OFF"
244
245 ;; CPU-Features:
246 ;; See cmake/OpenCVCompilerOptimizations.cmake
247 ;; (CPU_ALL_OPTIMIZATIONS) for a list of all optimizations
248 ;; BASELINE is the minimum optimization all CPUs must support
249 ;;
250 ;; DISPATCH is the list of optional dispatches.
251 "-DCPU_BASELINE=SSE2"
252
253 ,@(match (%current-system)
254 ("x86_64-linux"
255 '("-DCPU_DISPATCH=NEON;VFPV3;FP16;SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX"
256 "-DCPU_DISPATCH_REQUIRE=SSE3,SSSE3,SSE4_1,SSE4_2,AVX,AVX2"))
257 ("armhf-linux"
258 '("-DCPU_BASELINE_DISABLE=NEON")) ; causes build failures
259 ("aarch64-linux"
260 '("-DCPU_BASELINE=NEON"
261 "-DCPU_DISPATCH=NEON;VFPV3;FP16"))
262 (_ '()))
263
264 "-DBUILD_PERF_TESTS=OFF"
265 "-DBUILD_TESTS=ON"
266
267 (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
268 "/opencv-contrib/modules")
269
270 ;;Define test data:
271 (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
272 "/opencv-extra/testdata")
273
274 ;; Is ON by default and would try to rebuild 3rd-party protobuf,
275 ;; which we had removed, which would lead to an error:
276 "-DBUILD_PROTOBUF=OFF"
277
278 ;; Rebuild protobuf files, because we have a slightly different
279 ;; version than the included one. If we would not update, we
280 ;; would get a compile error later:
281 "-DPROTOBUF_UPDATE_FILES=ON"
282
283 ;; xfeatures2d disabled, because it downloads extra binaries from
284 ;; https://github.com/opencv/opencv_3rdparty
285 ;; defined in xfeatures2d/cmake/download_{vgg|bootdesc}.cmake
286 ;; Cmp this bug entry:
287 ;; https://github.com/opencv/opencv_contrib/issues/1131
288 "-DBUILD_opencv_xfeatures2d=OFF")
289 #:phases
290 (modify-phases %standard-phases
291 (add-after 'unpack 'disable-broken-tests
292 (lambda _
293 ;; These tests fails with:
294 ;; vtkXOpenGLRenderWindow (0x723990): Could not find a decent config
295 ;; I think we have no OpenGL support with the Xvfb.
296 (substitute* '("modules/viz/test/test_tutorial3.cpp"
297 "modules/viz/test/test_main.cpp"
298 "modules/viz/test/tests_simple.cpp"
299 "modules/viz/test/test_viz3d.cpp")
300 (("(TEST\\(Viz, )([a-z].*\\).*)" all pre post)
301 (string-append pre "DISABLED_" post)))
302
303 ;; This one fails with "unknown file: Failure"
304 ;; But I couldn't figure out which file was missing:
305 (substitute* "../opencv-contrib/modules/face/test/test_face_align.cpp"
306 (("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)"
307 all pre post)
308 (string-append pre "DISABLED_" post)))
309
310 ;; Failure reason: Bad accuracy
311 ;; Incorrect count of accurate poses [2nd case]: 90.000000 / 94.000000
312 (substitute* "../opencv-contrib/modules/rgbd/test/test_odometry.cpp"
313 (("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post)
314 (string-append pre "DISABLED_" post)))
315 #t))
316
317 (add-after 'unpack 'unpack-submodule-sources
318 (lambda* (#:key inputs #:allow-other-keys)
319 (mkdir "../opencv-extra")
320 (mkdir "../opencv-contrib")
321 (copy-recursively (assoc-ref inputs "opencv-extra")
322 "../opencv-extra")
323 (invoke "tar" "xvf"
324 (assoc-ref inputs "opencv-contrib")
325 "--strip-components=1"
326 "-C" "../opencv-contrib")))
327
328 (add-after 'set-paths 'add-ilmbase-include-path
329 (lambda* (#:key inputs #:allow-other-keys)
330 ;; OpenEXR propagates ilmbase, but its include files do not appear
331 ;; in the CPATH, so we need to add "$ilmbase/include/OpenEXR/" to
332 ;; the CPATH to satisfy the dependency on "ImathVec.h".
333 (setenv "CPATH"
334 (string-append (assoc-ref inputs "ilmbase")
335 "/include/OpenEXR"
336 ":" (or (getenv "CPATH") "")))
337 #t))
338 (add-before 'check 'start-xserver
339 (lambda* (#:key inputs #:allow-other-keys)
340 (let ((xorg-server (assoc-ref inputs "xorg-server"))
341 (disp ":1"))
342 (setenv "HOME" (getcwd))
343 (setenv "DISPLAY" disp)
344 ;; There must be a running X server and make check doesn't start one.
345 ;; Therefore we must do it.
346 (zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp)))))))))
347 (native-inputs
348 `(("pkg-config" ,pkg-config)
349 ("xorg-server" ,xorg-server) ; For running the tests
350 ("opencv-extra"
351 ,(origin
352 (method git-fetch)
353 (uri (git-reference
354 (url "https://github.com/opencv/opencv_extra")
355 (commit version)))
356 (file-name (git-file-name "opencv_extra" version))
357 (sha256
358 (base32 "08p5xnq8n1jw8svvz0fnirfg7q8dm3p4a5dl7527s5xj0f9qn7lp"))))
359 ("opencv-contrib"
360 ,(origin
361 (method git-fetch)
362 (uri (git-reference
363 (url "https://github.com/opencv/opencv_contrib")
364 (commit version)))
365 (file-name (git-file-name "opencv_contrib" version))
366 (patches (search-patches "opencv-rgbd-aarch64-test-fix.patch"))
367 (sha256
368 (base32 "1f334glf39nk42mpqq6j732h3ql2mpz89jd4mcl678s8n73nfjh2"))))))
369 (inputs `(("libjpeg" ,libjpeg)
370 ("libpng" ,libpng)
371 ("jasper" ,jasper)
372 ;; ffmpeg 4.0 causes core dumps in tests.
373 ("ffmpeg" ,ffmpeg-3.4)
374 ("libtiff" ,libtiff)
375 ("hdf5" ,hdf5)
376 ("libgphoto2" ,libgphoto2)
377 ("libwebp" ,libwebp)
378 ("zlib" ,zlib)
379 ("gtkglext" ,gtkglext)
380 ("openexr" ,openexr)
381 ("ilmbase" ,ilmbase)
382 ("gtk+" ,gtk+-2)
383 ("python-numpy" ,python-numpy)
384 ("protobuf" ,protobuf)
385 ("vtk" ,vtk)
386 ("python" ,python)))
387 ;; These three CVEs are not a problem of OpenCV, see:
388 ;; https://github.com/opencv/opencv/issues/10998
389 (properties '((lint-hidden-cve . ("CVE-2018-7712"
390 "CVE-2018-7713"
391 "CVE-2018-7714"))))
392 (synopsis "Computer vision library")
393 (description "OpenCV is a library aimed at
394 real-time computer vision, including several hundred computer
395 vision algorithms. It can be used to do things like:
396
397 @itemize
398 @item image and video input and output
399 @item image and video processing
400 @item displaying
401 @item feature recognition
402 @item segmentation
403 @item facial recognition
404 @item stereo vision
405 @item structure from motion
406 @item augmented reality
407 @item machine learning
408 @end itemize\n")
409 (home-page "https://opencv.org/")
410 (license license:bsd-3)))
411
412 (define-public vips
413 (package
414 (name "vips")
415 (version "8.7.4")
416 (source
417 (origin
418 (method url-fetch)
419 (uri (string-append
420 "https://github.com/libvips/libvips/releases/download/v"
421 version "/vips-" version ".tar.gz"))
422 (sha256
423 (base32 "01gjhcrl6zj7mcj1al717v5jsniahplqhz1xkfh2j78vyfl1hxff"))))
424 (build-system gnu-build-system)
425 (native-inputs
426 `(("pkg-config" ,pkg-config)
427 ("gobject-introspection" ,gobject-introspection)))
428 (inputs
429 `(("glib" ,glib)
430 ("libjpeg" ,libjpeg)
431 ("libpng" ,libpng)
432 ("librsvg" ,librsvg)
433 ("libtiff" ,libtiff)
434 ("libexif" ,libexif)
435 ("giflib" ,giflib)
436 ("libgsf" ,libgsf)
437 ("fftw" ,fftw)
438 ("poppler" ,poppler)
439 ("pango" ,pango)
440 ("lcms" ,lcms)
441 ("matio" ,matio)
442 ("libwebp" ,libwebp)
443 ("niftilib" ,niftilib)
444 ("openexr" ,openexr)
445 ("orc" ,orc)
446 ("imagemagick" ,imagemagick)
447 ("libxml2" ,libxml2)
448 ("expat" ,expat)
449 ("hdf5" ,hdf5)))
450 (home-page "https://libvips.github.io/libvips/")
451 (synopsis "Multithreaded image processing system with low memory needs")
452 (description
453 "VIPS is a demand-driven, horizontally threaded image processing library.
454 It's particularly good at processing large images, working with colour,
455 scientific analysis, and general research & development.
456
457 Compared to most image processing libraries VIPS needs little RAM and runs
458 quickly, especially on machines with more than one CPU core. This is primarily
459 due to its architecture which automatically parallelises the image workflows.")
460 (license license:lgpl2.1+)))
461
462 (define-public nip2
463 (package
464 (name "nip2")
465 (version "8.7.1")
466 (source
467 (origin
468 (method url-fetch)
469 (uri (string-append "https://github.com/libvips/nip2/releases/download/v"
470 version "/nip2-" version ".tar.gz" ))
471 (sha256
472 (base32 "0l7n427njif53npqn02gfjjly8y3khbrkzqxp10j5vp9h97psgiw"))))
473 (build-system gnu-build-system)
474 (arguments
475 `(#:phases
476 (modify-phases %standard-phases
477 ;; test_conv.ws keep failing so disabling for now.
478 (add-after 'unpack 'disable-test-conv
479 (lambda _
480 (delete-file "test/workspaces/test_conv.ws")
481 #t))
482 (add-before 'check 'set-home
483 (lambda _
484 (setenv "HOME" "/tmp") #t)))))
485 (inputs
486 `(("vips" ,vips)
487 ("glib" ,glib)
488 ("libtiff" ,libtiff)
489 ("gtk+-2" ,gtk+-2)
490 ("libxml2" ,libxml2)
491 ("libexif" ,libexif)
492 ("libjpeg" ,libjpeg) ; required by vips.pc
493 ("librsvg" ,librsvg)
494 ("fftw" ,fftw)
495 ("libgsf" ,libgsf)
496 ("imagemagick" ,imagemagick)
497 ("orc" ,orc)
498 ("matio" ,matio)
499 ("lcms" ,lcms)
500 ("libwebp" ,libwebp)
501 ("openexr" ,openexr)
502 ("poppler" ,poppler)
503 ("gsl" ,gsl)))
504 (native-inputs
505 `(("flex" ,flex)
506 ("bison" ,bison)
507 ("pkg-config" ,pkg-config)))
508 (home-page "https://github.com/libvips/nip2")
509 (synopsis "Spreadsheet-like GUI for libvips")
510 (description "This package provide a graphical user interface (GUI) for
511 the VIPS image processing library. It's a little like a spreadsheet: you
512 create a set of formula connecting your objects together, and on a change nip2
513 recalculates.")
514 (license license:gpl2+)))