# Histogram Equalization

**URL:** <https://discourse.julialang.org/t/histogram-equalization/41682>\
**Category:** General Usage\
**Created:** [June 18, 2020, 5:01pm UTC](https://discourse.julialang.org/t/histogram-equalization/41682 "2020-06-18T17:01:37Z")\
**Posts on this page:** 1\
**Showing post:** 25

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [June 19, 2020, 11:13am UTC](https://discourse.julialang.org/t/histogram-equalization/41682/25 "2020-06-19T11:13:24Z")

</div>

Okay to reduce the confusion I went ahead an installed `TestImages`. Here’s what’s happening (I think):

```julia
julia> using Images, TestImages

julia> image = testimage("cameraman.tif");

julia> typeof(image)
Array{Gray{Normed{UInt8,8}},2}

```

So `image` is an array of `Gray{Normed{UInt8,8}}` elements:

```julia
julia> image[1,1]
Gray{N0f8}(0.612)

```

If you multiply those by an `Int`, as you do, you end up with:

```julia
julia> image[1,1]*255
Gray{Float32}(156.0f0)

```

that doesn’t work for indexing, you need an integer. You converted this back to `UInt8`:

```julia
julia> UInt8(image[1,1]*255)
0x9c

```

but then you’re directly adding a `1`, which as we said is just a literal that gets parsed as an `Int64`, and adding that to your `UInt8` just gives you a regular `Int`:

```julia
julia> UInt8(image[1,1]*255)+1
157

```

So this is essentially the same as doing:

```julia
julia> Int(image[1,1]*255)+1
157

```

---

_[View the full topic](https://discourse.julialang.org/t/histogram-equalization/41682)._
