-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathhistogram.py
More file actions
37 lines (27 loc) · 1.02 KB
/
histogram.py
File metadata and controls
37 lines (27 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
#######################################################
# Copyright (c) 2019, ArrayFire
# All rights reserved.
#
# This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause
########################################################
import os
import sys
import arrayfire as af
if __name__ == "__main__":
if len(sys.argv) == 1:
raise RuntimeError("Expected to the image as the first argument")
if not os.path.isfile(sys.argv[1]):
raise RuntimeError("File %s not found" % sys.argv[1])
if len(sys.argv) > 2:
af.set_device(int(sys.argv[2]))
af.info()
hist_win = af.Window(512, 512, "3D Plot example using ArrayFire")
img_win = af.Window(480, 640, "Input Image")
img = af.load_image(sys.argv[1]).as_type(af.Dtype.u8)
hist = af.histogram(img, 256, 0, 255)
while not (hist_win.close() or img_win.close()):
hist_win.hist(hist, 0, 255)
img_win.image(img)