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