Skip to content

Commit 15f0f8c

Browse files
committed
Adding histogram example to arrayfire
1 parent e182b22 commit 15f0f8c

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

examples/graphics/histogram.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/python
2+
3+
#######################################################
4+
# Copyright (c) 2015, ArrayFire
5+
# All rights reserved.
6+
#
7+
# This file is distributed under 3-clause BSD license.
8+
# The complete license agreement can be obtained at:
9+
# http://arrayfire.com/licenses/BSD-3-Clause
10+
########################################################
11+
12+
import arrayfire as af
13+
import sys
14+
import os
15+
16+
if __name__ == "__main__":
17+
18+
if (len(sys.argv) == 1):
19+
raise RuntimeError("Expected to the image as the first argument")
20+
21+
if not os.path.isfile(sys.argv[1]):
22+
raise RuntimeError("File %s not found" % sys.argv[1])
23+
24+
if (len(sys.argv) > 2):
25+
af.set_device(int(sys.argv[2]))
26+
27+
af.info()
28+
29+
hist_win = af.Window(512, 512, "3D Plot example using ArrayFire")
30+
img_win = af.Window(480, 640, "Input Image")
31+
32+
img = af.cast(af.load_image(sys.argv[1]), af.Dtype.u8)
33+
hist = af.histogram(img, 256, 0, 255)
34+
35+
while (not hist_win.close()) and (not img_win.close()):
36+
hist_win.hist(hist, 0, 255)
37+
img_win.image(img)

0 commit comments

Comments
 (0)