Professional Documents
Culture Documents
HCM
- to ra hnh nh ca mt mt ct, my tnh phi tnh ton h s suy gim khi trung bnh ca mi voxel. Cc h s ny c th c xc nh theo phng php i s vi mt lng rt ln phng trnh. Tuy nhin, mt phng php n gin hn c gi l phng php Filtered Back Projection (hnh chiu ngc c lc) c s dng ph bin trong cc my CT ngy nay. Tia X qut ngang c thu thp thnh tp hp hnh chiu c thc hin xuyn qua bnh nhn theo mt hng c th no trong mt phng ct. - ti to li hnh nh t cc tn hiu tia X truyn qua, mi voxel phi c chiu t nhiu hng khc nhau. Mt tp hp d liu y cn n nhiu hnh chiu cc gc quay khc nhau xung quanh mt ct. Tm li, qu trnh qut CT to ra hnh nh cc lp ct trong mt bnh nhn bao gm ba bc chnh sau y : THU NHN HNH CHIU TI TO LP CT HIN TH HNH NH 2) Cc thut ton [Avinash, Rosenberg ] : Trnh t m phng to nh ct lp bao gm cc bc sau : a) Chiu mt lp ct (2-D) xung mt phng xc nh theo mt gc no to ra mt hnh chiu 1-D Thu nhn mt tp hp hnh chiu 1-D b) Mi hnh chiu c x l qua b lc c) Cc hnh chiu lc s c chiu ngc v tng hp ng thi to ra nh lp ct gc
a) Thu nhn tp hp hnh chiu 1-D: trong thc t, cc hnh chiu ny l tn hiu cc u d thu nhn c ng vi mi ln chiu mt gc quay no . Trong m phng, ta s dng php bin i Radon. Php bin i Radon ca mt hm hai bin no c nh ngha nh tch phn ng ca n dc theo mt phng to mt gc so vi trc y v cch gc to mt khong s. Biu thc ca php bin i c dng sau:
2/2
1 , z = 0 ( z) = 0 , z 0
Qua php bin i Radon ng vi N gc khc nhau, ta thu nhn c tp hp N hnh chiu k hiu g( , s). th tp hp hnh chiu gi l sinogram. b) Ti to nh ct lp: s dng phng php chiu ngc c lc (Filtered Back Projection). Phng php ny c xy dng trn c s nh l chiu lp Fourier (Fourier Slice Theorem) c hiu nh sau [Avinash]:
- Theo nh l chiu lp Fourier , G( , ) ng thi cng l hm bin i 2-D F(u,v) ca f(x,y) vi s i bin u = *sin( ) , v = - *cos( ). - S ti to nh lp ct c thc hin bng php bin i Fourier 2-D ngc c lc qua biu thc sau:
Lu hnh chiu c nhn vi hm | | trong min Fourier, iu tng ng vi tch chp tng ng trong min khng gian (x, y) ngha b lc. tng ca b lc xut pht t cc tn s thu nhn c cng nh tnh phc ca php bin i Fourier. V d: Nu c b lc u tin cho min tn s cao, hnh ti to r nt nhng nhiu nhiu v ngc li nu b lc u tin cho min tn s thp, nhiu gim nhng hnh ti to b m.Vn quan trng l p dng b lc dng no cho ph hp. cng l mc tiu kho st trong bi th nghim. 2/3
4. M t chng trnh m phng s to nh ct lp CT Chng trnh m phng s to nh ct lp vi mc ch ti hin cc c s l thuyt ca cc thut ton ct lp v x l nh ti to trn c s cc sinogram c m phng. Trong phn m t ny, chng trnh thc hin cc bc c bn to ra mt cng c hiu qu gip cc sinh vin hiu r nguyn l thu nhn ti to nh v thc hnh mt s k nng x l nh ct lp. Chng trnh c vit bng MATLAB nhm gii thiu sinh vin lm quen s dng mt cng c lp trnh k thut c lc vi ngun ti nguyn th vin phong ph trong nhiu lnh vc. Phn m ngun di y l nhng phn c bn ca mt chng trnh c th nghim c kt qu v ch mang tnh cht minh ha. Sinh vin han tan c th chnh sa ty theo thit k ring v mc thnh thc trong kh nng lp trnh. Chng trnh m t di y m phng s to nh ct lp vi cu hnh n gin nht: ngun tia X l ngun rng vi tia song song bao trm c kch thc ngang ca mt ct. Vt chiu Ngun tia X u thu nhn
Chng trnh bao gm 2 chng trnh con: - BP1.m : chng trnh m phng to nh ct lp bng lp trnh cc thut ton bin i theo l thuyt. - BP2.m : chng trnh m phng to nh ct lp bng cc lnh bin i c sn trong th vin Image Processing Toolbox ca MATLAB. C hai chng trnh bao gm 4 phn: - Phn 1: c nh vo b nh ca MATLAB. Lu cu lnh c k t % pha trc trong MATLAB l cu lnh tr, c th dng k t ny tm b nhng cu lnh chc nng khng dng n m khng phi xo chng.
% % % % % % BP1.m TOMOGRAPHY SIMULATION BY BP ALGORITHM PROGRAMMING Usage : BP1(IMAGE, N) IMAGE - a picture loaded into some matric in Matlab N - the number of projections you want taken between 0 and 180
function BP1 = BP1(image,N) % Load the image into Matlab disp('Loading Image into Matlab...'); image; %Goi chuong trinh tao anh trong Matlab %[image,MAP,out]=bmpread('logan.bmp'); %Doc file BMP 16bit %[image,MAP]=bmpread('CT1.bmp'); %Doc file BMP 8bit
2/4
% % Usage : picstandard; % % Here we make a picture (100X100) with various shapes function picstandard = picture2() picstandard = zeros(100,100); x1 = 1:100; y1 = 1:100; [x,y] = meshgrid(x1,y1); % Rectangle on left picstandard(70:90, 10:20) = ones(21,11); picstandard(70:90, 80:90) = ones(21,11); Rectangle on Right picstandard(30:85, 75:95) = ones(56,21); Thin Horiz. Line picstandard(70,10:30) picstandard(75,10:30) picstandard(80,10:30) picstandard(85,10:30) picstandard(85,10:30) picstandard(90,10:30) = = = = = = ones(1,21); ones(1,21); ones(1,21); ones(1,21); ones(1,21); ones(1,21);
% %
Circle p = (x-50).^2 + (y-57).^2; size = 250; picstandard(find(p<=size)) = ones(1,length(find(p<=size))); Triangle i = 0; n = 30; picstandard(10,50) = ones(1,1); for i = 1:n, picstandard(i+10,50-i: 50+i) = ones(1,2*i+1); end;
function [X,map,out3]=bmpread(filename); %BMPREAD Read a BMP (Microsoft Windows Bitmap) file from disk. % [X,MAP]=BMPREAD('filename') reads the 8-bit BMP file and % returns the indexed image X and associated colormap % MAP. If no extension is given for the filename, the % extension '.bmp' is assumed. % [X,MAP,OUT]=BMPREAD('filename') reads the 24-bit BMP file % from the file 'filename'. % BPP=BMPREAD('filename') returns the number of bits per % pixel in the BMP file
V d:
[image,MAP,out]=bmpread('logan.bmp'); %Doc file BMP 16bit [image,MAP]=bmpread('CT1.bmp'); %Doc file BMP 8bit
- Phn 3: Dng php bin i radon to sinogram cc hnh chiu v hin th gc phn t th hai ca trang kt qu. * Trong BP1:
% % Take the Projections of the image where 'count' is the number of intervals for theta between 1 and 180 interval = linspace(1, 180, N); Proj = proj(image, N); disp('Calculating projections of the image...'); subplot(222); imagesc(Proj); title('Sinogram - Plot of unchanged projections');
% Add Noise to projections - Thm nhiu ngu nhin cho nh (nu mun). disp('Adding noise to each projection...'); X = randn(144); for i = 1:N Proj(:,i)= Proj(:,i) +(2.* X(:,i)); end
2/6
on m trn gi hm hnh chiu proj(image, N) thng qua thut ton tnh tch phn ng theo mt gc no .
% This MATLAB function takes an image matrix and vector of angles and then % finds the 1D projection (Radon transform) at each of the angles. It % returns a matrix whose columns are the projections at each angle. function Projection = proj(IMG, N) % % Create a vector of values for theta interval = linspace(1, 180, N); Take images and pad with zero to eliminate error [iLength, iWidth] = size(IMG); iDiag = sqrt(iLength^2 + iWidth^2); LengthPad = ceil(iDiag - iLength) + 2; WidthPad = ceil(iDiag - iWidth) + 2; padIMG = zeros(iLength+LengthPad, iWidth+WidthPad); padIMG(ceil(LengthPad/2):(ceil(LengthPad/2)+iLength-1), ... ceil(WidthPad/2):(ceil(WidthPad/2)+iWidth-1)) = IMG; % Here we rotate the image N different angles of theta, and then sum the columns % of each of these projected images in order to build N different projections n = length(interval); Projection = zeros(size(padIMG,2), n); for i = 1:n temp = imrotate(padIMG, 90-interval(i), 'bilinear', 'crop'); Projection(:,i) = (sum(temp))'; end
- Phn 4: Dng php bin i chiu ngc ti to nh mt ct v hin th gc phn t th 3 v th 4 ca trang kt qu. * Trong BP1:
% % Using the projections from above we can back-project the image using our backprojection algorithm disp('Reconstructing the image from back-projection...'); BP = backuf(Proj, interval); % Hm chiu ngc khng lc subplot(223); BP = BP(22:121,22:121); imagesc(BP); title('Unfiltered Back-Projected Image'); Using the projections from above we can now filter and back-project
2/7
the image using our backprojection algorithm disp('Reconstructing the image from back-projection...'); BP = back(Proj, interval); % Hm chiu ngc c lc subplot(224); BP = BP(22:121,22:121); imagesc(BP); title('Filtered Back-Projected Image');
Trong on m trn c s dng hm chiu ngc back hoc backuf lp trnh theo thut ton:
function BackI = back(PR, THETA) % Determine the size of the projected, PR, image n = size(PR,1); sideSize = n; % * * * FILTER THE PROJECTIONS * * * % No Filter applied % filtPR = PR; % Ramp Filter with Cutoff filtPR = projfilter(PR); % % % Convert THETA to radians and subtract pi so the reconstructed image has the same orientation th = pi - ((pi/180)*THETA); Prepare image m = length(THETA); BackI = zeros(sideSize,sideSize); Find the middle index of the projections midindex = (n+1)/2; Create x and y matrices x = 1:sideSize; y = 1:sideSize; [X,Y] = meshgrid(x,y); xpr = X - (sideSize+1)/2; ypr = Y - (sideSize+1)/2; for i = 1:m % Use the backprojection algorithm to determine which areas % on the projected images add up filtIndex = round(midindex + xpr*sin(th(i)) - ypr*cos(th(i))); % While "in bounds" then add the point BackIa = zeros(sideSize,sideSize); spota = find((filtIndex > 0) & (filtIndex <= n)); newfiltIndex = filtIndex(spota); BackIa(spota) = filtPR(newfiltIndex(:),i); BackI = BackI + BackIa; end BackI = BackI./m;
% %
% % % %
The code below takes a matrix of projections and returns a matrix with filtered projections whose Fourier Transform is |w|. By uncommenting the vairous filters, various aspects of the reconstructed picture will be emphasized or lost.
function FIL = projfilter(Image) [L,C]=size(Image); % - - - - - - Filters - - - - - - - % % Uncomment the different filters below to change which one is applied to the projections we calculate in proj.m
w = [-pi : (2*pi)/L : pi-(2*pi)/L]; % Ramp filter (Linear High-Pass filter) Filt = fftshift(abs(w)); % The opposite of the Ramp Function (Linear Low-Pass Filter) %Filt = (abs(w)); % IIR Filter %a=[1,-.9]; %b=[1]; % FIR-Box car-length 32 %a=1; %b=[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]; % Butterworth Filter (Low-Pass Filter) %fcutoff = 1000; %Filt=3*10^5*((1+.414.*(fcutoff./(abs(w))).^2).^-1); % Sinusoidal Filter (peak at 25) % Filt = abs(sin(w)); % Stretched Sinusoidal Filter (peak at 42) %L = 170; %w = [-pi : (2*pi)/L : pi-(2*pi)/L]; %Filt = abs(sin(w)); %Filt = Filt(1:144); %Filt = Filt .* 3.5; % - - - - - - - - - - - - - - - - % Below we use the Fourier Slice Theorem to filter the image for i = 1:C, IMG = fft(Image(:,i)); FiltIMG = IMG.*Filt'; %FiltIMG = filter (b, a, IMG); FIL(:,i) = ifft(FiltIMG); end % Remove any remaining imaginary parts FIL = real(FIL);
% Using the projections from above we can back-project % the image using our backprojection algorithm disp('Reconstructing the image from back-projection...'); BP = iradon(proj,theta1); subplot(223); imagesc(BP); title('BP Image: Ram-Lak filter, linear interp.'); % % % % % % % % Add Noise to projections disp('Adding noise to each projection...'); X = randn(145); for i = 1:N proj(:,i)= proj(:,i) +(2.* X(:,i)); end Using the projections from above we can now filter and back-project the image using our backprojection algorithm disp('Reconstructing the image from back-projection...'); BP = iradon(proj,theta1,'spline','Hamming'); subplot(224); imagesc(BP); title('BP Image: Hamming filter, spline interp.');
- Ghi ch: Chng trnh BP2 thng cho kt qu ti to tt hn chng trnh BP1 v lnh php bin i ngc iradon c lp trnh mt cch ti u thng qua s chn b lc (mc nh Ram-Lak) v php ni suy (mc nh l linear). Tuy nhin sinh vin kh lng hiu c phn chng trnh c th ca 2 lnh radon v iradon m ch c th p dng mt cch my mc. Cho nn chng trnh BP1 to c hi cho sinh vin c th t lp trnh thut ton v th nghim nhiu dng b lc khc m lnh iradon khng cho php. 5. Nhim v v cu hi 1) Vn hnh MATLAB v tm hiu cc cu lnh c bn phc v cho bi th nghim. Ch tm hiu k 2 lnh radon v iradon (vit m t hai hm trn trong bo co). 2) Dng ti liu v phn help ca Matlab kho st cc dng hm lc trong php bin i back projection (vit tng quan bo co) 3) Thc hin lp trnh phn chng trnh BP1 v BP2 v chy th nghim: - Chp cc phn m ngun trong phn l thuyt vo trong giao din M-file ca MATLAB, lin kt v chy th. Ch s dng debug xc nh chnh sa li. - To cc file nh th nghim: ch phi l file BMP 100x100 pixels (c th s dng cc nh khc vi cc nh c trong th mc chng trnh cung cp). - Lu li m ngun v kt qu lm bo co. 4) Th thay i cc dng b lc khc nhau trong BP1 v BP2 v nhn xt. 5) Tm hiu lnh fanbeam v ifanbeam v xy dng chng trnh to nh ct lp trn c s cc hm (Lu li m ngun v kt qu lm bo co). 6. Ti liu tham kho: 1. Avinash C. Kak, Malcolm Slaney: "Principles of Computerized Tomographic Imaging" IEEE Press - 1988
2/10
2. Anthony Brinton Wolbarst: "Physics of Radiology", Prentice Hall International, Inc.- 1993 3. Kevin M. Rosenberg: "Ctsim The Open-Source Computed Tomography Simulator" 4. http://bigwww.epfl.ch
vlktcaohoc2009@gmail.com
2/11