generated by zdoc.tcl on Thu Feb 14 16:15:15 MET 2002

tclImageData.tcl



imagedata
Comments  
Arguments  
Used by  
Uses  

}


imagedata::createRangeInformation
Comments  
Arguments menu
object
color
Used by triangulation::installActiveTriangulation3DMenu
contour::installContourVertexMenu
SM2::selectVertex
triangulation::installPrecomputedTriangulation3DMenu
SM2::installSM2
tetrahedrisation::installActiveTetra3DMenu
SM2::selectZone
contour::installContourExternalMenu
Uses  
proc imagedata::createRangeInformation { menu object color} {
    $menu add cascade -label "Image Data" -menu $menu.imageData
    set mn [menu $menu.imageData -bg $color -tearoff 0 ]
    $mn add command -label "Gradient Information" -command "evaluate \"$object -rangeInformation \[ \[ evaluate { new ginfo 10 0 none false false 0 255 } \] -cast \] \" "
    $mn add command -label "Gradient Balloon Information" -command "evaluate \"$object -rangeInformation \[ \[ evaluate { new gbinfo 0 none 0.1 }\] -cast \] \" "
    $mn add command -label "Region Information" -command "evaluate \"$object -rangeInformation \[ \[ evaluate { new reginfo 10 4 0 inside 0 255 false} \] -cast \]\" "
    $mn add command -label "Gradient of the Gradient Information" -command "evaluate \"$object -rangeInformation \[ \[ evaluate { new gginfo 0 none}  \] -cast \]\" "
    $mn add command -label "Classify" -command "evaluate \"$object -rangeInformation \[ \[ evaluate { new clinfo 10 0 0 } \] -cast \]\" "
}


imagedata::displayExternalForce
Comments  
Arguments range
force
Used by  
Uses  
proc imagedata::displayExternalForce { range force } {
    variable gradientOrientation
    variable gradientStop
    variable useIntensity
    variable smoothLine
    variable displacement

    set root .dialogExternalForce
    set list [winfo children $root.f]
    set bg #A0D0A0
    set bg2 #80C080
    foreach w $list {destroy $w}

    switch $force {
    "none" {
        evaluate "$range -force none"
    }
    "local" {
        evaluate "$range -force local"
    }
    "gradient" {
        evaluate "$range -force gradient"

        frame $root.f.f1
        set gradientOrientation [ $range -gradient orientation]
        
        radiobutton $root.f.f1.none -variable imagedata::gradientOrientation -value {none} -text "No Orientation Constraint"  -relief flat -bg $bg -command "evaluate \"$range -gradient orientation none\""
        radiobutton $root.f.f1.direct -variable imagedata::gradientOrientation -value {direct} -text "Along Gradient"  -relief flat -bg $bg  -command "evaluate \"$range -gradient orientation direct\""
        radiobutton $root.f.f1.opposite -variable imagedata::gradientOrientation -value {opposite} -text "Along Opposite Gradient"  -relief flat -bg $bg  -command "evaluate \"$range -gradient orientation opposite\""
        pack $root.f.f1.none $root.f.f1.direct $root.f.f1.opposite -side left
        pack $root.f.f1 -expand true


        frame $root.f.f5
        set gradientStop [$range -gradient stop]
        radiobutton $root.f.f5.highest -variable imagedata::gradientStop -value highest -text "Highest gradient"  -relief flat -bg $bg -command "evaluate \"$range -gradient stop highest\""
        radiobutton $root.f.f5.closest -variable imagedata::gradientStop -value first -text "Closest gradient"  -relief flat -bg $bg -command "evaluate \"$range -gradient stop first\""
        pack $root.f.f5.highest $root.f.f5.closest -side left
        pack $root.f.f5 -expand true

        frame $root.f.f2
        scale $root.f.f2.rng -orient horizontal -label "Range" -from 0    -to 30 -length 200 -bg $bg
        $root.f.f2.rng set [$range -gradient range]
        bind $root.f.f2.rng <ButtonRelease-1> "evaluate \"$range -gradient range \[$root.f.f2.rng get\]\""
        set bounds [ [lindex [$range -images] 3] -glbounds]
        scale $root.f.f2.thres -orient horizontal -label {Gradient Threshold} -from [lindex $bounds 0] -to [lindex $bounds 1] -length 200 -bg $bg
        $root.f.f2.thres set [$range -gradient threshold]
        bind $root.f.f2.thres <ButtonRelease-1> "evaluate \"$range -gradient threshold \[$root.f.f2.thres get\]\""
        pack $root.f.f2.thres $root.f.f2.rng -fill both
        pack $root.f.f2 -expand true

        frame $root.f.f3
        set imagedata::useIntensity [$range -gradient intensity]
        checkbutton $root.f.f3.useIntensity -variable imagedata::useIntensity -onvalue true -offvalue false  -relief flat -bg $bg -command "evaluate \" $range -gradient intensity \$imagedata::useIntensity \" " -text "Use Intensity "
        pack $root.f.f3.useIntensity -fill both
        pack $root.f.f3 -side left

        frame $root.f.f4
        set bounds [ [lindex [$range -images] 1] -glbounds]
        scale $root.f.f4.min -orient horizontal -label {Minimum Intensity} -from [lindex $bounds 0] -to [lindex $bounds 1] -length 200 -bg $bg
        $root.f.f4.min set [$range -gradient min]
        bind $root.f.f4.min <ButtonRelease-1> "evaluate \"$range -gradient min \[$root.f.f4.min get\]\""
        scale  $root.f.f4.max -orient horizontal -label {Maximum Intensity} -from [lindex $bounds 0] -to [lindex $bounds 1] -length 200 -bg $bg
        $root.f.f4.max set [$range -gradient max]
        bind $root.f.f4.max <ButtonRelease-1> "evaluate \"$range -gradient max \[$root.f.f4.max get\]\""
        pack $root.f.f4.min $root.f.f4.max -side left
        pack $root.f.f4 -side left

        pack $root.f -expand true
    }
    "region" {
        evaluate "$range -force region"

        frame $root.f.f1
        set gradientOrientation [ $range -region orientation]
        radiobutton $root.f.f1.inside -variable imagedata::gradientOrientation -value {inside} -text "Inside"  -relief flat -bg $bg -command "evaluate \"$range -region orientation inside\""
        radiobutton $root.f.f1.outside -variable imagedata::gradientOrientation -value {outside} -text "Outside"  -relief flat -bg $bg  -command "evaluate \"$range -region orientation outside\""

        pack $root.f.f1.inside $root.f.f1.outside  -side left
        pack $root.f.f1 -expand true

        frame $root.f.f2
        scale $root.f.f2.rng -orient horizontal -label "Range" -from 0    -to 30 -length 200 -bg $bg
        $root.f.f2.rng set [$range -gradient range]
        bind $root.f.f2.rng <ButtonRelease-1> "evaluate \"$range -region range \[$root.f.f2.rng get\]\""
        set bounds [ [lindex [$range -images] 3] -glbounds]
        scale  $root.f.f2.thres -orient horizontal -label {Gradient Threshold} -from [lindex $bounds 0] -to [lindex $bounds 1] -length 200 -bg $bg
        $root.f.f2.thres set [$range -region threshold]
        bind $root.f.f2.thres <ButtonRelease-1> " evaluate \"$range -region threshold \[$root.f.f2.thres get\]\""
        pack $root.f.f2.thres $root.f.f2.rng -fill both
        pack $root.f.f2 -expand true

        frame $root.f.f3
        scale  $root.f.f3.length -orient horizontal -label {Minimum Region Length} -from 0 -to 10 -length 200 -bg $bg
        $root.f.f3.length set [$range -region length]
        bind $root.f.f3.length <ButtonRelease-1> "evaluate \"$range -region length \[$root.f.f3.length get\]\""
        pack $root.f.f3.length -fill both
        pack $root.f.f3 -expand true

        frame $root.f.f4
        set bounds [ [lindex [$range -images] 1] -glbounds]
        scale  $root.f.f4.min -orient horizontal -label {Minimum Intensity} -from [lindex $bounds 0] -to [expr [lindex $bounds 1] + 1] -length 200 -bg $bg
        $root.f.f4.min set [$range -region min]
        bind $root.f.f4.min <ButtonRelease-1> "evaluate \"$range -region min \[$root.f.f4.min get\]\""
        scale  $root.f.f4.max -orient horizontal -label {Maximum Intensity} -from [lindex $bounds 0] -to [expr [lindex $bounds 1] + 1] -length 200 -bg $bg
        $root.f.f4.max set [$range -region max]
        bind $root.f.f4.max <ButtonRelease-1> "evaluate \"$range -region max \[$root.f.f4.max get\]\""
        pack $root.f.f4.min $root.f.f4.max -side left
        pack $root.f.f4 -expand true

        frame $root.f.f5
        set imagedata::smoothLine [$range -region smooth]
        checkbutton $root.f.f5.smoothLine -variable imagedata::smoothLine -onvalue {true} -offvalue {false}  -relief flat -bg $bg -command " evaluate \" $range -region smooth \$imagedata::smoothLine \" " -text "Smooth Intensity Profile "
        pack $root.f.f5.smoothLine -fill both
        pack $root.f.f5 -side left

        pack $root.f -expand true
    }
    "gradientBalloon" {
        evaluate "$range -force gradientBalloon"

        frame $root.f.f1
        set gradientOrientation [$range -gradientBalloon orientation]
        
        radiobutton $root.f.f1.direct -variable imagedata::gradientOrientation -value {direct} -text "Along Gradient"  -relief flat -bg $bg  -command "evaluate \"$range -gradientBalloon orientation direct\""
        radiobutton $root.f.f1.opposite -variable imagedata::gradientOrientation -value {opposite} -text "Along Opposite Gradient"  -relief flat -bg $bg  -command "evaluate \"$range -gradientBalloon orientation opposite\""
        pack $root.f.f1.direct $root.f.f1.opposite -side left
        pack $root.f.f1 -expand true

        frame $root.f.f2
        set bounds [ [lindex [$range -images] 3] -glbounds]
        scale $root.f.f2.thres -orient horizontal -label {Gradient Threshold} -from [lindex $bounds 0] -to [lindex $bounds 1] -length 200 -bg $bg
        $root.f.f2.thres set [$range -gradientBalloon threshold]
        bind $root.f.f2.thres <ButtonRelease-1> "evaluate \"$range -gradientBalloon threshold \[$root.f.f2.thres get\]\""
        pack $root.f.f2.thres  -fill both
        pack $root.f.f2 -expand true

        frame $root.f.f3
        scale $root.f.f3.displacement -orient horizontal -from 0.0 -to 3.0 -resolution 0.1 -length 200 -bg $bg -label "Maximum Normal Displacement"
        $root.f.f3.displacement set [$range -gradientBalloon displacement]
        bind $root.f.f3.displacement <ButtonRelease-1> "evaluate \"$range -gradientBalloon displacement \[$root.f.f3.displacement get\]\" "
        pack $root.f.f3.displacement -fill both
        pack $root.f.f3 -expand true

        pack $root.f -expand true
    }
    "gradient2" {
        evaluate "$range -force gradient2"
    }
    "classify" {
        evaluate "$range -force classify"

        frame $root.f.f1
        scale $root.f.f1.rng -orient horizontal -label "Range" -from 0    -to 30 -length 200 -bg $bg
        $root.f.f1.rng set [$range -classify range]
        bind $root.f.f1.rng <ButtonRelease-1> "evaluate \"$range -classify range \[$root.f.f1.rng get\]\""
        bind $root.f.f1.rng <Enter> "focus $root.f.f1.rng"
        pack $root.f.f1.rng -fill y -expand true
        pack $root.f.f1 -expand true


        frame $root.f.f2 -bg $bg
        frame $root.f.f2.l -bg $bg
        frame $root.f.f2.r -bg $bg
        
        label $root.f.f2.l.l -text "Inside classes" -bg $bg
        entry $root.f.f2.l.e -bg white -fg black
        bind $root.f.f2.l.e <Key-Return> "$root.f.f2.l.b insert end \[$root.f.f2.l.e get\]; $root.f.f2.l.e delete 0 end; evaluate \"$range -classify inclasses \[$root.f.f2.l.b size\] \[$root.f.f2.l.b get 0 end\]\""
        listbox $root.f.f2.l.b -bg white -fg black
        pack $root.f.f2.l.l $root.f.f2.l.e $root.f.f2.l.b -expand true -fill x
        set ins [$range -classify inclasses]
        set nin [lindex $ins 0]
        set inclasses [lrange $ins 1 $nin]
        foreach f $inclasses { $root.f.f2.l.b insert end $f }
        bind $root.f.f2.l.b <Enter> "focus $root.f.f2.l.b"
        bind $root.f.f2.l.b <Key-Delete> "foreach f \[$root.f.f2.l.b curselection\] { $root.f.f2.l.b delete \$f }; evaluate \"$range -classify inclasses \[$root.f.f2.l.b size\] \[$root.f.f2.l.b get 0 end\]\""

        label $root.f.f2.r.l -text "Outside classes" -bg $bg
        entry $root.f.f2.r.e -bg white -fg black
        bind $root.f.f2.r.e <Key-Return> "$root.f.f2.r.b insert end \[$root.f.f2.r.e get\]; $root.f.f2.r.e delete 0 end; evaluate \"$range -classify outclasses \[$root.f.f2.r.b size\] \[$root.f.f2.r.b get 0 end\]\""
        listbox $root.f.f2.r.b -bg white -fg black
        pack $root.f.f2.r.l $root.f.f2.r.e $root.f.f2.r.b -expand true -fill x
        set outs [$range -classify outclasses]
        set nout [lindex $outs 0]
        set outclasses [lrange $outs 1 $nout]
        foreach f $outclasses { $root.f.f2.r.b insert end $f }
        bind $root.f.f2.r.b <Enter> "focus $root.f.f2.r.b"
        bind $root.f.f2.r.b <Key-Delete> "foreach f \[$root.f.f2.r.b curselection\] { $root.f.f2.r.b delete \$f }; evaluate \"$range -classify outclasses \[$root.f.f2.r.b size\] \[$root.f.f2.r.b get 0 end\]\""
        
        pack $root.f.f2.l $root.f.f2.r -side left -fill both -expand true
        pack $root.f.f2 -expand true

        pack $root.f -expand true
    }
    }
    pack $root.f -expand true
}


imagedata::displayIntensityProfile
Comments  
Arguments il1
il2
Used by imagedata::viewImageProfile
Uses  
proc imagedata::displayIntensityProfile { il1 il2 } {
    set root .displayIntensityProfile$il1
    if ![winfo exists $root] {
    set color white
    toplevel $root -bg $color
    wm title $root "Profile $il1 and $il2"
    frame $root.f -bg $color
    set x {}
    set y {}
    foreach {i} [ lindex [$il1 -dump] 0]  {
        lappend x  [ lindex $i 0 ]
        lappend y [ lindex $i 1 ]  
    }
    set graph $root.f.g
    #load BLT
    package require BLT

    blt::graph $graph -plotbackground $color
    
    $graph element create $il1 -xdata $x -ydata $y -linewidth 1 -scalesymbols yes -pixels 2 -symbol "" -label "Intensity"
    if  [ string match il* $il2] {
        puts "$il2"
        set y2 {}
        foreach {i} [ lindex [$il2 -dump] 0]  {
        lappend y2 [ lindex $i 1 ]  
        }        
        $graph element create $il2 -xdata $x -ydata $y2 -linewidth 1 -scalesymbols yes -pixels 2 -symbol "" -label "Gradient" -color red
        #        $graph axis configure y2 -hide false
    }
    Blt_ZoomStack $graph
    Blt_ClosestPoint $graph
    pack  $graph -fill both
    pack $root.f -side top

    frame $root.buttons -bg white

    button $root.buttons.destroy -text "Dismiss" -command "$il1 -destroy;if [ string match il* $il2 ] {$il2 -destroy };destroy $root" -bg white
    pack $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both

    }
    
}


imagedata::editClassDialog
Comments  
Arguments cinf
color
Used by imagedata::editRangeInformation
Uses  
proc imagedata::editClassDialog { cinf { color "#E8E0D2" } } {
    variable gradientOrientation
    set root .editClassDialog
    if ![winfo exists $root] {
    toplevel $root -bg $color
    wm title $root "Classify Information Edition"

    frame $root.f -bg $color
    set bg $color

    frame $root.f.f2
    scale $root.f.f2.rng -orient horizontal -label "Range" -from 0    -to 30 -length 200 -bg $bg
    $root.f.f2.rng set [$cinf -edit range]
    bind $root.f.f2.rng <ButtonRelease-1> "evaluate \"$cinf -edit range \[$root.f.f2.rng get\]\""
    pack $root.f.f2.rng -side right -fill y
    pack $root.f.f2 -expand true

    frame $root.f.f3
    label $root.f.f3.l -justify center -text "Label of inside classes"
    scrollbar $root.f.f3.scroll -command "$root.f.f3.list yview"
    listbox $root.f.f3.list -yscroll "$root.f.f3.scroll set" -setgrid 1 -height 3
    pack $root.f.f3.l -side right -fill y
    pack $root.f.f3.scroll -side right -fill y
    pack $root.f.f3.list -side left -expand 1 -fill both

    set in [$cinf -edit inclasses]
    if ![string match $in "0"] {
        foreach {i}  [ lrange $in 1 end ] {
        $root.f.f3.list insert end $i
        }
    }
    pack $root.f.f3 -expand true

    frame $root.f.f4
    label $root.f.f4.l -justify center -text "Label of outside classes"
    scrollbar $root.f.f4.scroll -command "$root.f.f4.list yview"
    listbox $root.f.f4.list -yscroll "$root.f.f4.scroll set" -setgrid 1 -height 3
    pack $root.f.f4.l -side right -fill y
    pack $root.f.f4.scroll -side right -fill y
    pack $root.f.f4.list -side left -expand 1 -fill both

    set out [$cinf -edit outclasses]
    if ![string match $in "0"] {
        foreach {i}  [ lrange $out 1 end ] {
        $root.f.f4.list insert end $i
        }
    }
    pack $root.f.f4 -expand true

    frame $root.f.f5
    scale $root.f.f5.inl -orient horizontal -label "Inside Region Length" -from 0    -to 20 -length 200 -bg $bg
    $root.f.f5.inl set [$cinf -edit inlength]
    bind $root.f.f5.inl <ButtonRelease-1> "evaluate \"$cinf -edit inlength \[$root.f.f5.inl get\]\""
    pack $root.f.f5.inl -side right -fill y
    pack $root.f.f5 -expand true

    frame $root.f.f6
    scale $root.f.f6.outl -orient horizontal -label "Outside Region Length" -from 0    -to 20 -length 200 -bg $bg
    $root.f.f6.outl set [$cinf -edit outlength]
    bind $root.f.f6.outl <ButtonRelease-1> "evaluate \"$cinf -edit outlength \[$root.f.f6.outl get\]\""
    pack $root.f.f6.outl -side right -fill y
    pack $root.f.f6 -expand true

    frame $root.f.f7
    button $root.f.f7.dismiss -text "Dismiss" -command "destroy $root" -bg $bg -padx 10 -pady 10
    
    pack $root.f.f7.dismiss -side left
    pack $root.f.f7 -expand true

    pack $root.f -expand true
    }
}


imagedata::editGradientBalloonDialog
Comments  
Arguments gbinf
color
Used by imagedata::editRangeInformation
Uses  
proc imagedata::editGradientBalloonDialog { gbinf { color "#E8E0D2" } } {
    variable gradientOrientation
    set root .editGradientBalloonDialog
    if ![winfo exists $root] {
    toplevel $root -bg $color
    wm title $root "Gradient Balloon Information Edition"

    frame $root.f -bg $color
    
    frame $root.f.f1     
    set gradientOrientation [$gbinf -edit orientation]
    set bg $color
    
    radiobutton $root.f.f1.direct -variable imagedata::gradientOrientation -value {direct} -text "Along Gradient"  -relief flat -bg $bg  -command "evaluate \"$gbinf -edit orientation direct\""
    radiobutton $root.f.f1.opposite -variable imagedata::gradientOrientation -value {opposite} -text "Along Opposite Gradient"  -relief flat -bg $bg  -command "evaluate \"$gbinf -edit orientation opposite\""
    radiobutton $root.f.f1.none -variable imagedata::gradientOrientation -value {none} -text "No Direction Constraint"  -relief flat -bg $bg  -command "evaluate \"$gbinf -edit orientation none\""
    pack $root.f.f1.none $root.f.f1.direct $root.f.f1.opposite -side left
    pack $root.f.f1 -expand true
    
    frame $root.f.f2
    set rimage [which rimg2D]
    if [string match $rimage ""] {
        set rimage [which rimg3D]
    }
    if  ![string match $rimage ""] {
        set bounds  [ [lindex [ [lindex $rimage 0] -images] 3] -glbounds]
    } else {
        set val [ expr [$gbinf -edit threshold] * 2.0 ]
        if ![string match $val "0"] {
        set val 255
        }
        set bounds "0 $val"
    }
    scale $root.f.f2.thres -orient horizontal -label {Gradient Threshold} -from [lindex $bounds 0] -to [lindex $bounds 1] -length 200 -bg $bg
    $root.f.f2.thres set [$gbinf -edit threshold]
    bind $root.f.f2.thres <ButtonRelease-1> "evaluate \"$gbinf -edit threshold \[$root.f.f2.thres get\]\""
    pack $root.f.f2.thres  -fill both
    pack $root.f.f2 -expand true
    
    frame $root.f.f3
    scale $root.f.f3.displacement -orient horizontal -from 0.0 -to 3.0 -resolution 0.1 -length 200 -bg $bg -label "Maximum Normal Displacement"
    $root.f.f3.displacement set [$gbinf -edit force]
    bind $root.f.f3.displacement <ButtonRelease-1> "evaluate \"$gbinf -edit force \[$root.f.f3.displacement get\]\" "
    pack $root.f.f3.displacement -side left
    pack $root.f.f3 -expand true
    
    frame $root.f.f6
    button $root.f.f6.dismiss -text "Dismiss" -command "destroy $root" -bg $bg -padx 10 -pady 10
    
    pack $root.f.f6.dismiss -side left
    pack $root.f.f6 -expand true

    pack $root.f -expand true
    }
}


imagedata::editGradientDialog
Comments  
Arguments ginf
color
Used by imagedata::editRangeInformation
Uses  
proc imagedata::editGradientDialog { ginf { color "#E8E0D2" } } {
    variable gradientOrientation
    variable gradientStop
    set root .editGradientDialog
    if ![winfo exists $root] {
    toplevel $root -bg $color
    wm title $root "Gradient Information edition"

    frame $root.f -bg $color
    
    frame $root.f.f1
    set gradientOrientation [ $ginf -edit orientation]
    set bg $color

    radiobutton $root.f.f1.none -variable imagedata::gradientOrientation -value {none} -text "No Orientation Constraint"  -relief flat -bg $bg -command "evaluate \"$ginf -edit orientation none\""
    radiobutton $root.f.f1.direct -variable imagedata::gradientOrientation -value {direct} -text "Along Gradient"  -relief flat -bg $bg  -command "evaluate \"$ginf -edit orientation direct\""
    radiobutton $root.f.f1.opposite -variable imagedata::gradientOrientation -value {opposite} -text "Along Opposite Gradient"  -relief flat -bg $bg  -command "evaluate \"$ginf -edit orientation opposite\""
    pack $root.f.f1.none $root.f.f1.direct $root.f.f1.opposite -side left
    pack $root.f.f1 -expand true


    frame $root.f.f5
    set gradientStop [$ginf -edit stop]
    radiobutton $root.f.f5.highest -variable imagedata::gradientStop -value highest -text "Highest gradient"  -relief flat -bg $bg -command "evaluate \"$ginf -edit stop highest\""
    radiobutton $root.f.f5.closest -variable imagedata::gradientStop -value first -text "Closest gradient"  -relief flat -bg $bg -command "evaluate \"$ginf -edit stop first\""
    pack $root.f.f5.highest $root.f.f5.closest -side left
    pack $root.f.f5 -expand true

    frame $root.f.f2
    scale $root.f.f2.rng -orient horizontal -label "Range" -from 0    -to 30 -length 200 -bg $bg
    $root.f.f2.rng set [$ginf -edit range]
    bind $root.f.f2.rng <ButtonRelease-1> "evaluate \"$ginf -edit range \[$root.f.f2.rng get\]\""

    set rimage [which rimg2D]
    if [string match $rimage ""] {
        set rimage [which rimg3D]
    }
    if  ![string match $rimage ""] {
        set bounds  [ [lindex [ [lindex $rimage 0] -images] 3] -glbounds]
    } else {
        set val [ expr [$ginf -edit threshold] * 2.0 ]
        if ![string match $val "0"] {
        set val 255
        }
        set bounds "0 $val"
    }
    
    scale $root.f.f2.thres -orient horizontal -label {Gradient Threshold} -from [lindex $bounds 0] -to [lindex $bounds 1] -length 200 -bg $bg
    $root.f.f2.thres set [$ginf -edit threshold]
    bind $root.f.f2.thres <ButtonRelease-1> "evaluate \"$ginf -edit threshold \[$root.f.f2.thres get\]\""
    pack $root.f.f2.thres $root.f.f2.rng -fill both
    pack $root.f.f2 -expand true
    
    frame $root.f.f3
    set useIntensity [$ginf -edit intensity]
    checkbutton $root.f.f3.useIntensity -variable imagedata::useIntensity -onvalue true -offvalue false  -relief flat -bg $bg -command "evaluate \" $ginf -edit intensity \$imagedata::useIntensity \" " -text "Use Intensity "
    pack $root.f.f3.useIntensity -fill both
    pack $root.f.f3 -side left
    
    frame $root.f.f4
    if  ![string match $rimage ""] {
        set bounds  [ [lindex [ [lindex $rimage 0] -images] 1] -glbounds]
    } else {
        set val [ expr [$ginf -edit max] * 2.0 ]
        if ![string match $val "0"] {
        set val 255
        }
        set bounds "0 $val"
    }
    scale $root.f.f4.min -orient horizontal -label {Minimum Intensity} -from [lindex $bounds 0] -to [lindex $bounds 1] -length 200 -bg $bg
    $root.f.f4.min set [$ginf -edit min]
    bind $root.f.f4.min <ButtonRelease-1> "evaluate \"$ginf -edit min \[$root.f.f4.min get\]\""
    scale  $root.f.f4.max -orient horizontal -label {Maximum Intensity} -from [lindex $bounds 0] -to [lindex $bounds 1] -length 200 -bg $bg
    $root.f.f4.max set [$ginf -edit max]
    bind $root.f.f4.max <ButtonRelease-1> "evaluate \"$ginf -edit max \[$root.f.f4.max get\]\""
    pack $root.f.f4.min $root.f.f4.max -side left
    pack $root.f.f4 -expand true
    
    frame $root.f.f6
    button $root.f.f6.dismiss -text "Dismiss" -command "destroy $root" -bg $bg
    
    pack $root.f.f6.dismiss -side left
    pack $root.f.f6 -expand true
    pack $root.f -expand true

    }
}


imagedata::editGradientGradientDialog
Comments  
Arguments gginf
color
Used by imagedata::editRangeInformation
Uses  
proc imagedata::editGradientGradientDialog { gginf { color "#E8E0D2" } } {
    variable gradientOrientation
    set root .editGradientBalloonDialog
    if ![winfo exists $root] {
    toplevel $root -bg $color
    wm title $root "Classify Information Edition"

    frame $root.f -bg $color
    set bg $color
    frame $root.f.f1     
    set gradientOrientation [$gginf -edit orientation]
    
    radiobutton $root.f.f1.direct -variable imagedata::gradientOrientation -value {direct} -text "Along Gradient"  -relief flat -bg $bg  -command "evaluate \"$gginf -edit orientation direct\""
    radiobutton $root.f.f1.opposite -variable imagedata::gradientOrientation -value {opposite} -text "Along Opposite Gradient"  -relief flat -bg $bg  -command "evaluate \"$gginf -edit orientation opposite\""
    radiobutton $root.f.f1.none -variable imagedata::gradientOrientation -value {none} -text "No Direction Constraint"  -relief flat -bg $bg  -command "evaluate \"$gginf -edit orientation none\""
    pack  $root.f.f1.none $root.f.f1.direct $root.f.f1.opposite -side left
    pack $root.f.f1 -expand true
    
    frame $root.f.f2
    set rimage [which rimg2D]
    if [string match $rimage ""] {
        set rimage [which rimg3D]
    }
    if  ![string match $rimage ""] {
        set bounds  [ [lindex [ [lindex $rimage 0] -images] 3] -glbounds]
    } else {
        set val [ expr [$gginf -edit threshold] * 2.0 ]
        if ![string match $val "0"] {
        set val 255
        }
        set bounds "0 $val"
    }
    scale $root.f.f2.thres -orient horizontal -label {Gradient Threshold} -from [lindex $bounds 0] -to [lindex $bounds 1] -length 200 -bg $bg
    $root.f.f2.thres set [$gginf -edit threshold]
    bind $root.f.f2.thres <ButtonRelease-1> "evaluate \"$gginf -edit threshold \[$root.f.f2.thres get\]\""
    pack $root.f.f2.thres  -side left
    pack $root.f.f2 -expand true

    frame $root.f.f6
    button $root.f.f6.dismiss -text "Dismiss" -command "destroy $root" -bg $bg -padx 10 -pady 10
    
    pack $root.f.f6.dismiss -side left
    pack $root.f.f6 -expand true

    pack $root.f -expand true
    }
}


imagedata::editIntensityProfileDialog
Comments  
Arguments ipinf
color
Used by triangulation::installPrecomputedTriangulation3DMenu
contour::installActiveContour3DMenu
imagedata::editRangeInformation
contour::installSliceActiveContour2DMenu
SM2::installSM2
Uses  
proc imagedata::editIntensityProfileDialog { ipinf { color "#E8E0D2" } } {
    variable criterion
    variable th
    variable range
    variable org
    set root .editGradientDialog
    if ![winfo exists $root] {
    toplevel $root -bg $color
    wm title $root "Intensity Profile Information edition"

    frame $root.f -bg $color
    
    frame $root.f.f1
    set criterion  [ $ipinf -edit criterion]
    set bg $color

    radiobutton $root.f.f1.abs -variable imagedata::criterion -value {differences} -text "Absolute Differences"  -relief flat -bg $bg -command "$root.f.f2.th configure -from 0 -to 255 -resolution 1; $root.f.f2.th set 50; evaluate \"$ipinf -edit criterion differences\""
    radiobutton $root.f.f1.linear -variable imagedata::criterion -value {linear} -text "Linear Coefficient"  -relief flat -bg $bg -command "$root.f.f2.th configure -from 0 -to 1.0 -resolution 0.01; $root.f.f2.th set 0.5;evaluate \"$ipinf -edit criterion linear\""
    radiobutton $root.f.f1.corr -variable imagedata::criterion -value {correlation} -text "Correlation Coefficient"  -relief flat -bg $bg -command "$root.f.f2.th configure -from 0 -to 1.0 -resolution 0.01; $root.f.f2.th set 0.5;evaluate \"$ipinf -edit criterion correlation\""
    radiobutton $root.f.f1.pattern -variable imagedata::criterion -value {pattern} -text "Pattern Intensity"  -relief flat -bg $bg -command "$root.f.f2.th configure -from 0 -to 100 -resolution 1; $root.f.f2.th set 30.0; evaluate \"$ipinf -edit criterion pattern\""

    pack $root.f.f1.abs $root.f.f1.linear $root.f.f1.corr  $root.f.f1.pattern -side left
    pack $root.f.f1 -expand true

    frame $root.f.f2
    set th  [ $ipinf -edit threshold]

    scale $root.f.f2.th -label threshold -orient horizontal -from 0 -to 255 -bg $bg -variable imagedata::th
    bind $root.f.f2.th  <ButtonRelease-1> "evaluate \"$ipinf -edit threshold \$imagedata::th \" "
    pack $root.f.f2.th -side left
    pack $root.f.f2 -expand true


    frame $root.f.f3
    set range  [ $ipinf -edit range]

    scale $root.f.f3.rng -label "Force range" -orient horizontal -from 0.0 -to 30.0 -resolution 0.1 -bg $color -variable imagedata::range
    bind $root.f.f3.rng  <ButtonRelease-1> "evaluate \"$ipinf -edit range \$imagedata::range \" "
    pack $root.f.f3.rng -side left
    pack $root.f.f3 -expand true

    frame $root.f.f4
    set org  [ $ipinf -edit origin]

    scale $root.f.f4.org -label "Origin" -orient horizontal -from -10.0 -to 10.0 -resolution 0.1 -bg $color -variable imagedata::org
    bind $root.f.f4.org  <ButtonRelease-1> "evaluate \"$ipinf -edit origin \$imagedata::org \" "
    pack $root.f.f4.org -side left
    pack $root.f.f4 -expand true

    if ![ string match  ipinfos* $ipinf ] {
        frame $root.f.f5
        button $root.f.f5.il -text "Show Intensity Profile" -command "$ipinf -draw;destroy $root" -bg $bg
        pack $root.f.f5.il -side left
        pack $root.f.f5 -expand true
    }

    frame $root.f.f6
    button $root.f.f6.dismiss -text "Dismiss" -command "destroy $root" -bg $bg
    
    pack $root.f.f6.dismiss -side left
    pack $root.f.f6 -expand true
    pack $root.f -expand true
    }
}


imagedata::editRangeInformation
Comments  
Arguments rinfo
Used by SM2::selectZone
contour::installContourExternalMenu
SM2::selectVertex
tetrahedrisation::installActiveTetra3DMenu
contour::installContourVertexMenu
SM2::installSM2
triangulation::installPrecomputedTriangulation3DMenu
triangulation::installActiveTriangulation3DMenu
Uses imagedata::editGradientDialog
imagedata::editClassDialog
imagedata::editIntensityProfileDialog
imagedata::editGradientGradientDialog
imagedata::editRegionDialog
imagedata::editGradientBalloonDialog
proc imagedata::editRangeInformation {rinfo} {
    set name [$rinfo -name]
    switch $name {
    "Gradient" {
        set ginf [new ginfo $rinfo]
        imagedata::editGradientDialog $ginf
    }
    "Region" {
        set rinf [new reginfo $rinfo]
        imagedata::editRegionDialog $rinf
    }
    "GradientBalloon" {
        set gbinf [new gbinfo $rinfo]
        imagedata::editGradientBalloonDialog $gbinf
    }
    "GradientGradient" {
        set gginf [new gginfo $rinfo]
        imagedata::editGradientGradientDialog $gginf
    }
    "Classify" {
        set cinf [new clinfo $rinfo]
        imagedata::editClassDialog $cinf
    }
    "Intensity Profile" {
        set ipinf [new ipinfo $rinfo]
        imagedata::editIntensityProfileDialog $ipinf
    }
    }
}


imagedata::editRegionDialog
Comments  
Arguments rinf
color
Used by imagedata::editRangeInformation
Uses  
proc imagedata::editRegionDialog { rinf { color "#E8E0D2" } } {
    variable gradientOrientation
    variable smoothLine
    set root .editRegionDialog
    if ![winfo exists $root] {
    toplevel $root -bg $color
    wm title $root "Region Information Edition"

    frame $root.f -bg $color
    
    frame $root.f.f1
    set bg $color

    set gradientOrientation [ $rinf -edit orientation]
    radiobutton $root.f.f1.inside -variable imagedata::gradientOrientation -value {inside} -text "Inside"  -relief flat -bg $bg -command "evaluate \"$rinf -edit orientation inside\""
    radiobutton $root.f.f1.outside -variable imagedata::gradientOrientation -value {outside} -text "Outside"  -relief flat -bg $bg  -command "evaluate \"$rinf -edit orientation outside\""
    
    pack $root.f.f1.inside $root.f.f1.outside  -side left
    pack $root.f.f1 -expand true
    
    frame $root.f.f2
    scale $root.f.f2.rng -orient horizontal -label "Range" -from 0    -to 30 -length 200 -bg $bg
    $root.f.f2.rng set [$rinf -edit range]
    bind $root.f.f2.rng <ButtonRelease-1> "evaluate \"$rinf -edit range \[$root.f.f2.rng get\]\""

    set rimage [which rimg2D]
    if [string match $rimage ""] {
        set rimage [which rimg3D]
    }
    if  ![string match $rimage ""] {
        set bounds  [ [lindex [ [lindex $rimage 0] -images] 3] -glbounds]
    } else {
        set val [ expr [$rinf -edit threshold] * 2.0 ]
        if ![string match $val "0"] {
        set val 255
        }
        set bounds "0 $val"
    }

    scale  $root.f.f2.thres -orient horizontal -label {Gradient Threshold} -from [lindex $bounds 0] -to [lindex $bounds 1] -length 200 -bg $bg
    $root.f.f2.thres set [$rinf -edit threshold]
    bind $root.f.f2.thres <ButtonRelease-1> " evaluate \"$rinf -edit threshold \[$root.f.f2.thres get\]\""
    pack $root.f.f2.thres $root.f.f2.rng -fill both
    pack $root.f.f2 -expand true
    
    frame $root.f.f3
    scale  $root.f.f3.length -orient horizontal -label {Minimum Region Length} -from 0 -to 10 -length 200 -bg $bg
    $root.f.f3.length set [$rinf -edit length]
    bind $root.f.f3.length <ButtonRelease-1> "evaluate \"$rinf  -edit length \[$root.f.f3.length get\]\""
    pack $root.f.f3.length -fill both
    pack $root.f.f3 -expand true
    
    frame $root.f.f4
    if  ![string match $rimage ""] {
        set bounds  [ [lindex [ [lindex $rimage 0] -images] 1] -glbounds]
    } else {
        set val [ expr [$rinf -edit max] * 2.0 ]
        if ![string match $val "0"] {
        set val 255
        }
        set bounds "0 $val"
    }
    scale  $root.f.f4.min -orient horizontal -label {Minimum Intensity} -from [lindex $bounds 0] -to [expr [lindex $bounds 1] + 1] -length 200 -bg $bg
    $root.f.f4.min set [$rinf -edit min]
    bind $root.f.f4.min <ButtonRelease-1> "evaluate \"$rinf -edit min \[$root.f.f4.min get\]\""
    scale  $root.f.f4.max -orient horizontal -label {Maximum Intensity} -from [lindex $bounds 0] -to [expr [lindex $bounds 1] + 1] -length 200 -bg $bg
    $root.f.f4.max set [$rinf -edit max]
    bind $root.f.f4.max <ButtonRelease-1> "evaluate \"$rinf -edit max \[$root.f.f4.max get\]\""
    pack $root.f.f4.min $root.f.f4.max -side left
    pack $root.f.f4 -expand true
    
    frame $root.f.f5
    set imagedata::smoothLine [$rinf -edit smooth]
    checkbutton $root.f.f5.smoothLine -variable imagedata::smoothLine -onvalue {true} -offvalue {false}  -relief flat -bg $bg -command " evaluate \" $rinf -edit smooth \$imagedata::smoothLine \" " -text "Smooth Intensity Profile "
    pack $root.f.f5.smoothLine -side left
    pack $root.f.f5 -expand true -pady 10
    
    frame $root.f.f6
    button $root.f.f6.dismiss -text "Dismiss" -command "destroy $root" -bg $bg -padx 10 -pady 10
    
    pack $root.f.f6.dismiss -side left
    pack $root.f.f6 -expand true

    pack $root.f -expand true
    }
}


imagedata::externalForce
Comments  
Arguments range
Used by  
Uses  
proc imagedata::externalForce { range } {
    global forceType

    if {![winfo exists .dialogExternalForce]} {
    set bg #A0D0A0
    set bg2 #80C080
    set root .dialogExternalForce
    toplevel $root -bg $bg
    wm title $root "RangeInrimage2D External Force"

    set mn2 [tk_optionMenu $root.type forceType  "none" "local" "gradient" "region" "gradientBalloon" "gradient2" "classify"]
    $root.type  configure -bg $bg2

    for {set i 0} {$i <= [$mn2 index last]} {incr i} {
        $mn2 entryconfigure $i  -command "imagedata::displayExternalForce $range  \[$mn2 entrycget $i -label\]" -background $bg2
    }
    pack $root.type -padx 10 -pady 10 -expand true -fill x
    
    frame $root.f -bg $bg
    pack $root.f -expand true -fill both

    frame $root.buttons -bg $bg
    button $root.buttons.dismiss -text "Dismiss" -command "destroy $root" -bg $bg2 -width 40
    pack $root.buttons.dismiss -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both

    set forceType [$range -force]
    imagedata::displayExternalForce $range $forceType
    }
}


imagedata::gradientDialog
Comments  
Arguments range
img
color
Used by  
Uses inrimage::inrscale
proc imagedata::gradientDialog { range img {color "#E8E0D2"}} {

    if ![winfo exists .gradient] {
    toplevel .gradient -bg $color
    wm title .gradient "Gradient computation"

    frame .gradient.d -bg $color
    frame .gradient.b -bg $color

    frame .gradient.d.rec -bg $color
    radiobutton .gradient.d.rec.b1 -text "Recursive filters" -relief raised -variable inrimage::filter -value rec  -bg $color -anchor w -command { .gradient.d.rec.b2 configure -state normal; .gradient.d.rec.b3 configure -state normal; .gradient.d.rec.b4 configure -state normal; .gradient.d.rec.s1 configure -state normal; .gradient.d.sobel.s1 configure -state disabled }
    radiobutton .gradient.d.rec.b2 -text "Deriche step-edge" -variable inrimage::rfilter -value deriche  -bg $color -anchor w
    radiobutton .gradient.d.rec.b3 -text "Deriche gaussian" -variable inrimage::rfilter -value gaussian  -bg $color -anchor w
    radiobutton .gradient.d.rec.b4 -text "Marta" -variable inrimage::rfilter -value marta  -bg $color -anchor w
    set inrimage::rfilter deriche
    label .gradient.d.rec.l1 -text "Filter standard deviation" -bg $color -anchor w
    scale .gradient.d.rec.s1 -from 0.1 -to 20 -resolution 0.1 -orient horiz -bg $color
    .gradient.d.rec.s1 set 3
    bind .gradient.d.rec.s1 <Enter> { focus .gradient.d.rec.s1 }

    frame .gradient.d.sobel -bg $color
    radiobutton .gradient.d.sobel.b1 -text "Sobel filters" -relief raised -variable inrimage::filter -value sobel  -bg $color -anchor w -command { .gradient.d.rec.b2 configure -state disabled; .gradient.d.rec.b3 configure -state disabled; .gradient.d.rec.b4 configure -state disabled; .gradient.d.rec.s1 configure -state disabled; .gradient.d.sobel.s1 configure -state normal }
    label .gradient.d.sobel.l1 -text "Filter size" -bg $color -anchor w
    scale .gradient.d.sobel.s1 -from 1 -to 15 -orient horiz -bg $color -state disabled
    bind .gradient.d.sobel.s1 <Enter> { focus .gradient.d.sobel.s1 }

    set inrimage::filter rec

    frame .gradient.d.opt -bg $color
    label .gradient.d.opt.l1 -text "Options" -relief raised -bg $color
    radiobutton .gradient.d.opt.b1 -text "3D" -variable inrimage::dim -value "3D"  -bg $color -anchor w
    radiobutton .gradient.d.opt.b2 -text "2D" -variable inrimage::dim -value "2D"  -bg $color -anchor w
    set inrimage::dim 3D
    checkbutton .gradient.d.opt.b3 -text "Max gradient value along gradient direction" -variable max -onvalue max -offvalue ""  -bg $color -anchor w
    set max ""
    #         radiobutton .gradient.d.opt.b4 -text "Compute norm only" -variable inrimage::output -value ""  -bg $color -anchor w
    #         radiobutton .gradient.d.opt.b5 -text "Return gradient vectors" -variable inrimage::output -value "dir vectors"  -bg $color -anchor w
    #         radiobutton .gradient.d.opt.b6 -text "Sample gradient vectors" -variable inrimage::output -value "dir sample"  -bg $color -anchor w
    #        set inrimage::output ""
    checkbutton .gradient.d.opt.b7 -text "Low threshold" -variable lt -onvalue 1 -offvalue 0  -bg $color -anchor w -command { if $lt { .gradient.d.opt.s1 configure -state normal } else { .gradient.d.opt.s1 configure -state disabled } }
    inrimage::inrscale .gradient.d.opt.s1 $img $color min
    .gradient.d.opt.s1 configure -state disabled

    button .gradient.b.ok -text "OK" -command "set cmd \"$img -gradient \$inrimage::dim dir sample \$max \$inrimage::filter \"; if !\[string compare \$inrimage::filter rec\] { set cmd \[concat \$cmd \"\$inrimage::rfilter sigma \[.gradient.d.rec.s1 get\] \"\] } else { set cmd \[concat \$cmd \"sigma \[.gradient.d.sobel.s1 get\] \"\] }; if \$lt { set cmd \[concat \$cmd \"lt \[.gradient.d.opt.s1 get\]\"\]}; set images \[evaluate \$cmd\]; set gradient \[$range -images gradient\]; if !\[string compare \$gradient none\] evaluate \"\$gradient -destroy\";evaluate \"$range -images gradient \[lindex \$images 0\]\";set gradientDir \[$range -images gradientdir\]; if !\[string compare \$gradientDir none\] evaluate \"\$gradientDir -destroy\";evaluate \"$range -images gradientdir \[lindex \$images 1\]\";destroy .gradient" -bg $color
    button .gradient.b.dismiss -text "Dismiss" -command "destroy .gradient" -bg $color
    
    pack .gradient.d.rec.b1 .gradient.d.rec.b2 .gradient.d.rec.b3 .gradient.d.rec.b4 .gradient.d.rec.l1 .gradient.d.rec.s1 -fill x
    pack .gradient.d.sobel.b1 .gradient.d.sobel.l1 .gradient.d.sobel.s1 -fill x
    pack .gradient.d.opt.l1 .gradient.d.opt.b1 .gradient.d.opt.b2 -fill x
    pack .gradient.d.opt.b3 -fill x -pady 10
    #        pack .gradient.d.opt.b4 .gradient.d.opt.b5 .gradient.d.opt.b6 -fill x
    pack .gradient.d.opt.b7 -fill x -pady 10
    pack .gradient.d.opt.s1 -fill x
    pack .gradient.d.rec .gradient.d.sobel .gradient.d.opt -side left -fill both -padx 10 -pady 10

    pack .gradient.b.ok .gradient.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .gradient.d .gradient.b
    }
}


imagedata::gradientGradientDialog
Comments  
Arguments range
img
color
Used by imagedata::range2Dinstall
Uses inrimage::inrscale
proc imagedata::gradientGradientDialog { range img {color "#E8E0D2"}} {

    if ![winfo exists .gradient] {
    toplevel .gradient -bg $color
    wm title .gradient "Gradient computation of the Gradient image"

    frame .gradient.d -bg $color
    frame .gradient.b -bg $color

    frame .gradient.d.rec -bg $color
    radiobutton .gradient.d.rec.b1 -text "Recursive filters" -relief raised -variable inrimage::filter -value rec  -bg $color -anchor w -command { .gradient.d.rec.b2 configure -state normal; .gradient.d.rec.b3 configure -state normal; .gradient.d.rec.b4 configure -state normal; .gradient.d.rec.s1 configure -state normal; .gradient.d.sobel.s1 configure -state disabled }
    radiobutton .gradient.d.rec.b2 -text "Deriche step-edge" -variable inrimage::rfilter -value deriche  -bg $color -anchor w
    radiobutton .gradient.d.rec.b3 -text "Deriche gaussian" -variable inrimage::rfilter -value gaussian  -bg $color -anchor w
    radiobutton .gradient.d.rec.b4 -text "Marta" -variable inrimage::rfilter -value marta  -bg $color -anchor w
    set inrimage::rfilter deriche
    label .gradient.d.rec.l1 -text "Filter standard deviation" -bg $color -anchor w
    scale .gradient.d.rec.s1 -from 0.1 -to 20 -resolution 0.1 -orient horiz -bg $color
    .gradient.d.rec.s1 set 3
    bind .gradient.d.rec.s1 <Enter> { focus .gradient.d.rec.s1 }

    frame .gradient.d.sobel -bg $color
    radiobutton .gradient.d.sobel.b1 -text "Sobel filters" -relief raised -variable inrimage::filter -value sobel  -bg $color -anchor w -command { .gradient.d.rec.b2 configure -state disabled; .gradient.d.rec.b3 configure -state disabled; .gradient.d.rec.b4 configure -state disabled; .gradient.d.rec.s1 configure -state disabled; .gradient.d.sobel.s1 configure -state normal }
    label .gradient.d.sobel.l1 -text "Filter size" -bg $color -anchor w
    scale .gradient.d.sobel.s1 -from 1 -to 15 -orient horiz -bg $color -state disabled
    bind .gradient.d.sobel.s1 <Enter> { focus .gradient.d.sobel.s1 }

    set inrimage::filter rec

    frame .gradient.d.opt -bg $color
    label .gradient.d.opt.l1 -text "Options" -relief raised -bg $color
    radiobutton .gradient.d.opt.b1 -text "3D" -variable inrimage::dim -value "3D"  -bg $color -anchor w
    radiobutton .gradient.d.opt.b2 -text "2D" -variable inrimage::dim -value "2D"  -bg $color -anchor w
    set inrimage::dim 3D
    checkbutton .gradient.d.opt.b3 -text "Max gradient value along gradient direction" -variable max -onvalue max -offvalue ""  -bg $color -anchor w
    set max ""
    #         radiobutton .gradient.d.opt.b4 -text "Compute norm only" -variable inrimage::output -value ""  -bg $color -anchor w
    #         radiobutton .gradient.d.opt.b5 -text "Return gradient vectors" -variable inrimage::output -value "dir vectors"  -bg $color -anchor w
    #         radiobutton .gradient.d.opt.b6 -text "Sample gradient vectors" -variable inrimage::output -value "dir sample"  -bg $color -anchor w
    #        set inrimage::output ""
    checkbutton .gradient.d.opt.b7 -text "Low threshold" -variable lt -onvalue 1 -offvalue 0  -bg $color -anchor w -command { if $lt { .gradient.d.opt.s1 configure -state normal } else { .gradient.d.opt.s1 configure -state disabled } }
    inrimage::inrscale .gradient.d.opt.s1 $img $color min
    .gradient.d.opt.s1 configure -state disabled

    button .gradient.b.ok -text "OK" -command "set cmd \"$img -gradient \$inrimage::dim dir vectors \$max \$inrimage::filter \"; if !\[string compare \$inrimage::filter rec\] { set cmd \[concat \$cmd \"\$inrimage::rfilter sigma \[.gradient.d.rec.s1 get\] \"\] } else { set cmd \[concat \$cmd \"sigma \[.gradient.d.sobel.s1 get\] \"\] }; if \$lt { set cmd \[concat \$cmd \"lt \[.gradient.d.opt.s1 get\]\"\]}; set images \[evaluate \$cmd\]; set gradient \[$range -images gradient2\]; if !\[string compare \$gradient none\] evaluate \"\$gradient -destroy\";evaluate \"$range -images gradient2 \[lindex \$images 1\]\";evaluate \"\[lindex \$images 0\] -destroy\";destroy .gradient" -bg $color
    button .gradient.b.dismiss -text "Dismiss" -command "destroy .gradient" -bg $color
    
    pack .gradient.d.rec.b1 .gradient.d.rec.b2 .gradient.d.rec.b3 .gradient.d.rec.b4 .gradient.d.rec.l1 .gradient.d.rec.s1 -fill x
    pack .gradient.d.sobel.b1 .gradient.d.sobel.l1 .gradient.d.sobel.s1 -fill x
    pack .gradient.d.opt.l1 .gradient.d.opt.b1 .gradient.d.opt.b2 -fill x
    pack .gradient.d.opt.b3 -fill x -pady 10
    #        pack .gradient.d.opt.b4 .gradient.d.opt.b5 .gradient.d.opt.b6 -fill x
    pack .gradient.d.opt.b7 -fill x -pady 10
    pack .gradient.d.opt.s1 -fill x
    pack .gradient.d.rec .gradient.d.sobel .gradient.d.opt -side left -fill both -padx 10 -pady 10

    pack .gradient.b.ok .gradient.b.dismiss -side left -expand true -fill x -padx 20 -pady 10
    pack .gradient.d .gradient.b
    }
}


imagedata::installDisplayMenu
Comments  
Arguments parent
camera
object
color
Used by  
Uses  
proc imagedata::installDisplayMenu { parent camera object color } {
    menubutton $parent.context.display -text "Display" -menu $parent.context.display.mn -bg $color
    set menu [menu $parent.context.display.mn -bg $color -postcommand "set transpar \[lindex \[$object -transparency\] 0\]"]
    $menu add command -label none -command "evaluate \"$object -render none\""
    $menu add command -label solid -command "evaluate \"$object -render solid\""
    $menu add command -label texture -command "evaluate \"$object -render texture\""
    $menu add command -label "volume rendering" -command "evaluate \"$object -render volume\""
    $menu add separator
    $menu add cascade -label "grid" -menu $menu.grid
    set mn [menu $menu.grid -tearoff 0 -bg $color]
    $mn add command -label frame -command "evaluate \"$object -grid frame\""
    $mn add command -label grid -command "evaluate \"$object -grid grid\""
    $mn add command -label hide -command "evaluate \"$object -grid hide\""
    $mn add command -label "voxel grid" -command "evaluate \"$object -grid voxel\""
    $menu add cascade -label "grid width" -menu $menu.gridw
    set mn [menu $menu.gridw -tearoff 0 -bg $color]
    $mn add command -label 1 -command "evaluate \"$object -grid width 1\""
    $mn add command -label 2 -command "evaluate \"$object -grid width 2\""
    $mn add command -label 3 -command "evaluate \"$object -grid width 3\""

    $menu add command -label "grid color..." -command "set a \[$object -grid\]; set col \[modules::selectColor \[list \[lindex \$a 1\] \[lindex \$a 2\] \[lindex \$a 3\]\] \]; $object -grid color \[lindex \$col 0\] \[lindex \$col 1\] \[lindex \$col 2\]"

    $menu add separator

    $menu add cascade -label "box width" -menu $menu.box
    set mn [menu $menu.box -tearoff 0 -bg $color]
    $mn add command -label off -command "evaluate \"$object -box width 0\""
    $mn add command -label 1 -command "evaluate \"$object -box width 1\""
    $mn add command -label 2 -command "evaluate \"$object -box width 2\""
    $mn add command -label 3 -command "evaluate \"$object -box width 3\""
    $mn add command -label 5 -command "evaluate \"$object -box width 5\""

    $menu add command -label "box color..." -command "set a \[$object -box\]; set col \[modules::selectColor \[list \[lindex \$a 0\] \[lindex \$a 1\] \[lindex \$a 2\]\] \]; $object -box color \[lindex \$col 0\] \[lindex \$col 1\] \[lindex \$col 2\]"

    $menu add separator
    $menu add cascade -label "Show Black Pixels" -menu $menu.black
    set mn [menu $menu.black -tearoff 0 -bg $color -postcommand "set  imagedata::showBlackPixels \[$object -showBlackPixels\]" ]
    $mn add radiobutton -label "true" -variable imagedata::showBlackPixels  -command "evaluate \"$object -showBlackPixels true\""
    $mn add radiobutton -label "false" -variable imagedata::showBlackPixels  -command "evaluate \"$object -showBlackPixels false\""
    
    $menu add cascade -label "resolution" -menu $menu.res
    set mn [menu $menu.res -tearoff 0 -bg $color]
    $mn add command -label 1 -command "evaluate \"$object -resolution 1\""
    $mn add command -label 2 -command "evaluate \"$object -resolution 2\""
    $mn add command -label 4 -command "evaluate \"$object -resolution 4\""

    $menu add checkbutton -label "transparency" -variable transpar -onvalue true -offvalue false  -command "evaluate \"$object -transparency \$transpar\""
    $menu add cascade -label "opacity" -menu $menu.tr
    set mn [menu $menu.tr -tearoff 0 -bg $color]
    $mn add command -label "very opaque" -command "evaluate \"$object -transparency true 0.9\""
    $mn add command -label "quite opaque" -command "evaluate \"$object -transparency true 0.7\""
    $mn add command -label "half" -command "evaluate \"$object -transparency true 0.5\""
    $mn add command -label "quite transparent" -command "evaluate \"$object -transparency true 0.3\""
    $mn add command -label "very transparent" -command "evaluate \"$object -transparency true 0.1\""

    $menu add separator

    $menu add cascade -label "texture mapping mode" -menu $menu.textmap
    set mn [menu $menu.textmap -tearoff 0 -bg $color]
    $mn add command -label "decal" -command "evaluate \"$object -texture mapping decal\""
    $mn add command -label "modulate" -command "evaluate \"$object -texture mapping modulate\""
    $mn add command -label "blend" -command "evaluate \"$object -texture mapping blend\""
    
    $menu add cascade -label "volume rendering mode" -menu $menu.volren
    set mn [menu $menu.volren -tearoff 0 -bg $color]
    $mn add command -label "over (transparent volume)" -command "evaluate \"$object -volume blending over\""
    $mn add command -label "attenuate (X-Ray like)" -command "evaluate \"$object -volume blending attenuate\""
    $mn add command -label "MIP (Maximum Intensity Projection)" -command "evaluate \"$object -volume blending mappping MIP\""
    
    $menu add cascade -label "volume rendering slices" -menu $menu.volns
    set mn [menu $menu.volns -tearoff 0 -bg $color]
    $mn add command -label 20 -command "evaluate \"$object -volume nslices 20\""
    $mn add command -label 50 -command "evaluate \"$object -volume nslices 50\""
    $mn add command -label 100 -command "evaluate \"$object -volume nslices 100\""
    $mn add command -label 200 -command "evaluate \"$object -volume nslices 200\""
    $mn add command -label 400 -command "evaluate \"$object -volume nslices 400\""
    pack $parent.context.display -side left
}


imagedata::installMenu
Comments  
Arguments parent
camera
object
color
Used by  
Uses  
proc imagedata::installMenu { parent camera object color } {
    installObjectMenu $parent $camera $object $color
    installDisplayMenu $parent $camera $object $color
}


imagedata::installObjectMenu
Comments  
Arguments parent
camera
object
color
Used by  
Uses  
proc imagedata::installObjectMenu { parent camera object color } {
    menubutton $parent.context.file -text "Object" -menu $parent.context.file.mn -bg $color
    set menu [menu $parent.context.file.mn -bg $color]
    $menu add command -label destroy -command "evaluate \"$object -destroy\""
    pack $parent.context.file -side left
}


imagedata::isAnImageInformation
Comments  
Arguments name
Used by  
Uses  
proc imagedata::isAnImageInformation { name} {
    variable res
    set res 0
    switch $name {
    "Gradient" {
        set res 1
    }
    "Balloon" {
        set res 1
    }
    "Region" {
        set res 1
    }
    "GradientGradient" {
        set res 1
    }
    "Classify" {
        set res 1
    }
    "Intensity Profile" {
        set res 1
    }
    }
    return $res
}


imagedata::range2Dinstall
Comments  
Arguments parent
camera
object
color
Used by  
Uses imagedata::gradientGradientDialog
proc imagedata::range2Dinstall { parent camera object color } {
    variable forces
    variable nbImages
    variable displayMode
    variable displayImages

    installObjectMenu $parent $camera $object $color
    menubutton $parent.context.image -text "Image" -menu $parent.context.image.mn -bg $color
    set menu [menu $parent.context.image.mn -bg $color ]
    menu $parent.context.image.mn.view -bg $color -postcommand "set imagedata::displayMode \[$object -display\]; set imagedata::displayImages \[$object -images\]; set imagedata::nbImages \[llength \$imagedata::displayImages \]; $parent.context.image.mn.view delete 0 last; $parent.context.image.mn.view add radiobutton  -label  {none}  -variable imagedata::displayMode -command \"$object -display none \";for {set i 0 } {\$i < \$imagedata::nbImages } { incr i;incr i} {$parent.context.image.mn.view add radiobutton  -label  \[ lindex \$imagedata::displayImages \$i \]  -variable imagedata::displayMode -command \"$object -display \[ lindex \$imagedata::displayImages \$i \] \" }"
    $menu add cascade -label "View Images" -menu $menu.view
    $menu add command -label "Compute Gradient.." -command "imagedata::gradientDialog $object \[$object -images intensity\]"
    $menu add command -label "Compute Gradient Gradient.." -command "set gradient \[$object -images gradient\]; if {\[string compare \$gradient {none}\]} {imagedata::gradientGradientDialog $object \$gradient}"

    menubutton $parent.context.forces -text "External forces" -menu $parent.context.forces.mn -bg $color
    set menu [menu $parent.context.forces.mn -bg $color -postcommand "set imagedata::forces \[$object -force\]"]
    foreach f [$object -force list] {
    $menu add radiobutton -label $f -variable imagedata::forces  -command "evaluate \"$object -force \$imagedata::forces\"" -value $f
    }
    $menu add command -label "Set Parameters..." -command "imagedata::externalForce $object"
    pack $parent.context.image $parent.context.forces -side left    
}


imagedata::range2Duninstall
Comments  
Arguments parent
camera
object
Used by  
Uses  
proc imagedata::range2Duninstall { parent camera object } {
    # remove frame children
    set list [winfo children $parent.context]
    foreach w $list { destroy $w}
    pack $parent.context -fill x
    #remove popup
    destroy  $parent.popup
    #reset selection mode
    $camera -motionMode camera
    #unbind popup
    bind [$camera -widget] <Button-3> ""
}


imagedata::range3Dinstall
Comments  
Arguments parent
camera
object
color
Used by  
Uses  
proc imagedata::range3Dinstall { parent camera object color } {
    variable displayMode
    variable forces

    installObjectMenu $parent $camera $object $color
    installDisplayMenu $parent $camera $object $color

    menubutton $parent.context.image -text "Image" -menu $parent.context.image.mn -bg $color
    set menu [menu $parent.context.image.mn -bg $color -postcommand "set imagedata::displayMode \[$object -display\]"]
    $menu add radiobutton -label "none" -variable imagedata::displayMode  -command "evaluate \"$object -display none\""
    $menu add radiobutton -label "intensity" -variable imagedata::displayMode  -command "evaluate \"$object -display intensity\"; if !\[ string compare \[ \[ $object -images intensity \] -slicecams \] \"\" \] { evaluate \" view \[ $object -images intensity \] \" }" -value intensity
    $menu add radiobutton -label "gradient" -variable imagedata::displayMode  -command "if \[ string compare \[ $object -images gradient \] \"none\" \] { evaluate \"$object -display gradient\"; if !\[ string compare \[ \[ $object -images gradient \] -slicecams \] \"\" \] { evaluate \" view \[ $object -images gradient \] \" } }" -value gradient
    $menu add radiobutton -label "gradient direction" -variable imagedata::displayMode  -command "if \[ string compare \[ $object -images gradientdir \] \"none\" \] { evaluate \"$object -display gradientdir\"; if !\[ string compare \[ \[ $object -images gradientdir \] -slicecams \] \"\" \] { evaluate \" view \[ $object -images gradientdir \] \" } }" -value gradientdir
    $menu add radiobutton -label "edge" -variable imagedata::displayMode  -command  "if \[ string compare \[ $object -images edge \] \"none\" \] { evaluate \"$object -display edge\"; if !\[ string compare \[ \[ $object -images edge \] -slicecams \] \"\" \] { evaluate \" view \[ $object -images edge \] \" } }" -value edge
    $menu add radiobutton -label "gradient derivative" -variable imagedata::displayMode  -command   "if \[ string compare \[ $object -images gradient2 \] \"none\" \] { evaluate \"$object -display gradient2\"; if !\[ string compare \[ \[ $object -images gradient2 \] -slicecams \] \"\" \] { evaluate \" view \[ $object -images gradient2 \] \" } }"  -value gradient2
    $menu add radiobutton -label "classification" -variable imagedata::displayMode  -command  "if \[ string compare \[ $object -images classify \] \"none\" \] { evaluate \"$object -display classify\"; if !\[ string compare \[ \[ $object -images classify \] -slicecams \] \"\" \] { evaluate \" view \[ $object -images classify \] \" } }"  -value classify
    
    #    menubutton $parent.context.forces -text "External forces" -menu $parent.context.forces.mn -bg $color
    #    set menu [menu $parent.context.forces.mn -bg $color]
    #    foreach f [$object -force list] {
    #        $menu add radiobutton -label $f -variable imagedata::forces  -command "evaluate \"$object -force \$imagedata::forces\"" -value $f
    #    }
    #    $menu add command -label "set Parameters..." -command "imagedata::externalForce $object"

    #    pack $parent.context.image $parent.context.forces -side left    
    pack $parent.context.image -side left    
}


imagedata::range3Duninstall
Comments  
Arguments parent
camera
object
Used by  
Uses  
proc imagedata::range3Duninstall { parent camera object } {
    uninstallMenu $parent $camera $object
    destroy $parent.context.image $parent.context.forces
}


imagedata::setExternalForce2D
Comments  
Arguments range
force
Used by  
Uses  
proc imagedata::setExternalForce2D { range force } {
    switch $force {
    "gradient" {
        evaluate "$range -gradient threshold $imagedata::gradientThreshold"
    }
    }
    evaluate " $range -force \"$force\" "
}


imagedata::uninstallMenu
Comments  
Arguments parent
camera
object
Used by  
Uses  
proc imagedata::uninstallMenu { parent camera object } {
    destroy $parent.context.file $parent.context.display
}


imagedata::vRtransform
Comments proc imagedata::forceParameters { object color } {
variable fl
set name .forces$object
if ![winfo exists $name] {
toplevel $name -bg $color
wm title $name "$object external forces"
set mn [tk_optionMenu $name.fl imagedata::fl none]
$mn delete 1 end
$name.fl configure -bg $color
foreach f "[$object -force list]" {
$mn add radiobutton -variable imagedata::fl -label $f -background $color -command " foreach w \[winfo children $name.f\] { destroy \$w }
switch \$imagedata::fl {
none { }
gradient {
scale $name.f.th -label threshold -orient horizontal -from 0 -to 255 -bg $color
bind $name.f.th \"evaluate \\\"$object -gradient threshold \\\[$name.f.th get\\\]\\\"\"
scale $name.f.range -label range -orient horizontal -from 0 -to 30 -bg $color
bind $name.f.range \"evaluate \\\"$object -gradient range \\\[$name.f.range get\\\]\\\"\"
label $name.f.l -text \"orientation constraint\" -relief raised -bg $color
radiobutton $name.f.none -text none -variable imagedata::forces -bg $color -anchor w -value none -command \"evaluate \\\"$object -gradient orientation none\\\"\"
radiobutton $name.f.direct -text direct -variable imagedata::forces -bg $color -anchor w -value direct -command \"evaluate \\\"$object -gradient orientation direct\\\"\"
radiobutton $name.f.opposite -text opposite -variable imagedata::forces -bg $color -anchor w -value opposite -command \"evaluate \\\"$object -gradient orientation opposite\\\"\"
pack $name.f.th $name.f.range $name.f.l $name.f.none $name.f.direct $name.f.opposite -expand true -fill x
scan \"\[$object -gradient\]\" \"orientation %s range %f threshold %f\" imagedata::forces rng th
$name.f.th set \$th
$name.f.range set \$rng
}
}
"
}
frame $name.f -bg $color
button $name.dismiss -text "Dismiss" -command "destroy $name" -bg $color
pack $name.fl $name.f $name.dismiss -expand true -padx 10 -pady 5
}
}
Arguments x
y
Used by  
Uses  
proc imagedata::vRtransform { x y } {
    return [list [expr $x - 60] [expr 270 - y]]
}


imagedata::viewImageProfile
Comments  
Arguments object
vertex
bg
Used by  
Uses imagedata::displayIntensityProfile
proc imagedata::viewImageProfile { object vertex bg } {
    set root .imageProfile$vertex$object
    
    
    if {![winfo exists $root]} {
    set rim [ which rimg3D ]
    if ![ string match rimg3D* $rim ] {
        set rim [ which rimg2D ]
    }
    toplevel $root -bg $bg
    wm title $root "Image Profile"
    #option menu
    #        set mn [tk_optionMenu $root.item imagedata::imageType "intensity" "gradient"]
    #        $root.item configure -bg $bg
    #        pack $root.item -padx 10 -pady 10 -expand true -fill x
    #scale of the range
    frame $root.range -bg $bg
    pack $root.range -expand true -fill both
    scale $root.range.val  -orient horizontal -label "Profile Size" -from 1 -to 20 -length 200 -resolution 1 -bg $bg
    $root.range.val set 10
    pack $root.range.val -padx 10 -pady 5
    #buttons
    #
    frame $root.buttons -bg $bg
    button $root.buttons.applyDismiss -text "Apply & Dismiss" -command "set il1name \[ evaluate \"  new il \[$rim -images intensity \] \[$object $vertex -position \] \[$object $vertex -normal \] \[$root.range.val get \]  \" \] ;set il2name \[ evaluate \"  new il \[$rim -images gradient \] \[$object $vertex -position \] \[$object $vertex -normal \] \[$root.range.val get \]  \" \]; evaluate \" imagedata::displayIntensityProfile \$il1name \$il2name \";destroy $root" -bg $bg
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $bg  
    pack $root.buttons.applyDismiss  $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both
    }
}


imagedata::volumeRendering
Comments  
Arguments object
color
Used by  
Uses  
proc imagedata::volumeRendering { object {color #A0D0A0}} {
    global imagedata::oldX imagedata::oldY imagedata::vline imagedata::cline imagedata::ccolor imagedata::ccolorbox imagedata::red imagedata::green imagedata::blue imagedata::alpha imagedata::apply imagedata::modified imagedata::attenuation

    if ![winfo exists .volren] {
    set imagedata::apply "$object -volume transparency imagedata::red imagedata::green imagedata::blue imagedata::alpha"

    toplevel .volren -bg $color
    wm title .volren "volume renderer"
    set imagedata::modified 0

    canvas .volren.c -width 450 -height 410 -bg black
    .volren.c create text 195 285 -text "voxel intensity" -fill white
    .volren.c create text 60 280 -text "0" -fill white
    .volren.c create text 310 280 -text "256" -fill white
    .volren.c create text 30 150 -text "opacity" -fill white
    .volren.c create text 50 260 -text "0" -fill white
    .volren.c create text 50 25 -text "1" -fill white
    .volren.c create rectangle 59 270 316 14 -fill black -outline blue
    .volren.c create rectangle 59 299 316 331 -fill black -outline blue
    .volren.c create text 195 345 -text "displayed color" -fill white
    set x 60
    for { set i 0 } { $i < 256 } { incr i } {
        set imagedata::vline($i) [.volren.c create line $x 270 $x 142 -fill white]
        set imagedata::alpha($i) 0.5
        set imagedata::cline($i) [.volren.c create line $x 300 $x 330 -fill [format "#%02x%02x%02x" $i $i $i]]
        set val [expr $i / 255.0]
        set imagedata::red($i) $val
        set imagedata::green($i) $val
        set imagedata::blue($i) $val
        incr x
    }

    set imagedata::ccolor #FFFFFF
    set imagedata::ccolorbox [.volren.c create rectangle 60 360 90 390 -fill $imagedata::ccolor -outline blue]
    .volren.c create text 130 375 -text "current color" -fill white
    button .volren.c.reset -text "reset gray scale" -bg $color -command {
        set x 60
        for { set i 0 } { $i < 256 } { incr i } {
        set imagedata::cline($i) [.volren.c create line $x 300 $x 330 -fill [format "#%02x%02x%02x" $i $i $i]]
        set val [expr $i / 255.0]
        set imagedata::red($i) $val
        set imagedata::green($i) $val
        set imagedata::blue($i) $val
        incr x
        }
        eval "$imagedata::apply \[.volren.opac get\]"
    }
    .volren.c create window 316 360 -window .volren.c.reset -anchor ne
    
    set bcolor(0) #FF0000
    set bcolor(1) #00FF00
    set bcolor(2) #0000FF
    set bcolor(3) #FFFF00
    set bcolor(4) #FF00FF
    set bcolor(5) #00FFFF
    set bcolor(6) #900000
    set bcolor(7) #009000
    set bcolor(8) #000090
    set bcolor(9) #909000
    for { set i 0 } { $i < 10 } { incr i } {
        set gl [expr round($i * (255.0 / 9.0))]
        .volren.c create rectangle 350 [expr $i * 40 + 10] 380 [expr $i * 40 + 40] -fill [format "#%02x%02x%02x" $gl $gl $gl] -outline blue
        .volren.c create rectangle 400 [expr $i * 40 + 10] 430 [expr $i * 40 + 40] -fill $bcolor($i) -outline blue
    }

    scale .volren.opac -label "overall opacity" -orient horizontal -from 0.0 -to 1.0 -resolution 0.01 -bg $color
    bind .volren.opac <ButtonRelease-1> "$imagedata::apply \[.volren.opac get\]"
    bind .volren.opac <Enter> { focus .volren.opac }
    .volren.opac set [lindex [$object -texture] 4]

    scale .volren.nslices -label "number of slices" -orient horizontal -from 1 -to 500 -bg $color
    bind .volren.nslices <ButtonRelease-1> "evaluate \"$object -volume nslices \[ .volren.nslices get\] \" "
    bind .volren.nslices <Enter> { focus .volren.nslices }
    .volren.nslices set [lindex [$object -volume] 0]

    label .volren.lab -text "Attenuation function" -anchor center -bg $color
    frame .volren.f -bg $color
    radiobutton .volren.f.over -text "over" -variable imagedata::attenuation -bg $color -value over  -command "$object -volume blending over"
    radiobutton .volren.f.attenuate -text "attenuate" -variable imagedata::attenuation -bg $color -value attenuate  -command "$object -volume blending attenuate"
    radiobutton .volren.f.mip -text "MIP" -variable imagedata::attenuation -bg $color -value MIP  -command "$object -volume blending MIP"
    radiobutton .volren.f.under -text "under" -variable imagedata::attenuation -bg $color -value under -command "$object -volume blending under"
    set imagedata::attenuation [lindex [$object -volume] 1]
    pack .volren.f.over .volren.f.attenuate .volren.f.mip .volren.f.under -side left -fill x -expand true

    button .volren.bdismiss -text "Dismiss" -command { destroy .volren } -bg $color

    pack .volren.c .volren.opac .volren.nslices .volren.lab .volren.f -expand true -fill both -padx 5 -pady 5
    pack .volren.bdismiss -padx 5 -pady 10
    
    bind .volren.c <ButtonPress-1> {
        if { %x >= 40 && %x <= 335 && %y >= 0 && %y <= 289 } {
        set imagedata::modified 1
        if { %x < 60 } {
            set imagedata::oldX 60
        } elseif { %x > 315 } {
            set imagedata::oldX 315
        } else {
            set imagedata::oldX %x
        }
        if { %y < 15 } {
            set imagedata::oldY 15
        } elseif { %y > 269 } {
            set imagedata::oldY 269
        } else {
            set imagedata::oldY %y
        }
        bind .volren.c <Motion> {
            if { %%x < 60 } { set x 60 } elseif { %%x > 315 } { set x 315} else { set x %%x }
            if { %%y < 15 } { set y 15 } elseif { %%y > 270 } { set y 270} else { set y %%y }
            set a [expr $x - $imagedata::oldX]
            if { $a == 0 } {
            set a [expr $y - $imagedata::oldY]
            } else {
            set a [expr ($y - $imagedata::oldY) / ($x - $imagedata::oldX.0)]
            }
            if { $imagedata::oldX <= $x } {
            for { set i $imagedata::oldX } { $i <= $x } { incr i } {
                set j [expr round($imagedata::oldY + ($i - $imagedata::oldX) * $a)]
                set idx [expr $i - 60]
                .volren.c coords $imagedata::vline($idx) $i 270 $i $j
                set imagedata::alpha($idx) [expr (270.0 - $j) / 255.0]
            }
            } else {
            for { set i $imagedata::oldX } { $i >= $x} { incr i -1 } {
                set j [expr round($imagedata::oldY + ($i - $imagedata::oldX) * $a)]
                set idx [expr $i - 60]
                .volren.c coords $imagedata::vline($idx) $i 270 $i $j
                set imagedata::alpha($idx) [expr (270.0 - $j) / 255.0]
            }    
            }
            set imagedata::oldX $x
            set imagedata::oldY $y                
        }
        } elseif { %x >= 60 && %x <= 315 && %y >= 300 && %y <= 330 } {
        set imagedata::modified 1
        set imagedata::oldX %x
        bind .volren.c <Motion> {
            if { %%x < 60 } { set x 60 } elseif { %%x > 315 } { set x 315} else { set x %%x }
            scan $imagedata::ccolor {#%%%%2x%%%%2x%%%%2x} r g b
            set r [expr $r / 255.0]
            set g [expr $g / 255.0]
            set b [expr $b / 255.0]
            if { $imagedata::oldX <= $x } {
                for { set i $imagedata::oldX } { $i <= $x } { incr i } {
                set idx [expr $i - 60]
                .volren.c itemconfigure $imagedata::cline($idx) -fill $imagedata::ccolor
                set imagedata::red($idx) $r
                set imagedata::green($idx) $g
                set imagedata::blue($idx) $b
                }
            } else {
                for { set i $imagedata::oldX } { $i >= $x} { incr i -1 } {
                set idx [expr $i - 60]
                .volren.c itemconfigure $imagedata::cline($idx) -fill $imagedata::ccolor
                set imagedata::red($idx) $r
                set imagedata::green($idx) $g
                set imagedata::blue($idx) $b
                }
            }
            }
        } elseif { (%x >= 350 && %x <= 380) || (%x >= 400 && %x <= 430) } {
            set imagedata::ccolor [.volren.c itemcget [.volren.c find closest %x %y] -fill]
            .volren.c itemconfigure $imagedata::ccolorbox -fill $imagedata::ccolor
        }
        }
        bind .volren.c <ButtonRelease-1> {
        bind .volren.c <Motion> { }
        if $imagedata::modified {
            set imagedata::modified 0
            eval "$imagedata::apply \[.volren.opac get\]"
        }
        }
    }
    }

}