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