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/python
#######################################################
# Copyright (c) 2015, 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 arrayfire as af
import sys
import os
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()) and (not img_win.close()):
hist_win.hist(hist, 0, 255)
img_win.image(img)
|