Skip to content

Commit

Permalink
Adds Histogram function for Single Channel Images
Browse files Browse the repository at this point in the history
  • Loading branch information
mronian committed Mar 22, 2016
1 parent cf1efb3 commit 4b7c03c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/src/function_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ include the following functions:
padarray
}

# Exposure

@{
imhist
}

# Filtering kernels

@{
Expand Down
2 changes: 2 additions & 0 deletions src/Images.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export # types
imfilter_fft,
imfilter_gaussian,
imfilter_gaussian!,
imhist,
imfilter_LoG,
imgaussiannoise,
imgradients,
Expand Down Expand Up @@ -266,6 +267,7 @@ Algorithms:
- Reductions: `maxfinite`, `maxabsfinite`, `minfinite`, `meanfinite`, `sad`, `ssd`
- Resizing: `restrict`, `imresize` (not yet exported)
- Exposure: `imhist`
- Filtering: `imfilter`, `imfilter_fft`, `imfilter_gaussian`, `imfilter_LoG`, `imROF`, `ncc`, `padarray`
- Filtering kernels: `ando[345]`, `guassian2d`, `imaverage`, `imdog`, `imlaplacian`, `prewitt`, `sobel`
- Gradients: `backdiffx`, `backdiffy`, `forwarddiffx`, `forwarddiffy`, `imgradients`
Expand Down
22 changes: 22 additions & 0 deletions src/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,28 @@ function copytail!(dest, A, coloffset, strd, len)
dest
end

"""
```
hist=imhist(img, 0:0.2:1)
```
Calculates a histogram of the given single channel image with the given range as bins.
The histogram is calculated on the flattened image. For multi dimensional images, use the function
separately on each channel to obtain a histogram for each.
"""
function imhist{T}(img::AbstractArray{T,2}, edg::AbstractVector)
img_data=raw(img)
hist(img_data[:], edg)
end

# """
# ```

# ```

# """
# function histeq()

# Laplacian of Gaussian filter
# Separable implementation from Huertas and Medioni,
# IEEE Trans. Pat. Anal. Mach. Int., PAMI-8, 651, (1986)
Expand Down
11 changes: 11 additions & 0 deletions test/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@ facts("Algorithms") do
@fact img2 --> roughly(reinterpret(Float32, img))
end

context("Exposure") do
A = reshape(0.1:0.1:2.0, 4, 5)
imgA = convert(Image, A)
_, hist = Images.imhist(imgA, 0:0.5:2)
@fact hist --> [5,5,5,5]
A = reshape(1.24:0.04:2, 4, 5)
imgA = convert(Image, A)
_, hist = Images.imhist(imgA, 0:0.2:2)
@fact hist --> [0,0,0,0,0,0,5,5,5,5]
end

context("Array padding") do
A = [1 2; 3 4]
@fact Images.padindexes(A, 1, 0, 0, "replicate") --> [1,2]
Expand Down

0 comments on commit 4b7c03c

Please sign in to comment.