Getting a 2D histogram of a grayscale image in Julia -


using images package, can open color image, convert gray scale , :

using images img_gld = imread("...path color jpg...") img_gld_gs = convert(image{gray},img_gld) #change floats array of values between 0 , 255: img_gld_gs = reinterpret(uint8,data(img_gld_gs)) 

now i've got 1920x1080 array of uint8's:

julia> img_gld_gs  1920x1080 array{uint8,2} 

now want histogram of 2d array of uint8 values:

julia> hist(img_gld_gs) (0.0:50.0:300.0, 6x1080 array{int64,2}:  1302  1288  1293  1302  1297  1300  1257  1234  …    12    13    13    12    13    15    14   618   632   627   618   623   620   663   686      189   187   187   188   185   183   183     0     0     0     0     0     0     0     0        9     9     8     7     8     7     7     0     0     0     0     0     0     0     0       10    12     9     7    13     7     9     0     0     0     0     0     0     0     0     1238  1230  1236  1235  1230  1240  1234     0     0     0     0     0     0     0     0  …   462   469   467   471   471   468   473) 

but, instead of 6x1080, i'd 256 slots in histogram show total number of times each value has appeared. tried:

julia> hist(img_gld_gs,256) 

but gives:

(2.0:1.0:252.0, 250x1080 array{int64,2}: 

so instead of 256x1080 array, it's 250x1080. there way force have 256 bins (without resorting writing own hist function)? want able compare different images , want histogram each image have same number of bins.

hist accepts vector (or range) optional argument specifies edge boundaries, so

hist(img_gld_gs, 0:256) 

should work.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -