1
$\begingroup$

Consider a volume (MRI Head) from (http://www9.informatik.uni-erlangen.de/External/vollib/).

I wish to design a simple 1D Transfer Function which will assign/map each intensity value to a specific colour and opacity values. This also requires to specify the number of key points to specify the bins and I want this number to be decided dynamically.

For example,

Image3D[img, 
  ColorFunction -> 
    (Blend[
       {{0, RGBColor[0, 0, 1, 0]}, 
        {0.5, RGBColor[0, 0.5, 0.25, 0.1]}, 
        {0.6, RGBColor[1, 1, 0, 0.15]}, 
        {1, RGBColor[1, 0.5, 0, 1]}}, #1] &)]  

This colour function is created using the option ColorFunction and sets the number of key points and opacity values manually.

I want to get the color and opacity values in the following way:

colour = cf[img];   (* cf is a user defined color function *)
opacity = of[img];  (* of is the user defined opacity function *)

One way to achieve this is to assign colour and opacity values running a loop for each pixel or set the number of bins or key points based on the histogram and assign the values using some conditional statements.

Is there any smart alternative to implement this 1D transfer function?

Edit

Consider, I wish to have five bins with different intensity ranges for the given volume:

Bin1: Intensity range -> [0, 0.2]; Colour and opacity -> RGBColor[0, 0, 0.15, 0];

Bin2: Intensity range -> [0.2, 0.4]; Colour and opacity -> RGBColor[0.5, 0, 0.15, 0.2];

Bin3: Intensity range -> [0.4, 0.6]; Colour and opacity -> RGBColor[0, 0.5, 0.5, 0.4];

Bin4: Intensity range -> [0.6, 0.8]; Colour and opacity -> RGBColor[0, 0.5, 0.15, 0.8];

Bin5: Intensity range -> [0.8, 1]; Colour and opacity -> RGBColor[1, 1, 1, 1];

How can I implement this as a transfer function?

$\endgroup$

closed as unclear what you're asking by MarcoB, corey979, Feyre, m_goldberg, Young Feb 5 '17 at 17:08

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ So ImageData@img? I'm not sure I understand you question. $\endgroup$ – Feyre Jan 26 '17 at 12:31