#
# HELP: SYNOPSIS:
# HELP:     colotux/user/FastPolysToshiba
# HELP:
# HELP: DESCRIPTION:
# HELP:     This is a special version of colotux/user/FastPolys intended
# HELP:     for tomographs that deliver signed pixeldata in HU, like some
# HELP:     Toshiba models do.
# HELP:     ATTENTION: The script expects that colotux/user/FixToshiba
# HELP:     has been called before. This is required for visual inspection
# HELP:     of incoming image quality anyway.
# HELP:     The performed function is like colotux/user/FastPolys:
# HELP:     Prepare an acquired volume for display, including denoising
# HELP:     and autodetection of polyps.
# HELP:
# HELP: SEE ALSO:
# HELP:     colotux/user/FastPolys, colotux/user/FixToshiba
#

! generic/menu/confirm_longrun
IF ${!$result} QUIT

VIEW_SET Main
VOL_ALLOC_DEPTH
VOL_ALLOC_CLASS
remark 0-255 0
mark ${$root.func.eccet.fromHU(-400)} 65535 0 4
killside 0 4 2 3 10
killside 1 4 2 3 10
kill_top z0 0,3 2
markgc 65535 2
remark 2,4 0
mark 0 ${$root.func.eccet.fromHU(-400)} 0 3
MARKCC_SIZE 1000 3 0 2
MARKCC_DILATE 15 2 3
markgc 65535 0
COPY_GREYTOBACK
nlgs 2 1 10000
nlgs 0 1 10000
nlgs 1 1 10000
nlgs 2 4 64
nlgs 0 4 48
nlgs 1 4 24
MIX_BACKTOGREY 0.5
nlgs 0 8 32
nlgs 1 8 24
nlgs 2 8 16
ERASE_BACK
mark 0 ${$root.func.eccet.fromHU(-750)} 0 3
MARKCC_SIZE 1000 3 0 2
mark 65535 65535 0 4
MARKCC_SIZE 10 0 2 3
remark 3,4 0
kill_top ze 2 3
MARKCC_DILATE 1 2,3 32,36
norm2 32,36 2,3 2 3
markpoly -20 60 32 244
markpoly -20 60 36 244
mindist ${$root.func.eccet.fromHU(-650)} 2 244 242
disp 0
#
# O.K. - we are ready - now convert to colotux format
#
# remove the in/out colors and expand the markers
remark 1-3 0
MARKCC_FLOOD 2 242,244 0
MARKCC_FLOOD 2 32,36 0

# Save classes to depthfield
CLASSTODEPTH

# Re-load original grey values.
set_set 2 ,
merge ${$root.vol[current].path}
! generic/convert/greyshift 2048

# Filter for better viewing.
nlgs 0 1 10000
nlgs 1 1 10000
nlgs 2 1 10000

# Push the greyscale stuff into the classes
GREYTOCLASS 0 65535 0 0
GREYTOCLASS 0 ${$root.func.eccet.fromHU(-1000)} 0 0
GREYTOCLASS ${$root.func.eccet.fromHU(-1000)} ${$root.func.eccet.fromHU(-500)} 0 255
GREYTOCLASS ${$root.func.eccet.fromHU(-500)} 65535 255 255

# Originalgrauwertdaten wieder einladen
set_set 2 ,
merge ${$root.vol[current].path}
! generic/convert/greyshift 2048

# Gesicherte Klassen in die Grauwerte einblenden
MARKBITGD 0xf000 0x6000 36
MARKBITGD 0xf000 0x7000 32
MARKBITGD 0xf000 0xA000 242
MARKBITGD 0xf000 0xC000 244

VIEW_SET Main
GWINDOW 120 130
RENDERLUT_SIMPLE 125
CLASS_MAKEDIST 1
LAYER 0-255 0
]WEIRD])
