using namespace s t d ; #define MAX LOADSTRING 100 // G l o b a l V a r i a b l e s : HINSTANCE h I n s t ; WCHAR s z T i t l e [MAX LOADSTRING ] ; WCHAR szWindowClass [MAX LOADSTRING ] ; const const const const const const const const const
unsigned unsigned unsigned unsigned double double double unsigned unsigned
int int int int
np nf nx ny a d c1 int npnf int nxny
= = = = = = = = =
359; 270; 250; 250; 700; 800; ( 2 . 0 ∗ M PI ) / n f ; np ∗ n f ; nx ∗ ny ;
struct INF { unsigned int ∗ i n d ; unsigned int ∗ Ind ; double ∗ s e g ; double ∗ Seg ; 7
Fig. 6: result of filtered back-projection when using 360 projection views instead of 270 double SumOfSegs ; unsigned int count ; unsigned int Count ; }; HDC HGDIOBJ BITMAPINFOHEADER BITMAPINFO HBITMAP BITMAP
hdcMem ; hbmOld ; bmih ; dbmi ; hbmp = NULL; bmp ;
double double double double
= = = =
duration1 duration2 min1 max1
0.0; 0.0; 0.0; 0.0;
unsigned char ∗ p i x e l s = NULL; void ∗ bits = NULL; unsigned int
Status = 0;
// Forward d e c l a r a t i o n s o f f u n c t i o n s i n c l u d e d i n t h i s code module : ATOM M y R e g i s t e r C l a s s (HINSTANCE h I n s t a n c e ) ; BOOL I n i t I n s t a n c e (HINSTANCE, int ) ; LRESULT CALLBACK WndProc (HWND, UINT , WPARAM, LPARAM) ; INT PTR CALLBACK About (HWND, UINT , WPARAM, LPARAM) ; int APIENTRY wWinMain ( I n HINSTANCE I n o p t HINSTANCE In LPWSTR In int { UNREFERENCED PARAMETER( h P r e v I n s t a n c e ) ;
hInstance , hPrevInstance , lpCmdLine , nCmdShow)
8
Fig. 7: result of the direct integration method when using 360 projection views instead of 270 UNREFERENCED PARAMETER( lpCmdLine ) ; // I n i t i a l i z e g l o b a l s t r i n g s LoadStringW ( h I n s t a n c e , IDS APP TITLE , s z T i t l e , MAX LOADSTRING) ; LoadStringW ( h I n s t a n c e , IDC IM1VS2015ENTERPRISEWITHUPDATESV1, szWindowClass , MAX LOADSTRING) ; MyRegisterClass ( hInstance ) ; // Perform a p p l i c a t i o n i n i t i a l i z a t i o n : i f ( ! I n i t I n s t a n c e ( h I n s t a n c e , nCmdShow ) ) { return FALSE ; } HACCEL hAccelTable = L o a d A c c e l e r a t o r s ( h I n s t a n c e , MAKEINTRESOURCE(IDC IM1VS2015ENTERPRISEWITHUPDATESV1 ) ) ; MSG msg ; // Main message l o o p : while ( GetMessage(&msg , NULL, 0 , 0 ) ) { i f ( ! T r a n s l a t e A c c e l e r a t o r ( msg . hwnd , hAccelTable , &msg ) ) { T r a n s l a t e M e s s a g e (&msg ) ; DispatchMessage (&msg ) ; } } return ( int ) msg . wParam ; }
// 9
// FUNCTION: M y R e g i s t e r C l a s s ( ) // // PURPOSE: R e g i s t e r s t h e window c l a s s . // ATOM M y R e g i s t e r C l a s s (HINSTANCE h I n s t a n c e ) { WNDCLASSEXW wcex ; wcex . c b S i z e = s i z e o f (WNDCLASSEX) ; wcex . s t y l e = CS HREDRAW | CS VREDRAW; wcex . lpfnWndProc = WndProc ; wcex . c b C l s E x t r a = 0 ; wcex . cbWndExtra = 0 ; wcex . h I n s t a n c e = h I n s t a n c e ; wcex . hIcon = LoadIcon ( h I n s t a n c e , MAKEINTRESOURCE(IDI IM1VS2015ENTERPRISEWITHUPDATESV1 ) ) ; wcex . hCursor = LoadCursor (NULL, IDC ARROW) ; wcex . hbrBackground = (HBRUSH) (COLOR WINDOW + 1 ) ; wcex . lpszMenuName = MAKEINTRESOURCEW(IDC IM1VS2015ENTERPRISEWITHUPDATESV1 ) ; wcex . lpszClassName = szWindowClass ; wcex . hIconSm = LoadIcon ( wcex . h I n s t a n c e , MAKEINTRESOURCE( IDI SMALL ) ) ; return RegisterClassExW(&wcex ) ; } // // FUNCTION: I n i t I n s t a n c e (HINSTANCE, i n t ) // // PURPOSE: S av e s i n s t a n c e h a n d l e and c r e a t e s main window // // COMMENTS: // // In t h i s f u n c t i o n , we s a v e t h e i n s t a n c e h a n d l e i n a g l o b a l v a r i a b l e and // c r e a t e and d i s p l a y t h e main program window . // BOOL I n i t I n s t a n c e (HINSTANCE h I n s t a n c e , int nCmdShow) { h I n s t = h I n s t a n c e ; // S t o r e i n s t a n c e h a n d l e i n our g l o b a l v a r i a b l e HWND hWnd = CreateWindowW ( szWindowClass , s z T i t l e , WS OVERLAPPEDWINDOW, CW USEDEFAULT, 0 , CW USEDEFAULT, 0 , NULL, NULL, h I n s t a n c e , NULL ) ; i f ( ! hWnd) { return FALSE ; } ShowWindow (hWnd, SW SHOWMAXIMIZED) ; UpdateWindow (hWnd ) ; return TRUE; } // // // // //
FUNCTION: WndProc (HWND, UINT, WPARAM, LPARAM) PURPOSE:
P r o c e s s e s messages f o r t h e main window .
10
// WMCOMMAND − p r o c e s s t h e a p p l i c a t i o n menu − P a i n t t h e main window // WM PAINT // WM DESTROY − p o s t a q u i t message and r e t u r n // // LRESULT CALLBACK WndProc (HWND hWnd, UINT message , WPARAM wParam , LPARAM lParam ) { switch ( message ) { case WMCOMMAND: { int wmId = LOWORD( wParam ) ; // Parse t h e menu s e l e c t i o n s : switch (wmId) { case ID X ITERATIVEMETHOD1 : { S e t C u r s o r ( LoadCursor (NULL, IDC WAIT ) ) ; I n v a l i d a t e R e c t (hWnd, NULL, TRUE) ; Status = 0; MSG msg ; msg . hwnd = hWnd ; msg . message = WM PAINT; DispatchMessage (&msg ) ; clock t start1 ; clock t start2 ; clock t finish ; start1 = clock ( ) ; unsigned int i ; unsigned int j ; unsigned int k ; INF ∗Z1 = NULL; double ∗Mu = NULL; double ∗RI = NULL; double ∗O1 = NULL;
Z1 Mu RI O1
= = = =
( INF∗ ) m a l l o c ( npnf ( double ∗ ) m a l l o c ( nxny ( double ∗ ) m a l l o c ( nxny ( double ∗ ) m a l l o c ( nxny
∗ ∗ ∗ ∗
s i z e o f ( INF )); s i z e o f ( double ) ) ; s i z e o f ( double ) ) ; s i z e o f ( double ) ) ;
FILE ∗ f 1 ; double d1 ; i f ( f o p e n s (& f1 , ”ph−250x250 . t x t ” , ” r ” ) == 0 ) { f o r ( i = 0 ; i < nxny ; i ++) { f s c a n f s ( f1 , ”%l f ” , &d1 ) ; Mu[ i ] = d1 ; } f c l o s e ( f1 ) ; } else MessageBox (NULL, (LPCWSTR)L” Problem a t f o p e n s 1 ! ” , (LPCWSTR)L” E r r o r ! ” , MB OK) ;
11
i f ( f o p e n s (& f1 , ”ph−250x250 −(2) −270. t x t ” , ” r ” ) == 0 ) { f o r ( i = 0 ; i < nxny ; i ++) { f s c a n f s ( f1 , ”%l f ” , &d1 ) ; RI [ i ] = ( d1 < 0 . 0 ? 0 . 0 : d1 ) ; } f c l o s e ( f1 ) ; } else MessageBox (NULL, (LPCWSTR)L” Problem a t f o p e n s 2 ! ” , (LPCWSTR)L” E r r o r ! ” , MB OK) ;
f o r ( i = 0 ; i < nxny ; i ++) { /∗ RI [ i ] = 0 . 0 ; ∗/ O1 [ i ] = 0 . 0 ; }
double ∗ dc = NULL; dc = ( double ∗ ) m a l l o c ( np ∗ s i z e o f ( double ) ) ; dc [ 0 ] = −(((( double ) np ) − 1 . 0 ) / 2 . 0 ) ∗ ( ( a + d ) / d ) ; f o r ( i = 1 ; i < np ; i ++) dc [ i ] = dc [ i − 1 ] + ( a + d ) / d ; double double double double
x1 ; x2 ; y1 ; y2 ;
double ∗ x l = NULL; double ∗ y l = NULL; x l = ( double ∗ ) m a l l o c ( ( ny + 1 ) ∗ s i z e o f ( double ) ) ; y l = ( double ∗ ) m a l l o c ( ( nx + 1 ) ∗ s i z e o f ( double ) ) ; double xLoLimit ; double xUpLimit ; double yLoLimit ; double yUpLimit ; xLoLimit = −(((( double ) ny ) xUpLimit = ( ( ( ( double ) ny ) yLoLimit = −(((( double ) nx ) yUpLimit = ( ( ( ( double ) nx ) x l [ 0 ] = xLoLimit ; f o r ( i = 1 ; i < ( ny xl [ i ] = xl [ i − 1] y l [ 0 ] = yLoLimit ; f o r ( i = 1 ; i < ( nx yl [ i ] = yl [ i − 1]
− − − −
1.0) 1.0) 1.0) 1.0)
/ / / /
2.0 2.0 2.0 2.0
+ 1 ) ; i ++) + 1.0; + 1 ) ; i ++) + 1.0;
12
+ + + +
0.5); 0.5); 0.5); 0.5);
double double double double
xhrz ; yhrz ; xvrt ; yvrt ;
double ∗S1 = NULL; S1 = ( double ∗ ) m a l l o c ( npnf ∗ s i z e o f ( double ) ) ; f o r ( i = 0 ; i < npnf ; i ++) S1 [ i ] = 0 . 0 ; double double double double double
f , m, b ; Sinf ; Sinfa ; Cosf ; Cosfa ;
double xcm ; double ycm ; unsigned int Lin ; unsigned int Col ; double seg ; double ∗xV ; double ∗yV ; xV = ( double ∗ ) m a l l o c ( ( ny + 1 ) ∗ ( nx + 1 ) ∗ s i z e o f ( double ) ) ; yV = ( double ∗ ) m a l l o c ( ( ny + 1 ) ∗ ( nx + 1 ) ∗ s i z e o f ( double ) ) ; v e c t o r V; unsigned int nEl ; unsigned unsigned unsigned unsigned double double
int int int int
unsigned unsigned unsigned unsigned double unsigned unsigned
int int int int
nyPlusOne nxPlusOne nyMinusOne nxMinusOne Var1 Var2
= = = = = =
ny + 1 ; nx + 1 ; ny − 1 ; nx − 1 ; ( ( ( double ) ny ) − 1 . 0 ) / 2 . 0 + 0 . 5 ; ( ( ( double ) nx ) − 1 . 0 ) / 2 . 0 + 0 . 5 ;
index1 ; index2 ; index3 ; index4 ; maxS1 = −1.0; int imax ; int jmax ;
double aux ; f o r ( j = 0 ; j < n f ; j ++) { f = j ∗ c1 ; S i n f = s i n ( f ) ; S i n f a = S i n f ∗a ; Cosf = c o s ( f ) ; Cosfa = Cosf ∗ a ; x1 = (−d)∗( − S i n f ) ; y1 = (−d ) ∗ ( Cosf ) ; f o r ( i = 0 ; i < np ; i ++)
13
{ index1 = i ∗ nf + j ; Z1 [ i n d e x 1 Z1 [ i n d e x 1 Z1 [ i n d e x 1 Z1 [ i n d e x 1
] . count ] . ind ] . seg ] . SumOfSegs
= = = =
0; NULL; NULL; 0.0;
nEl = 0 ; x2 = Cosf ∗ dc [ i ] − S i n f a ; y2 = S i n f ∗ dc [ i ] + Cosfa ; i f ( x1 != x2 ) { i f ( y1 != y2 ) { m = ( y2 − y1 ) / ( x2 − x1 ) ; b = y1 − m∗ x1 ; f o r ( k = 0 ; k < nyPlusOne ; k++) { xhrz = ( x l [ k ] − b ) / m; yhrz = x l [ k ] ; i f ( ( xhrz >= xLoLimit ) && ( xhrz = yLoLimit ) ( yhrz = xLoLimit ) && ( x v r t = yLoLimit ) ( y v r t = 2 ) { Z1 [ i n d e x 1 ] . count = nEl − 1 ; Z1 [ i n d e x 1 ] . i n d = ( unsigned int ∗ ) m a l l o c ( Z1 [ i n d e x 1 ] . count ∗ s i z e o f ( unsigned int ) ) ; Z1 [ i n d e x 1 ] . s e g = ( double∗ ) m a l l o c ( Z1 [ i n d e x 1 ] . count ∗ sizeof ( double ) ) ;
14
f o r ( k = 1 ; k < nEl ; k++) { xcm = (xV [ k − 1 ] + xV [ k ] ) / 2 . 0 ; ycm = (yV [ k − 1 ] + yV [ k ] ) / 2 . 0 ; Col = ( int ) f l o o r ( xcm + Var1 ) ; i f ( Col > nyMinusOne ) Col = Col − 1 ; Lin = ( int ) f l o o r ( Var2 − ycm ) ; i f ( Lin > nxMinusOne ) Lin = Lin − 1 ; s e g = s q r t ( pow (xV [ k ] − xV [ k − 1 ] , 2 ) + pow (yV [ k ] − yV [ k − 1 ] , 2 ) ) ; S1 [ i n d e x 1 ] = S1 [ i n d e x 1 ] + s e g ∗Mu[ Lin ∗ny + Col ] ; Z1 [ i n d e x 1 ] . i n d [ k − 1 ] = Lin ∗ny + Col ; Z1 [ i n d e x 1 ] . s e g [ k − 1 ] = s e g ; Z1 [ i n d e x 1 ] . SumOfSegs += s e g ; } i f ( S1 [ i n d e x 1 ] > maxS1 ) { maxS1 = S1 [ i n d e x 1 ] ; imax = i ; jmax = j ; } } } else { i f ( ( y1 >= yLoLimit ) && ( y1 nxMinusOne ) Lin = Lin − 1 ; f o r ( k = 1 ; k nyMinusOne ) Col = Col − 1 ; S1 [ i n d e x 1 ] = S1 [ i n d e x 1 ] + Mu[ Lin ∗ny + Col ] ; Z1 [ i n d e x 1 ] . i n d [ k − 1 ] = Lin ∗ny + Col ; Z1 [ i n d e x 1 ] . s e g [ k − 1 ] = 1 . 0 ; Z1 [ i n d e x 1 ] . SumOfSegs += 1 . 0 ; } i f ( S1 [ i n d e x 1 ] > maxS1 ) { maxS1 = S1 [ i n d e x 1 ] ; imax = i ; jmax = j ; } }
15
} } else { i f ( ( x1 >= xLoLimit ) && ( x1 nyMinusOne ) Col = Col − 1 ; f o r ( k = 1 ; k nxMinusOne ) Lin = Lin − 1 ; S1 [ i n d e x 1 ] = S1 [ i n d e x 1 ] + Mu[ Lin ∗ny + Col ] ; Z1 [ i n d e x 1 ] . i n d [ k − 1 ] = Lin ∗ny + Col ; Z1 [ i n d e x 1 ] . s e g [ k − 1 ] = 1 . 0 ; Z1 [ i n d e x 1 ] . SumOfSegs += 1 . 0 ; } i f ( S1 [ i n d e x 1 ] > maxS1 ) { maxS1 = S1 [ i n d e x 1 ] ; imax = i ; jmax = j ; } } } V. c l e a r ( ) ; } } start2 = clock ( ) ;
unsigned int unsigned int
ray1 ; ray2 ;
double Sit1 ; double Sit2 ; double R at io 1 ; double coeff ; double coeff1 ; double coeff2 ; unsigned int ∗ p i 1 ; unsigned int ∗ p i 2 ; double ∗pd1 ; double double double
maxRay1 ; maxRay2 ; maxRay3 ;
16
double double
sumExt ; sumOFS ;
unsigned int
I1 ;
int int
z; T;
i f ( f o p e n s (& f1 , ” p a i r s −270x270 . t x t ” , ” r ” ) != 0 ) MessageBox (NULL, (LPCWSTR)L” Problem a t f o p e n s ! ” , (LPCWSTR)L” E r r o r ! ” , MB OK) ; unsigned int ∗vRay1 = ( unsigned int ∗ ) m a l l o c ( 6 2 8 2 6 7 4 ∗ s i z e o f ( unsigned int ) ) ; unsigned int ∗vRay2 = ( unsigned int ∗ ) m a l l o c ( 6 2 8 2 6 7 4 ∗ s i z e o f ( unsigned int ) ) ; f o r ( z = 0 ; z < 6 2 8 2 6 7 4 ; z++) { f s c a n f s ( f1 , ”%d” , &ray1 ) ; f s c a n f s ( f1 , ”%d” , &ray2 ) ; vRay1 [ z ] = ray1 ; vRay2 [ z ] = ray2 ; } f c l o s e ( f1 ) ; start2 = clock ( ) ; int ∗ Mzeros = ( int ∗ ) m a l l o c ( nxny ∗ s i z e o f ( int ) ) ; f o r ( i = 0 ; i < nxny ; i ++) Mzeros [ i ] = 1 ; f o r ( i = 0 ; i < npnf ; i ++) { i f ( S1 [ i ] == 0 . 0 ) f o r ( k = 0 ; k < Z1 [ i ] . count ; k++) Mzeros [ Z1 [ i ] . i n d [ k ] ] = 0 ; } f o r ( i = 0 ; i < npnf ; i ++) { Z1 [ i ] . Ind = NULL; Z1 [ i ] . Seg = NULL; Z1 [ i ] . Count = 0 ; i f ( Z1 [ i ] . count > 0 ) { Z1 [ i ] . Ind = ( unsigned int ∗ ) m a l l o c ( Z1 [ i ] . count ∗ s i z e o f ( unsigned int ) ) ; Z1 [ i ] . Seg = ( double∗ ) m a l l o c ( Z1 [ i ] . count ∗ s i z e o f ( double ) ) ; f o r ( k = 0 ; k < Z1 [ i ] . count ; k++) i f ( Mzeros [ Z1 [ i ] . i n d [ k ] ] == 1 ) { Z1 [ i ] . Ind [ Z1 [ i ] . Count ] = Z1 [ i ] . i n d [ k ] ; Z1 [ i ] . Seg [ Z1 [ i ] . Count ] = Z1 [ i ] . s e g [ k ] ; Z1 [ i ] . Count++; } } }
17
i = 0; I1 = 125000; f o r ( z = I 1 ; z != 0 ; z−−) { ray1 = vRay1 [ i ] ; ray2 = vRay2 [ i ] ; i ++; i f ( ( S1 [ ray1 ] > 0 . 0 ) && ( S1 [ ray2 ] > 0 . 0 ) ) { i n d e x 1 = Z1 [ ray1 ] . Count ; i n d e x 2 = Z1 [ ray2 ] . Count ; Sit1 = 0.0; p i 1 = Z1 [ ray1 ] . Ind ; pd1 = Z1 [ ray1 ] . Seg ; f o r ( k = 0 ; k < i n d e x 1 ; k++) { S i t 1 += ( ∗ pd1 ) ∗ RI [ ∗ p i 1 ] ; p i 1 ++; pd1++; } Sit2 = 0.0; p i 1 = Z1 [ ray2 ] . Ind ; pd1 = Z1 [ ray2 ] . Seg ; f o r ( k = 0 ; k < i n d e x 2 ; k++) { S i t 2 += ( ∗ pd1 ) ∗ RI [ ∗ p i 1 ] ; p i 1 ++; pd1++; } R at io 1 = S1 [ ray1 ] / S1 [ ray2 ] ; c o e f f = ( R a ti o1 ∗ S i t 2 − S i t 1 ) / ( 1 . 0 + Ra ti o 1 ) ; coeff1 = coeff / Sit1 ; coeff2 = coeff / Sit2 ; p i 1 = Z1 [ ray1 ] . Ind ; f o r ( k = 0 ; k < i n d e x 1 ; k++) { RI [ ∗ p i 1 ] += ( 1 . 0 ) ∗ c o e f f 1 ∗RI [ ∗ p i 1 ] ; p i 1 ++; }
p i 1 = Z1 [ ray2 ] . Ind ; f o r ( k = 0 ; k < i n d e x 2 ; k++) { RI [ ∗ p i 1 ] −= ( 1 . 0 ) ∗ c o e f f 2 ∗RI [ ∗ p i 1 ] ; p i 1 ++; } } else { z++; }
18
} f i n i s h = clock ( ) ; d u r a t i o n 1 = ( double ) ( s t a r t 2 − s t a r t 1 ) / CLOCKS PER SEC ; d u r a t i o n 2 = ( double ) ( f i n i s h − s t a r t 2 ) / CLOCKS PER SEC ;
f o r ( i = 0 ; i < npnf ; i ++) { f r e e ( Z1 [ i ] . i n d ) ; f r e e ( Z1 [ i ] . s e g ) ; f r e e ( Z1 [ i ] . Ind ) ; f r e e ( Z1 [ i ] . Seg ) ; } f r e e ( Z1 ) ; f r e e (Mu) ; f r e e (O1 ) ; f r e e ( dc ) ; free ( xl ) ; free ( yl ) ; f r e e ( S1 ) ; f r e e (xV ) ; f r e e (yV ) ; f r e e ( vRay1 ) ; f r e e ( vRay2 ) ; f r e e ( Mzeros ) ;
min1 = RI [ 0 ] ; f o r ( i = 0 ; i < nxny ; i ++) i f ( RI [ i ] < min1 ) min1 = RI [ i ] ; max1 = RI [ 0 ] ; f o r ( i = 0 ; i < nxny ; i ++) i f ( RI [ i ] > max1 ) max1 = RI [ i ] ;
char ∗ b u f f e r 1 = NULL; b u f f e r 1 = ( char ∗ ) m a l l o c ( CVTBUFSIZE ) ; i f ( f o p e n s (& f1 , ” f o u t 1 . t x t ” , ”w+t ” ) == 0 ) { f o r ( i = 0 ; i < nxny ; i ++) { s p r i n t f s ( b u f f e r 1 , CVTBUFSIZE , ”%f \n” , RI [ i ] ) ; fputs ( buffer1 , f1 ) ; } f c l o s e ( f1 ) ; } else MessageBox (NULL, (LPCWSTR)L” Problem a t f o p e n s 3 ! ” , (LPCWSTR)L” E r r o r ! ” , MB OK) ; free ( buffer1 );
19
if ( pixels ) free ( pixels ); p i x e l s = ( unsigned char ∗ ) m a l l o c ( 3 ∗ nx ∗ ny + 2 ∗ nx ) ; unsigned char c ; f o r ( i = 0 ; i < nx ; i ++) { f o r ( j = 0 ; j < ny ; j ++) { c = ( unsigned char ) ( ( RI [ i ∗ny + j ] / max1 ) ∗ 2 5 5 . 0 ) ; p i x e l s [ i ∗ 3 ∗ ny + i ∗ 2 + 3 ∗ j ] = c; p i x e l s [ i ∗ 3 ∗ ny + i ∗ 2 + 3 ∗ j + 1 ] = c ; p i x e l s [ i ∗ 3 ∗ ny + i ∗ 2 + 3 ∗ j + 2 ] = c ; } }
S e t C u r s o r ( LoadCursor (NULL, IDC WAIT ) ) ; I n v a l i d a t e R e c t (hWnd, NULL, TRUE) ; Status = 1; MSG msg1 ; msg1 . hwnd = hWnd ; msg1 . message = WM PAINT; DispatchMessage (&msg1 ) ; } break ; case IDM ABOUT: DialogBox ( h I n s t , MAKEINTRESOURCE(IDD ABOUTBOX) , hWnd, About ) ; break ; case IDM EXIT : DestroyWindow (hWnd ) ; break ; default : return DefWindowProc (hWnd, message , wParam , lParam ) ; } } break ; case WM PAINT: { PAINTSTRUCT ps ; HDC hdc = B e g i n P a i n t (hWnd, &ps ) ; i f ( S t a t u s == 1 ) { bmih . b i S i z e = s i z e o f (BITMAPINFOHEADER) ; bmih . biWidth = ( int ) ny ; bmih . b i H e i g h t = −( int ) nx ; bmih . b i P l a n e s = 1 ; bmih . biBitCount = 2 4 ; bmih . b i C om p r e ss i o n = BI RGB ; bmih . b i S i z e I m a g e = 0 ; bmih . biXPelsPerMeter = 1 0 ; bmih . biYPelsPerMeter = 1 0 ; bmih . b i C l r U s e d = 0 ;
20
bmih . b i C l r I m p o r t a n t = 0 ;
ZeroMemory(&dbmi , s i z e o f ( dbmi ) ) ; dbmi . bmiHeader = bmih ; dbmi . bmiColors−>rgbBlue = 0 ; dbmi . bmiColors−>rgbGreen = 0 ; dbmi . bmiColors−>rgbRed = 0 ; dbmi . bmiColors−>r g b R e s e r v e d = 0 ; b i t s = ( void ∗)&( p i x e l s [ 0 ] ) ;
hbmp = C r e a t e D I B S e c t i o n ( hdc , &dbmi , DIB RGB COLORS, &b i t s , NULL, 0 ) ; i f (hbmp == NULL) MessageBox (hWnd, (LPCWSTR)L” Couldn ’ t c r e a t e bitmap ! ” , (LPCWSTR)L” E r r o r ! ” , MB OK) ; memcpy ( b i t s , p i x e l s , 3 ∗ nx ∗ ny + 2 ∗ nx ) ;
hdcMem = CreateCompatibleDC ( hdc ) ; hbmOld = S e l e c t O b j e c t (hdcMem , hbmp ) ; GetObject (hbmp , s i z e o f (bmp) , &bmp ) ; B i t B l t ( hdc , 0 , 0 , bmp . bmWidth , bmp . bmHeight , hdcMem , 0 , 0 , SRCCOPY) ; S e l e c t O b j e c t (hdcMem , hbmOld ) ; DeleteDC (hdcMem ) ; RECT r1 , r2 , r3 , r1 . l e f t = 0; r 1 . top = nx + r 1 . r i g h t = ny ; r 1 . bottom = nx + r2 . l e f t = 0; r 2 . top = nx + r 2 . r i g h t = ny ; r 2 . bottom = nx + r3 . l e f t = 0; r 3 . top = nx + r 3 . r i g h t = ny ; r 3 . bottom = nx + r4 . l e f t = 0; r 4 . top = nx + r 4 . r i g h t = ny ; r 4 . bottom = nx +
r4 ; 10; 40; 40; 70; 70; 100; 100; 130;
WCHAR b u f f e r 1 [ 5 0 ] ; int l e n ; l e n = s w p r i n t f ( b u f f e r 1 , 5 0 , L”Time 1 : %12.2 f ” , d u r a t i o n 1 ) ; DrawText ( hdc , (LPTSTR) b u f f e r 1 , l e n , &r1 , DT RIGHT ) ; l e n = s w p r i n t f ( b u f f e r 1 , 5 0 , L”Time 2 : %12.2 f ” , d u r a t i o n 2 ) ; DrawText ( hdc , (LPTSTR) b u f f e r 1 , l e n , &r2 , DT RIGHT ) ; l e n = s w p r i n t f ( b u f f e r 1 , 5 0 , L” min : %12.2 f ” , min1 DrawText ( hdc , (LPTSTR) b u f f e r 1 , l e n , &r3 , DT RIGHT ) ;
);
l e n = s w p r i n t f ( b u f f e r 1 , 5 0 , L” max : %12.2 f ” , max1 DrawText ( hdc , (LPTSTR) b u f f e r 1 , l e n , &r4 , DT RIGHT ) ;
);
}
21
EndPaint (hWnd, &ps ) ; } break ; case WM DESTROY: i f (hbmp) D e l e t e O b j e c t (hbmp ) ; PostQuitMessage ( 0 ) ; break ; default : return DefWindowProc (hWnd, message , wParam , lParam ) ; } return 0 ; } // Message h a n d l e r f o r a b o u t box . INT PTR CALLBACK About (HWND hDlg , UINT message , WPARAM wParam , LPARAM lParam ) { UNREFERENCED PARAMETER( lParam ) ; switch ( message ) { case WM INITDIALOG : return (INT PTR)TRUE; case WMCOMMAND: i f (LOWORD( wParam ) == IDOK | | LOWORD( wParam ) == IDCANCEL) { EndDialog ( hDlg , LOWORD( wParam ) ) ; return (INT PTR)TRUE; } break ; } return (INT PTR)FALSE ; }
6.2
Generation of Non-overlapping X-rays
When describing the second randomized algorithm, we have explained that the two X-rays chosen at each iteration have to be such that they don’t have share any element of the reconstruction matrix. For the example of the 250 by 250 phantom that we have tested, we have generated enough pairs such that up to 1000000 iterations can be run on the shown example. Precisely, 6282674 pairs of X-rays have been generated, for the special geometry and parameter values of the shown example with 270 projections views. We have calculated that exactly these number of pairs are needed in order to run up to 1000000 iterations for the shown example with 270 projection views. That is, 5282674 pairs from this pool of pairs will not satisfy the condition if ((S1[ray1] > 0.0)&&(S1[ray2] > 0.0)). Before the correction algorithm starts, as one can see, the pairs are loaded in memory and used during the correction algorithm.
7
Conclusions
We have proposed fast corection of analytical algorithms for sparse view X-ray CT, that provide significantly better reconstructions as compared to the results obtained by the analytical algorithms alone, and thus can be used for speeding-up the experiment, as less number of views are required in order to obtain comparable quality of reconstruction. One important thing that needs to be done with the proposed randomized iterative algorithms is to study their convergence and define precise stopping criteria to be used in practice. 22
References [1] Beister, M., D. Kolditz and W. A. Kalender, “Iterative reconstruction methods in X-ray CT,” Physica Medica, Vol. 28, 94–108, 2012. [2] Kak, A. and M. Slaney, Principles of Computerized Tomographic Imaging, Classics in Applied Mathematics, Book 33, 327p, 2001. [3] Libin, E. E., S. V. Chakhlov and D. Trinca, “Direct Integration of the Inverse Radon Equation for X-Ray Computed Tomography,” Journal of X-Ray Science and Technology, Vol. 24, 787–795, 2016. [4] Niu, S., Y. Gao, Z. Bian, J. Huang, W. Chen, G. Yu, Z. Liang and J. Ma, “Sparse-view X-ray CT Reconstruction via Total Generalized Variation Regularization,” Physics in Medicine and Biology, Vol. 59, 2997–3017, 2014. [5] Zhang, H., L. Wang, B. Yan, L. Li, A. Cai and G. Hu, “Constrained Total Generalized p-Variation Minimization for Few-View X-Ray Computed Tomography Image Reconstruction,” PLoS One, Vol. 11, e0149899, 2016. [6] Li, M., C. Zhang, C. Peng, Y. Guan, P. Xu, M. Sun and J. Zheng, “Smoothed l0 Norm Regularization for Sparse-View X-Ray CT Reconstruction,” BioMed Research International, article 2180457, 2016. [7] Liu, Y., Z. Liang, J. Ma, H. Lu, K. Wang, H. Zhang and W. Moore, “Total Variation-Stokes Strategy for Sparse-View X-ray CT Image Reconstruction,” IEEE Transactions on Medical Imaging, Vol. 33, 749–763, 2014.
23