The 3D image processing tools

JASRI/SPring-8

Figure 0.1: zoom（§4.1）

Figure 0.2: triming（§4.2）iFigure 0.3: reslicing（§5）

ii

Figure 0.4: colorize the slice images（§5）

iii

Figure 0.5: volume rendering（§6.1）

iv

Figure 0.6: Volume rendering with polygon（§8.1）v

Figure 0.7: Three dimensional movie（§8.4）

vi

Figure 0.8: incorporating two polygon data and transition movie（§8.6）

Figure 0.9: binarizing and hole labeling（§9.1）

Figure 0.10: binarizing and noise subtraction（§9.2）

vii

Figure 0.11: binarizing and masking（§9.3）

Figure 0.12: transparent overlay（§9.4）

viii

Figure 0.13: ellipsoidal approximation （§10.2）ix

made by

Tsukasa Nakano (GSJ/AIST, JASRI/SPring-8),
Akira Tsuchiyama (Osaka Univ., JASRI/SPring-8),
Kentaro Uesugi (JASRI/SPring-8),
Masayuki Uesugi (Osaka Univ., JASRI/SPring-8)

andKunio Shinohara (Waseda Univ., JASRI/SPring-8)

xContents
1 Introduction
1.1 About “Slice” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 About this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3 Bibliographic Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.4 Important . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1
1
1
1
1

2 Getting Started
2.1 Download ﬁles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Compile and install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3 How to execute the sample script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.4 Other softwares . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2
2
2
3
3

3 Fundamentals
3.1 About the pixel value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 Coordinate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3 Sample data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4
4
5
5

4 Resizing and triming
4.1 Resizing (sliceBIC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 Triming (sliceIT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7775 Reslicing
5.1 Reslicing on x-z plane (slice NSX) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2 Reslicing on y-z plane(slice NSY) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.3 Make slice image by arbitrary surface (sliceNSG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.4 Make slice images by arbitrary surface(sliceIR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.5 Make gif movie of slice images(gif movie) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.6 Colorize of slice images(slice.CMA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

9
9
9
10
10
12
12

6 Volume rendering
6.1 Volume rendering(sliceIT, slice.NO, sliceBEVM.DS, bevm.WD, bevmGS, tiﬀmask) . . . . . . . . . . .

14
14

7 Binarizing
7.1 Binarizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.2 Preparation of binarizing: threshould . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.3 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.3.1 Example 1:Binarizing based on the pixel value only (slicePVR). . . . . . . . . . . . . . . . . . .
7.3.2 Example 2 : binarizing or value multiplexing based on the pixel value and structure of the object(sliceMCL, sliceMHL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

16
16
16
17
17

8 Volume rendering with Polygon
8.1 Make birdeye’s view image with polygon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.1 Direct rendering from slice data (si s bev, si m bev) . . . . . . . . . . . . . . . . . . . . . . . .
8.2 Make stl polygon data ﬁle(si stl B, si stl C：stl.tar.gz is required) . . . . . . . . . . . . . . . . . . . .
8.3 Make polygon bird eye’s view image from stl ﬁles( stl bev SS, stl bev C SS) . . . . . . . . . . . . . .
8.4 Make polygon movie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.4.1 Render from slice images (si s bev, si m bev) . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.4.2 Make movie from STL ﬁle (stl bev GIF SS, stl bev GIF C SS：stl.tar.gz が必要) . . . . . . . .
8.5 Angle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.6 Incorporating polygon data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

20
20
20
21
22
23
23
24
25
28

xi

17

9 Image processing of binarized image
9.1 Hole ﬁlling (sliceMHL, sliceDE, slicePVR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.1.1 sliceDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.1.2 sliceMHL, slicePVR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.2 Noise reduction（slicePVR） . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.3 Mask(slicePVM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.4 Transparent ovarlay(si cim) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

29
29
29
30
31
32
32

10 Quantitative analysis of binarized images
10.1 Evaluation of porosity (sliceMHL, slicePVR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.2 Ellipsoidal approximation of binarized object (sliceOF, of stl ih) . . . . . . . . . . . . . . . . . . . . .

34
34
34

Program reference

xii

1

Introduction

1.1

About “Slice”
Slice is a series of softwares for three dimensional image analysis of CTdata that works on command line.
Users can manipulate the image processing and quantitative analysis of three dimensional data by Sliceseries, and also create new images for presentations.
The advantage of Slice is image processing of three dimensional data composed of two dimensional images,
in at once. The image processings such as erosion and dilcation are operated on three dimesional structure,
not on the 2D images. And also, Slice is availabe on UNIX, Windows and Macintosh platform, and open
source with written by primitive C-language.
This book is a manual for the image processing of CT data by Slice series softwares.

1.2

About this book
The Slice manual is composed of two books. This book is the cookbook for the several image processing
using test samples with sample scripts. However, the cookbook does not covers whole programs of Sliceseries and its usage. If further infomation of Slice series programs is required, please refer Program reference
book, which is reference of programs included in Slice series.

1.3

Bibliographic Reference
Please use following reference sample for using images created by Slice on public.

Tsukasa Nakano, Akira Tsuchiyama, Kentaro Uesugi, Masayuki Uesugi and Kunio Shinohara（2006） Slice-Softwares for basic 3-D analysis-, Slice Home Page (web), http://www-bl20.spring8.or.jp/slice/，Japan
Synchrotron Radiation Research Institute (JASRI).

1.4

Important
Poor English in the text is made by MU. If you have any suggestions for the correction, please access
http://www-bl20.spring8.or.jp/slice/1

2

Getting Started

2.1

Download ﬁlesSlice works under unix environment. If you want to use on the Windows platform, you can use Cygwin
environment. The install ﬁles and documents for the installation is available at
http://www.cygwin.com/
Files of slice program is available at
http://www-bl20.spring8.or.jp/slice/
Body of slice(XXXXXX is date)
http://www-bl20.spring8.or.jp/slice/ﬁle/sliceXXXXXX.tar.gz (2.2MB)
Grain identiﬁcation
http://www-bl20.spring8.or.jp/slice/ﬁle/gi.tar (1MB)
3D image mosaic
http://www-bl20.spring8.or.jp/slice/ﬁle/rmsd.tar (1.6MB)
inclination correction
http://www-bl20.spring8.or.jp/slice/ﬁle/irac.tar (730MB)

STLﬁle operation（NIST）
http://www.gsj.jp/GDB/openﬁle/ﬁles/no0448/0448index.html (5MB)

sample data for training
http://www-bl20.spring8.or.jp/slice/ﬁle/mouse.lzh (35MB)
http://www-bl20.spring8.or.jp/slice/ﬁle/bubble.lzh (28MB)

The “body of slice” is requied for all image processing shown in this book, and stl.tar.gz is partially required
for advanced volume rendering processes.

2.2

Compile and install
Open the terminal window, and go to the directory where the downloaded ﬁles are extracted. Change
directory to the slice (or other) directory where created by extracting the archive, and type ”make install(enter)”.

Please note that executable ﬁles are installed on the bin directory in slice directory. If you want to installother directories, you must edit Makeﬁle in slice directory or move the executables manually.

After the installation, environment variable $PATH should be changed or added. In UNIX environment,
make following changes.bash proﬁle :2

PATH=$PATH:absolute path of program directory.cshrc :set path = ($path absolute path of program directory)

How to install the ﬁles is also introduced in “install manual” uploaded at same page of slice. Please refer
it for the installation.

2.3

How to execute the sample script
Slice series programs basically treat the data in directory unit. So the working directory should be upperdirectory of the data directory where 3D data ﬁles are exist. For example, if slice image ﬁles are saved at/data/BYTE/ directory, then working directory should be /data/.
Sample scripts in this cookbook can be run from command line, and also run from batch ﬁles. For example,
you can run slice.No by either typing
slice.No BYTE no -r (enter)or preparing text ﬁle named no.txt with written ”slice.No BYTE no -r” and typing
csh no.txt (enter)
The name of text ﬁle is arbitrary.

2.4

Other softwares
Following programs are available for displaying images saved by Slice programs or original slice images.
Windows・irfan view (Freeware: http://www8.plala.or.jp/kusutaku/iview/)
・ ImageJ (Freeware: http://rsb.info.nih.gov/ij/)

MacOSX・ Preview (OS)・ ImageJ (Freeware: http://rsb.info.nih.gov/ij/)
・ Graphic Converter (shareware: http://www.bridge1.com/ grahpicconverter.html)

UNIX・ ImageJ (Freeware: http://rsb.info.nih.gov/ij/)
・ Image magick
・ XV (http://www-bl20.spring8.or.jp/slice/ﬁle/xv-hipic.tar.gz 2.6MB)3

3

Fundamentals

3.1

About the pixel value
X-ray CT is a imaging method that use the distribution of transmitted X-ray ﬂux through the samples toobserve the internal structure. The contrast of the CT slice images shows the linear absorption coeﬃcient(LAC value, cm−1 ) of the local material converted into gray value of the picutre, called pixel value (PV).
The relation depends on the X-ray energy, experimental devices, and chemical composition of the matetrial.

Figure 3.1: relation of the gray scale of the image and LAC value
If the contrast of each slice image is diﬀerent, it indicates that the relation between the pixle value and
LAC value is not uniform, and should be corrected. Futher information for the correction and LAC value
is available in the text of beamline introduction.

4

3.2

Coordinate
The reconstructed 3D image data of the CT has a series of ﬁle name such as 0000.tif, 0001.tif. The originof the coordinate for the CT data is left-upper of the image that has smallest number (see Figure). The
Slice proograms and this manual are based on this coordinate, but some of the programs use diﬀerent
coodinate (see §8.5).

Figure 3.2: coordinate

3.3

Sample data
The sample data is available from the Web site of the Slice. mouse.lzh is a CT image data of a mouse thatcomposed of 000.TIF ∼ 327.TIF、500x500 pixel images.

Figure 3.3: Example of the sample data : 000.TIF
The bubble.lzh is the heated sphere of a rock which composed of 000.TIF ∼ 297.TIF、500x500 pixel images.

5The sample scripts in this cookbook use these examples. For the case of the analysis of the original data,
the ﬁlename and directory name should be changed to the names appropreate for the data.

6

4

Resizing and triming

Some program in Slice requires amount of available memory. So if the memory is not enough to the operation, suchprograms would appear errors and abort. Such cases can be avoided by reducing the image size. sliceXXXXX.tar.gz
should be installed for the image processings of this section.

4.1

Resizing (sliceBIC)

Figure 4.1: Reducing slice image
sample script
mkdir bic
sliceBIC BYTE - 2 2 2 bic

1st line: make save directory
2nd line: reduce slice image by sliceBIC. The 2 pixels for x, y ,z direction each are averaged and reduced
into 1 pixel, and stored in new directory, bic. The image size for each direction are reduced into 1/2
and total size of the data become 1/8 of original data.
saved images by sample script: bic/000.tif∼163.tif

4.2

Triming (sliceIT)
Trim oﬀ the unnecessary region of 3D data, and reduce the data size.
sample script
sliceOSP3 BYTE - 140 0
mkdir trim
sliceIT BYTE - 85 209 32 399 456 282 trim

1st line: detect cubic area which completely cotain the object by sliceOSP3 (material have pixel value>140)
2nd line: make save directory
3rd line: get cubic data by sliceIT and save to the trim directory7

Figure 4.2: Triming
supplement：
Text displayed by sliceOSP36545861 85 209 32 399 456 282
sliceIT requires two sets of (x,y,z) coordinate data of the cubic area that are the nearest vertex of the origin
and the diagonal vertex. sliceOSP3 can detect the cubic area which contain the object which composed ofpixels which have higher pixel value than the value given in the command line. See §7
saved images by sample script: trim/000.tif∼250.tif

8

5ReslicingMake the 3D image date with variable cutting surfaces that align X, Y, Z plane and arbitrary surfaces. In thissection, we use mouse.lzh sample data. sliceXXXXX.tar.gz should be installed for the image processings of this section.

5.1

Reslicing on x-z plane (slice NSX)

Sample script
mkdir nsx
slice NSX BYTE - 1 1 1 nsx
1st line: make save directory
2st line: reslice slice images by slice NSX

Figure 5.1:

Figure 5.2: Example 250.tif
saved images by sample script: nsx/000.tif∼499.tif

5.2

Reslicing on y-z plane(slice NSY)

Sample script
mkdir nsy
slice NSY BYTE - 1 1 1 nsy
1st line: make save directory
2st line: reslice slice images by slice NSY

Figure 5.3:
9

saved images by sample script: nsy/000.tif∼499.tif

5.3

Make slice image by arbitrary surface (sliceNSG)

Figure 5.4:
Sample script
echo 250 250 300 20 40 0 cs.tif | sliceNSG BYTE - 1 1 1 0

1st line: input the coordinates of the point (250, 250, 300) which included by the new slice surface, to thesliceNSG command using ”echo” command. The direction of eye (the direction perpendicular to the
new slice surface ) lon and lat = (20,40) and rotation in the slice image =0. The scale of all directionis 1, and if the new image data contains the outside area of the original data, the pixel value = 0 is
given to the pixel.

Figure 5.5: Example, cs.tif
saved images by sample script: cs.tif

5.4

Make slice images by arbitrary surface(sliceIR)10

Figure 5.6: make slice images by arbitrary surface
Sample script
mkdir ir
sliceIR BYTE - 60 -20 0 0 ir

1st line: make save directory
2nd line: make new slice images by sliceIR, with rotation of lon and lat = 60,-20 and rotation in the surfaceof new slice image is 0.
saved images by sample script: ir/000.tif∼752.tif
supplement:This program store the image data into memory. So if there are smaller memory available for the program,
program may be aborted with errors. Such case can be avoided by the size reduction of the image data
(see previous section) . This program took some amount of time.

Figure 5.7: Example

11

5.5

Make gif movie of slice images(gif movie)
Sample script
mkdir gifs
slice.T2G BYTE gifs
gif_movie gifs - 0 65536 slice.gif
1st line: make save directory
2nd line: convert slice images from tif to gif images by slice.T2G
3rd line: make gif movie ﬁle named as slice.gif which has no deray and inﬁnit loop number.

saved images by sample script: slice.gif

5.6

Colorize of slice images(slice.CMA)
Put colors to the slice images. In this subsection, bubble.lzh was used.

Figure 5.8: Example 200.tif
Sample script
mkdir cma
slice.CMA BYTE cluster.cm cma
1 行目: make save directory
2 行目: put colors to the slice images using color table ﬁle, cluster.cm, and save them to cma directory

saved images by sample script: cma/000.tif∼297.tif

12

supplement:
Samples of the color table for slice.CMA are saved in slice/slice/etc in the sliceXXXXXX.tar.gz archive.
These color table should be copied to the working directory, or, the directory should be speciﬁed in thecommand line.

13

6

Volume rendering

Perform volume rendering from the 3D image data. sliceXXXXX.tar.gz should be installed for the image processingsof this section.

6.1

Volume rendering(sliceIT, slice.NO, sliceBEVM.DS, bevm.WD, bevmGS, tiﬀmask)

Figure 6.1: Example
Sample script
mkdir itsliceIT BYTE - 0 0 0 499 250 326 it
mkdir noslice.No it no -r > no.shcsh no.shecho 30 20 40 10 mouse-bevm | sliceBEVM.DS no - 1 1 1
bevm.WD mouse-bevm.d.tif mouse-bevm.w.tif
bevmGS mouse-bevm.s.tif mouse-bevm.l.tif 1 25 0 mouse.ls.tif
tiffmask mouse-bevm.e.tif 1 mouse.ls.tif -0 mouse.lse.tif
tiffmask mouse-bevm.w.tif 1 mouse.lse.tif -255 mouse.tif
1st line: make save directory
2nd line: trim the slice images by sliceIT
3rd line: make save directory,“no”
4th line: make script ﬁle to sort ﬁles by slice.No
5th line: sort ﬁles to reverse order and save “no” directory
6th line: input the lon and lat of viewpoint = (30,20) and light source = (40 10), and ﬁlename “mousebevm” to sliceBEVM.DS using ”echo” command
7th line: get ﬂame of 3D ragion from depth image (mouse-bevm.d.tif)
8th line: render 3D image with shade from label image (mouse-bevm.l.tif) and shade image (mousebevm.s.tif)
9th line: put edge enhance eﬀect from edge image (mouse-bevm.e.tif)
10th line: put ﬂame (mouse-bevm.w.tif) on the 3D image

14

supplement：
Because the coordinate of the 3D data is diﬀerent from general coordinate, the bird eye’s view image
created by sliceBEVM.DS would be rotated. See §8.5. It is also important to sort the image into reverse
direction.
saved images by sample script:
it/000.tif∼599.tif
mouse-bevm.s.tif, mouse-bevm.e.tif, mouse-bevm.d.tif, mouse-bevm.l.tif , mouse-bevm.w.tif, mouse-bevm.ls.tif,
mouse-bevm.lse.tif, mouse.tif

15

7

Binarizing

7.1

Binarizing
The contrast of the CT image basically represent the diﬀerence of local material. By making threshould of
the pixel value (i.e.LAC value), we can divide the object of the interest and other object in the CT image
data. This procedure is called as ”binarizing”. In this procedure, generally the pixel value of the object is
set to 1 and that of other object is set to 0.
Table 7.1: diﬀerence of gray scale data and binarized datagray scale data

binarized data

Observation of whole internal structure of the sample

Observation of speciﬁc objects

Not suitable for quantitative analysis

suitable for quantitative analysis

Figure 7.1: Examples of bird eye’s view image of a mouse by gray scale data (left) and binarized data (right)
For the case of gray scale data, the gradation in the image is based on the LAC value. On the other hand,for the case of binarized data, the contrast of the image shows the shape of the surface of the object. Thus,
the structure of a speciﬁc material inside of the sample can be well observed by binarized data rather thangray scale data.

7.2

Preparation of binarizing: threshould
The pixel value of the CT image shows the LAC value and can be used for distinguishing the internalmaterial. In this subsection, a simple procedure of the binarizing is introduced. The thresould value isthe boundary of the pixel value between the body of interest and other portion of the CT data. How to
obtain the threshould value is diﬀerent according to the sample structure. If the object of the interest haslargely diﬀerent pixel value (i.e. LAC value) from the surrounding material, ﬁnding the threshould value
is easy. Figure 7.2 show the histgram of the sample data of mouse. In the histgram, a highest peak near
the 0 is a air (the portion without objects). The next peak near the 30 shows the body of the mouse. The
threshould value of the mouse body can be the valley between the peaks. In the general cases, ﬁnding thethreshould value is empirical and is complicated. In addition, several procedures, such as noise reduction
or selection of the objects, are required before the quantitative analysis.

16Figure 7.2: histgram of the sample CT data, mouse.lzh

7.3

ExampleHere we show a some representative method for the binarizing (or value multiplexing) of CT data. There
are several possible ways as well as the method introduced in this section. A number of programs in the
Slice series, such as sliceBEVM.DS, sliceDE, sliceED can binarize the images with their speciﬁc procedure.
Further information for those programs is available in the program reference.
7.3.1

Example 1:Binarizing based on the pixel value only (slicePVR).

Following sample script show the binarizing procedure by slicePVR program. By this script,
slicePVR saves CT data to pvr directory the images that pixel value 0-127 to be replaced to 0
and 128-255 to be replaced to 1.
Sample script
mkdir pvr
(echo 0 127 0 ; echo 128 255 1) | slicePVR BYTE - pvr > pvr.txt
1st line: make save directory
2nd line: binarize the CT data with -127 and 128- using slicePVRThis is the simplest way of the binarizing.

7.3.2 Example 2 : binarizing or value multiplexing based on the pixel value and structureof the object (sliceMCL, sliceMHL)
Next we show the cluster labeling and hole labeling which also can binarize or value multiplex
the CT data.

Cluster labeling17

In this method, the pixels which have a given value range adjacented are recongnized as a partof a cluster, and labeled the pixel value from 1 in decreasing order of the number of the pixels
belonging the cluster. The pixel value of the portion outside the object is set to 0. This procedure
is called cluster labeling, and is used for the indentifying the object inside the CT data.

3
0
1

2

Figure 7.3: A conceptual diagram for the cluster labeling : The numbers in the diagram show the pixel value.
Sample script
mkdir mcl
sliceMCL BYTE - 65 80 mcl > mcllog.txt
1st line: make save directory
2nd line: adopt the cluster labeling to the objects that composed of pixels with the value 65-80.
Hole labelingIn this method, the objects are recognized as same manner of the cluster labering. The diﬀerenceis that the labeling is adopted to the holes of the objects, not objects it self. In this case, allobjects has same pixel value, 1, and holes have pixel value decreasing order of the number of the
pixels belonging the hole from 2. The example image is created using bubble.lzh and color tablecm.cm in slice/slice/etc/ directory in the sliceXXXXXX.tar.gz.

0
1
3
2

4

1

Figure 7.4: A conceptual diagram for the hole labeling : The numbers in the diagram show the pixel value.

18

Sample script
mkdir mhl
sliceMHL BYTE - 100 255 mhl > mhllog.txt
mkdir pvr
echo 256 65535 0 | slicePVR mhl - pvr > /dev/null
mkdir cma
slice.CMA pvr cm.cm cma
1st line: make save directory
2nd line: adopt hole labeling to the holes in the objects that have pixels with the value=65-80
3rd line: make save directory
4th line: give 0 to the pixels smaller than 256 (holes with pixel value 256-65535) by slicePVR
5th line: make save directory
6th line: put colors to the images by slice.CMA introduced in §5.

Figure 7.5: Example 200.tif

198Volume rendering with Polygon

The volume rendering with polygon model is convenient for the analysis of binarized image data. In this section,
we show the polygon modeling of 3D data with stl format. sliceXXXXX.tar.gz and stl.tar.gz should be installed forthe image processings of this section.

8.1

Make birdeye’s view image with polygon
make bird eye’s view image with polygon. There are two ways: directory render from slice image data andcreate and use stl format ﬁle. If you want to make stl ﬁles, you should use stl.tar.gz.

Figure 8.1: Example

8.1.1

Direct rendering from slice data (si s bev, si m bev)

Gray scale image(si s bev)
Sample script
echo 260 190 | si_s_bev BYTE - 90-255 1 1 1 1 64 255 0 mouse.gif
1st line: make gray scale image of the object which have pixel value 90<PV<255 with lon andlat of viewpoint = (260, 190)

Color image (si m bev)
Sample script
si_m_bev BYTE - color.tbl 1 1 1 1 64 255 255 255 0 0 0 mouse_C.gif (Enter)
260 190 (Enter, Control-d）
1st line: make color image by si m bev using color table
2nd line: lon and lat of viewpoint = (260, 190). End of the input

20

Figure 8.2: Example
color.tbl：
prepare a text ﬁle with text editor with following lines
0-50
51-89 255 200 200
90-255 200 255 200
1st line: pixels with PV=0-50 are not body
2nd line: set color of pixels with PV=51-89 as RGB=(255 200 200)
3rd line: set color of pixels with PV=90-255 as RGB=(200 255 200)
saved images by sample script: mouse.gif, mouse C.gif

8.2

Make stl polygon data ﬁle(si stl B, si stl C：stl.tar.gz is required)
Make stl-format ﬁle using stl.tar.gz. The data is available other programs which can read the stl
ﬁle.
Make STL- ﬁle (si stl B)
Sample script
si_stl_B BYTE - 90 255 mouse.stl
500
500
328
388037 13130487659390 774456

375

327

1st line: make polygon dataﬁle of the object that composed of pixels with value 90<PV<255 bysi stl B
2nd line: pixel number of x, y, z direction of the data (output text)
3rd line: pixel number of the object and its region (output text)
4th line: pixel number of the object surface and number of triagles in the polygon surface (output
text)
21

make color stl ﬁle (si stl C)
Sample script
si_stl_C BYTE - mouse_C.stl (Enter)
500
500
328
0 50 (Enter)
51 89 255 200 200 (Enter)
90 255 200 255 200 (Enter、Control-d）
921156 121204881233694 1516171

407

327

1st line: make polygon dataﬁle mouse C.stl by si stl C
2nd line: pixels that have pixel value=0-50 are not body
3rd line: set color of pixels with value=51-89 as RGB=(255 200 200)
4th line: set color of pixels with value=90-255 as RGB=(200 255 200)
5th line: pixel number of the object and its region (output text)
6th line: pixel number of the object surface and number of triagles in the polygon surface (output
text)

supplement：
For the initial setting, the stl series program could not read 16 bit image ﬁles. In order to read
16 bit data ﬁle, re-compile the stl program (see stl program document in stl.tar.gz).
saved images by sample script: mouse.stl, mouse C.stl

8.3

Make polygon bird eye’s view image from stl ﬁles( stl bev SS, stl bev C SS)
make gray scale image( stl bev SS)
Sample script
echo 260 190 260_190.tif | stl_bev_SS mouse.stl 1 1 16 255 0
1st line: make bird eye’s view image using stl bev SS from mouse.stl from the viewpoint withlon and lat= (260,190)

make color image ( stl bev C SS)
Sample script
stl_bev_C_SS mouse_C.stl 1 1 16 255 255 255 0 0 0 0 0 0 (Enter)0 0 X0_0_C.tif (Enter)
260 190 260_190_C.tif (Enter、Control-d）
1st line: stl bev C SS from mouse C.stl
22

2nd line: make image from the viewpoint with lon and lat = (0, 0)
3rd line: make image from the viewpoint with lon and lat = (260, 190)

supplement：
For the initial setting, the stl series program could not read 16 bit image ﬁles. In order to read
16 bit data ﬁle, re-compile the stl program (see stl program document in stl.tar.gz).
Because the coordinate of the 3D data is diﬀerent from general coordinate, the bird eye’s view
image would be rotated. See §8.5.

saved images by sample script: 260 190.tif, X0 0 C.tif, 260 190 C.tif

8.4

Make polygon movie

Figure 8.3: Example

8.4.1

Render from slice images (si s bev, si m bev)

Make gray scale movie (si s bev)
Sample script
si_s_bev BYTE - 100-255 1 1 1 1 64 255 0 mouse.gif(Enter)180 180 0 10 2(Enter)180 200 10 0 8(Enter, Control-d）

23

1st line: make polygon image of the object that composed of pixels twith the value 100<PV<255
by si s bev
2nd line: make movie from the viewpoint with lon and lat = (180, 180) and 2 times moves by(0, 10) degree
3rd line: add movie from the viewpoint with lon and lat = (180, 200) and 8 times moves by (10,0) degree

Make color movie ﬁle(si m bev)
Sample script
si_m_bev BYTE - color.tbl 1 1 1 1 64 255 255 255 0 0 0 mouse_C.gif (Enter)180 180 0 10 2(Enter)180 200 10 0 8(Enter, Control-d）
1st line: make color polygon movie by si m bev
2nd line: make movie from the viewpoint with lon and lat = (180, 180) and 2 times moves by(0, 10) degree
3rd line: add movie from the viewpoint with lon and lat = (180, 200) and 8 times moves by (10,0) degree

color.tbl：
prepare a text ﬁle with text editor with following lines
0-50
51-89 255 200 200
90-255 200 255 200

1st line: pixels that have pixel value=0-50 are not body
2nd line: set color of pixels that have pixel value=51-89 as RGB=(255 200 200)
3rd line: set color of pixels that have pixel value=90-255 as RGB=(200 255 200)
saved images by sample script: mouse.gif, mouse C.gif

8.4.2

Make movie from STL file (stl bev GIF SS, stl bev GIF C SS：stl.tar.gz が必要)

Make gray scale movie (stl bev GIF SS)
Sample script( echo 180 180 0 10 2 ; echo 180 200 10 0 8 ) | stl_bev_GIF_SS mouse.stl 1 1 16 255
0 mouse_move.gif
1st line: make polygon image by stl bev GIF C SS from mouse.stl from the viewpoint with lon
and lat = (180, 180) and 2 times moves by (0, 10) degree, next 8 times moves by (10, 0)
degree from (180, 200).

24

Make color movie (stl bev GIF C SS)
Sample script
stl_bev_GIF_C_SS mouse_C.stl 1 1 16 255 255 255 0 0 0 0 0 0
180 180 0 10 2(Enter)180 200 10 0 8(Enter, Control-d）mouse_move_C.gif(Enter)1st line: make polygon image by stl bev GIF C SS from mouse C.stl
2nd line: make movie from the viewpoint with lon and lat = (180, 180) and 2 times moves by(0, 10) degree
3rd line: add movie from the viewpoint with lon and lat = (180, 200) and 8 times moves by (10,0) degree

supplement：
Because the coordinate of the 3D data is diﬀerent from general coordinate, the bird eye’s view
image would be rotated. See §8.5.

saved images by sample script: mouse move.gif, mouse move C.gif

8.5

Angle

Figure 8.4: coordinate
When a polygon data (Fig. 8.4) is rotated a certain degree (lon, lat) , following results are obtained.
25

26

27

8.6

Incorporating polygon data
Incorporate two polygon images with a certain surface, and make a transition movie

sample script
echo 500 220 220 -50 0 0 10 | si_x_bev BYTE - color.tbl
BYTE - color2.tbl 1 64 255 255 255 0 0 0 move.gif(do not break)

1st line: Make bird eye’s view image of polygon by si x bev from data in BYTE directory. This program
makes two polygon data from color.tbl and color2.tbl and incorpolate them at y-z plane which contains
x=500 point, and output bird eye’s view image from the viewpoint with lon and lat =(220, 220) .
The y-z plane is moved from 500 by -50 pixels10 times, and the images are added to transition movie
in gif format.
color tableprepare text ﬁles with text editor with following lines
color.tbl：
0-19
20-255 255
color2.tbl：
0-89
90-255 255

supplement：
In this example, we use same 3D data in BYTE, but diﬀerent data can be used in the script. It also
possible to make color polygon data by si x bev and incopolate them (by editing color table ﬁle). If thesecond 3D data （BYTE - color2.tbl）is (- - /dev/null), cross section image of the bird eye’s view image
could be obtained.

saved images by sample script: move.gif

28

9Image processing of binarized image

The quantitative analysis of 3D data is possible by using binarized image. In this section, we show the examplesof image processings which would be required before the quantitative analysis.
In this section, we also use another sample data (bubble.lzh).

9.1

Hole ﬁlling (sliceMHL, sliceDE, slicePVR)

The image processing to ﬁll the holes in object is sometime required in order to estimate the volume of a object inCT data.
9.1.1

sliceDE

Figure 9.1: Example 152.tif
Sample script
mkdir desliceDE BYTE - 140 255 3 de1st line: make save directory
2nd line: adopt dilation and erosion in three pixels to the objects that have pixel value=140-255 by sliceDE,and save images in desupplement：
In order to ﬁll the holes, dilation (increase the pixels of object to outside) and erosion (reduce the pixels of
the object to inside) eﬀect is adopted on the 3D data. By this processing, holes ad gaps which have radius
smaller than 6 pixels are ﬁlled. Through this process, the pixel value of the object is set to 1.
By using sliceED, the small object can be erased.
saved images by sample script:
de/000.tif∼297.tif

29

Figure 9.2: Example 152.TIF
9.1.2

sliceMHL, slicePVR

Sample script
mkdir mhl
sliceMHL BYTE - 140 255 mhl
mkdir mhlpvr
echo 2 65535 1 | slicePVR mhl - mhlpvr
1st line: make save directory
2nd line: adopt the hole labeling to the holes in the object that are composed of pixels with the value=140255 by sliceMHL
3rd line: make save directory
4th line: replace pixel value 2-65535 to 1 by slicePVR
supplement：
sliceMHL labels values larger than 1 to the pixels that are in the hole of the object. So by replacing the
pixel values 2 to 65535 to 1 (the pixel value of the object) after the sliceMHL by slicePVR, we can ﬁll
the hole in the objects. However, if a hole connects to the outside of the object, the hole could not be
identiﬁed. In this processing, the deformation of the hole and object does not appears in the images, whichappears for the case of sliceDE or ED. Through the process, the pixel value of the object is replaced to 1.
saved images by sample script:
mhl/000.tif∼297.tif
mhlpvr/000.tif∼297.tif

30

Figure 9.3: Example

9.2

Noise reduction（slicePVR）
Sample script
mkdir mcl
sliceMCL BYTE - 90 255 mcl > /dev/null
mkdir mclpvr(echo 22 22 0 ; echo 44 65535 0 ; echo 2 43 1) | slicePVR mcl - mclpvr > /dev/nullecho 260 190 | si_s_bev BYTE - 1 1 1 1 1 64 255 0 mouse.gif
1st line: make save directory
2st line: adopt claster labeling to the object that are composed of pixels with the value=90-255 by sliceMCL
3st line: make save directory
4st line: replace pixel value 22 and 44-65535 to 0, and other pixels to 1 by slicePVR
5st line: make bird eye’s view image with lon and lat of viewpoint = (30,20) by si s bev
supplement：
sliceMCL labels values larger than 0 to the pixels that composed of the objects. The largest cluster has
pixel value = 1 and small objects have pixel value = 65535. Small objects generally appear as noise in the
3D image. In this case, by replacing 22 (which is large noise near the corner) and 44-65535 to 0, we canerase the noises in the data.
saved images by sample script:
mcl/000.tif∼327.tif
mclpvr/000.tif∼327.tif
mouse.gif

31

Figure 9.4: Example 152.tif

9.3

Mask(slicePVM)
Sample script
mkdir mhl
sliceMHL BYTE - 140 255 mhl > /dev/null
mkdir pvr
echo 2 65535 0 | slicePVR mhl - pvr > /dev/null
mkdir pvm
slicePVM pvr - 0 BYTE pvm
1st line: make save directory
2st line: adopt hole labeling to the holes in the object that have PV=140-255 by sliceMHL
3st line: make save directory
4st line: replace pixel value 2-65535 to 1 by slicePVR
5st line: make save directory
6st line: mask images in the BYTE directory using binarized slice images in the pvr directory, and save inthe pvm directory
supplement：
In the sample script, the area of the object appears in the binarized image data (pvr) are selected fromthe original data (BYTE) and saved in the new directory (mhlpvr). Then the noise appears outside of theobject (or inside the holes) in the original data can be erased in the new image data.
saved images by sample script:
pvm/000.tif∼297.tif
pvr/000.tif∼297.tif
mhl/000.tif∼297.tif

9.4

Transparent ovarlay(si cim)
The result of hole ﬁlling processing (§9.1) is conﬁrmed by transparent overlaying on the original data.

32

Figure 9.5: Exsample
Sample script
mkdir cim
si_cim BYTE - mhlpvr - 0.1 cim
1st line: make save directory
2st line: using si cim, image data in the mhlpvr directory is overlayed on the original data in the BYTE
directory for factor 0.1, and the new image data is saved in the cim directory
supplement：
Right hand side of the sample image is hole ﬁlled image and left hand side of the sample image is the image
overlayed on the original data in the BYTE directory. The holes did not ﬁlled by sliceMHL show whiteembedding lines around the hole because of original data. The si cim can read and save color images.

saved images by sample script:
cim/000.tif∼297.tif

33

10

Quantitative analysis of binarized images

In this section, the examples of quantitative analysis of the CT data are shown in some aspects. We use bubble.lzh
for the sample data in the sample script.

10.1

Evaluation of porosity (sliceMHL, slicePVR)
Sample script
sliceMHL BYTE - 140 255 mhl > /dev/null(echo 2 65535 255) | slicePVR mhl - pvr > /dev/nullecho ’’ | slicePVR pvr - > pvr.txt
1st line: adopt hole labeling to the objects that are composed of pixels with value=140-255 by sliceMHL
2nd line: replace pixel value 2-65535 to 1 by slicePVR
3rd line: make histogram data by slicePVR and save it as pvr.txt
supplement：
pvr.txt
0 0 67954139
1 1 4515889
255 255 2029972

The object has pixel value=1 and the holes have pixel value=255. The whole volume of the object is(number of pixel value=1) + (number of pixel value=255),and porosity is (whole volume)/(number ofpixel value=255). If a number of holes connected to the outside of the objects, their volume could not be
included. In such case, another processing before making histogram, such as sliceDE, may be requried.

saved data by sample script: pvr.txt

10.2

Ellipsoidal approximation of binarized object (sliceOF, of stl ih)
Sample script
mkdir mhl
sliceMHL BYTE - 140 255 mhl > /dev/null
mkdir pvr
(echo 3 65535 0 ; echo 1 1 0) | slicePVR mhl - bb_pvr > /dev/null
sliceOF bb_pvr - 2 2 2 > of.txt
1st line: make save directory
2nd line: adopt hole labeling to the holes in the object that have pixel value=140-255 by sliceMHL
3rd line: make save directory
4th line: replace pixel value 3-65535 and 1 to 0 by slicePVR
5th line: adopt ellipsoidal approximation and save the date in of.txt. The scale of each axis is 2.

34

supplement：of.txt
0 74129789 249.731 249.219 148.586 499.462 498.437 297.172 35.144 0.00616071 90.0343 385.557 646.646
647.054 675747719.388186
2 370211 203.27 305.823 131.288 406.539 611.646 262.576 -100.378 33.7734 44.0446 70.8966 75.1825 167.559
3741083.083801
1st line in the of.txt is the information of background and following lines show the information of theobjects. The data format is number of cluster, number of pixel, x,y,z coordinate of the gravity center ofthe object (pixel), x,y,z coordinate of the gravity center of the object (scaled), angle of each axis of theapproximated ellipsoid λ,φ,θ (degree), the length of each axis (scaled), the volume of the approximatedellipsoid.
The data of the approximated ellipsoids obtained by sliceOF can be converted into the stl format polygon
data, and bird eye’s view.

Figure 10.1: ellipsoidal approximation image of a bubble
Sample script
tail -n+2 of.txt | cut -f3-5,9-14 | of_stl_ih 7 of.stl
echo 20 60 20_60.tif | stl_bev_SS of.stl 1 1 16 255 0
1st line: make stl ﬁle named of.stl from the of.txt using cut and tail command in UNIX by of stl ih
2nd line: make bird eye’s view image from the of.stl ﬁle by stl bev SS

Figure 10.2: shape of the original bubble (Try to reproduce this image as the practice !)saved images by sample script: of.txt, of.stl, 20-60.tif

35April 18, 2008, SPring-8