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