# GLVisualize maximum intensity projection: set 'inherent' attenuation

**URL:** https://discourse.julialang.org/t/glvisualize-maximum-intensity-projection-set-inherent-attenuation/1501
**Category:** Visualization
**Tags:** glvisualize
**Created:** [January 15, 2017, 8:57pm UTC](https://discourse.julialang.org/t/glvisualize-maximum-intensity-projection-set-inherent-attenuation/1501 "2017-01-15T20:57:01Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![samuelpowell](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samuelpowell/32/248_2.png) [@samuelpowell](https://discourse.julialang.org/u/samuelpowell)
#### Post date: [January 15, 2017, 8:57pm UTC](https://discourse.julialang.org/t/glvisualize-maximum-intensity-projection-set-inherent-attenuation/1501/1 "2017-01-15T20:57:01Z")

</div>

I am using `GLVisualize` to render a maximum intensity protection of some volumetric data:

```julia
viewable = visualize(array, :mip)
_view(viewable, window, camera=:perspective)

```

This works okay, but at certain angles the field is obscured by what I assume is some inherent attenuation applied to the bounding box in the shader routine. This is shown in the attached images, which are of the same dataset, viewed from different angles. In the second image the field is almost completely obscured.

I think that this is managed by the `absorption` parameter which is assigned in the appropriate default:

```julia
_default{T<:VolumeElTypes}(main::VolumeTypes{T}, s::Style, data::Dict) = @gen_defaults! data begin
...
    algorithm = MaximumIntensityProjection
    boundingbox = hull
    absorption = 1f0
...

```

Is this the parameter I need to override? And how do I go about doing so? I have tried to override the default with keyword arguments, to no avail.

 ![](https://global.discourse-cdn.com/julialang/original/3X/a/0/a0a753a9ff2321525b5a4722c3cabc7031a0331e.png)

 ![](https://global.discourse-cdn.com/julialang/original/3X/e/1/e100ce31be8de734dae644cf1aadcc904da061b0.png)

---

<div class="post-metadata">

### Author: ![samuelpowell](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samuelpowell/32/248_2.png) [@samuelpowell](https://discourse.julialang.org/u/samuelpowell)
#### Post date: [January 16, 2017, 10:09am UTC](https://discourse.julialang.org/t/glvisualize-maximum-intensity-projection-set-inherent-attenuation/1501/2 "2017-01-16T10:09:45Z")

</div>

Having read the volume shader fragment I can see that I was incorrect in my assumption that the `absorption` variable was related to what I was trying to achieve. Indeed, this is only used when visualising with `_view(array, :absorption)`. In any case, those parameters are fixed as they do not reference the input style.

The correct way to achieve the desired effect is simply to manipulate the colormap such that that input volume is transparent where necessary. For example,

```julia
color_map = map(RGBA{U8}, GLVisualize.colormap("Blues"))
color_map[1] = RGBA{U8}(0,0,0,0)

```

will make transparent data close to the minimum value in the volume (in the case of the default `color_norm` which is set to the extrema of the data).

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [January 16, 2017, 8:33pm UTC](https://discourse.julialang.org/t/glvisualize-maximum-intensity-projection-set-inherent-attenuation/1501/3 "2017-01-16T20:33:12Z")

</div>

Glad you figured it out 🙂 I definitely need a better validation of kw\_args!

Btw, you should be able to use any array of `Color.Colorant`!

---

<div class="post-metadata">

### Author: ![samuelpowell](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samuelpowell/32/248_2.png) [@samuelpowell](https://discourse.julialang.org/u/samuelpowell)
#### Post date: [January 16, 2017, 8:55pm UTC](https://discourse.julialang.org/t/glvisualize-maximum-intensity-projection-set-inherent-attenuation/1501/4 "2017-01-16T20:55:32Z")

</div>

Thank you Simon for all your work on this impressive package, it was no doubt quite an undertaking!

Do you suggest using `Color.Colorant` because this will give me direct control over, e.g., the alpha channel, rather than relying on a colour map?

I have been looking at some of the other volume rendering options, and I find that the `absorption` style seems to clip or cull parts of the image depending upon the view angle. Since it doesn’t look much like the examples in your thesis, I suspect I’m doing something wrong. Do you have any self-contained examples for this style?

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [January 16, 2017, 10:02pm UTC](https://discourse.julialang.org/t/glvisualize-maximum-intensity-projection-set-inherent-attenuation/1501/5 "2017-01-16T22:02:08Z")

</div>

> Do you suggest using Color.Colorant because this will give me direct control over, e.g., the alpha channel

I was just mentioning it for completeness 😉 Btw, it should be rather:

```Julia
Colors.colormap("Blues")

```

It just works for you, since I import Colors in GLVisualize.  
I think the example in the thesis was maximum intensity projection with a Gray color map.  
I might be wrong though, it’s a long time ago and the algorithm has changed completely since then.

The clipping and culling is a bug ☹ At some point I need to get back there and rework the volume rendering code!

Btw, you should try GLPlot master, there you should be able to play more easily with the parameters, like in:

[![](https://global.discourse-cdn.com/julialang/original/3X/0/d/0d76ff4e5b9276239199978ff42257bb86927dca.webp "Mandelbulb on the GPU") ](https://vimeo.com/184020541)

just replace `_view(visualize(volume))` with `glplot(volume)`, and maybe you need to checkout GLVisualize master as well. The GUI you see in the video should open when you click on the very small button at the right!

---

<div class="post-metadata">

### Author: ![samuelpowell](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samuelpowell/32/248_2.png) [@samuelpowell](https://discourse.julialang.org/u/samuelpowell)
#### Post date: [January 16, 2017, 10:27pm UTC](https://discourse.julialang.org/t/glvisualize-maximum-intensity-projection-set-inherent-attenuation/1501/6 "2017-01-16T22:27:29Z")

</div>

> [@sdanisch](#):
>
> The clipping and culling is a bug ☹ At some point I need to get back there and rework the volume rendering code!

Ahh, okay, I’m pleased to hear this as I couldn’t work out what I was doing wrong! Do you think the problem is in the shader or at a higher level?

I will be sure to try out the GLPlot examples tomorrow.
