# On the riddle in JuliaAcademy lesson "Representing data in a computer"

**URL:** https://discourse.julialang.org/t/on-the-riddle-in-juliaacademy-lesson-representing-data-in-a-computer/32566
**Category:** Teaching & Outreach
**Created:** [December 21, 2019, 11:47pm UTC](https://discourse.julialang.org/t/on-the-riddle-in-juliaacademy-lesson-representing-data-in-a-computer/32566 "2019-12-21T23:47:16Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![yuxi.liu](https://avatars.discourse-cdn.com/v4/letter/y/839c29/32.png) [@yuxi.liu](https://discourse.julialang.org/u/yuxi.liu)
#### Post date: [December 21, 2019, 11:47pm UTC](https://discourse.julialang.org/t/on-the-riddle-in-juliaacademy-lesson-representing-data-in-a-computer/32566/1 "2019-12-21T23:47:16Z")

</div>

I filtered out the white background in apples and bananas,

```julia
iswhite(pixel) = (Float64( red(pixel) ) > 0.9 
               && Float64( green(pixel) ) > 0.9 
               && Float64( blue(pixel) ) > 0.9)

applewhitearray = iswhite.(apple)
applewhitemask = [RGB{N0f8}(i, i, i) for i in applewhitearray]
display(apple)
display(applewhitemask)
display(apple[.!applewhitearray])

bananawhitearray = iswhite.(banana)
bananawhitemask = [RGB{N0f8}(i, i, i) for i in bananawhitearray]
display(banana)
display(bananawhitemask)
display(banana[.!bananawhitearray])

```

 ![](https://global.discourse-cdn.com/julialang/original/3X/4/4/44c153e3f54b360c3ad1933d948c7792f50dae05.png)  
 ![](https://global.discourse-cdn.com/julialang/original/3X/e/3/e3a17a1d7084c99f25854cc57c7d4df1519f9e70.png)  
and surprisingly, there is still a lot of red in the banana:

```julia
display(histogram(float.(red.(apple[.!applewhitearray])),color="red",label="apple", normalize=true, nbins=25))
histogram!(float.(red.(banana[.!bananawhitearray])),color="yellow",label="banana", normalize=true, nbins=25)

```

 ![](https://global.discourse-cdn.com/julialang/original/3X/c/7/c7779ecc2c30ecd54ef55c95e9eba8b2a477b611.png)

and the mean redness of the banana is still bigger.

```julia
println("Apple has average redness ", mean(Float64.(red.(apple[.!applewhitearray]))))
println("Banana has average redness ", mean(Float64.(red.(banana[.!bananawhitearray]))))

```

```julia
Apple has average redness 0.4411
Banana has average redness 0.6242

```
