|
a |
|
b/fcnPseudoBmodeUltrasoundSimulator.m |
|
|
1 |
function [imageOut, rfEnvelope] = fcnPseudoBmodeUltrasoundSimulator(echoModel,f0,c,sigma_x,sigma_y,speckleVariance) |
|
|
2 |
|
|
|
3 |
% fcnPseudoBmodeUltrasoundSimulator generates a simulated Pseudo B-Mode |
|
|
4 |
% Ultrasound image given the echogenicity model for the structure to be |
|
|
5 |
% imaged. |
|
|
6 |
% |
|
|
7 |
% OUTPUTIMAGE = fcnPseudoBmodeUltrasoundSimulator(ECHO_MODEL) generates |
|
|
8 |
% the simulated B-Mode Ultrasound image using default parameter settings. |
|
|
9 |
% The size of the simulated image is same as size of the echogenity |
|
|
10 |
% matrix provided. The OUTPUTIMAGE is of type uint8. Supported classes |
|
|
11 |
% for ECHO_MODEL are uint8, uint16, single, double. |
|
|
12 |
% |
|
|
13 |
% OUTPUTIMAGE = fcnPseudoBmodeUltrasoundSimulator(ECHO_MODEL, F_0, C, |
|
|
14 |
% SIGMA_X, SIGMA_Y, SPECKLE_VARIANCE) generates the simulated B-Mode |
|
|
15 |
% Ultrasound image using the specified parameters based on the ECHO_MODEL |
|
|
16 |
% provided. |
|
|
17 |
% |
|
|
18 |
% F_0 - Center frequency of the ultrasonic wave. Default valus is 10e6 |
|
|
19 |
% C - Velocity of sound in media (m/s). Default valus is 1540 |
|
|
20 |
% SIGMA_X - Pulse-width of transmitting ultrasonic wave. Default |
|
|
21 |
% value is 2 |
|
|
22 |
% SIGMA_Y - Beam-width) of transmitting ultrasonic wave. Default |
|
|
23 |
% value is 1.5 |
|
|
24 |
% SPECKLE_VARIANCE - Variance of Speckle distribution of the media. |
|
|
25 |
% Default value is 0.01 |
|
|
26 |
% |
|
|
27 |
% [OUTPUTIMAGE, RF_ENVELOPE] = fcnBPDFHE(...) returns also the |
|
|
28 |
% rf Envelope matrix for further usage. |
|
|
29 |
% |
|
|
30 |
% Details of the method are available in |
|
|
31 |
% |
|
|
32 |
% Yongjian Yu, Acton, S.T., "Speckle reducing anisotropic diffusion," |
|
|
33 |
% IEEE Trans. Image Processing, vol. 11, no. 11, pp. 1260-1270, Nov 2002. |
|
|
34 |
% [http://dx.doi.org/10.1109/TIP.2002.804276] |
|
|
35 |
% |
|
|
36 |
% J. C. Bambre and R. J. Dickinson, "Ultrasonic B-scanning: A computer |
|
|
37 |
% simulation", Phys. Med. Biol., vol. 25, no. 3, pp. 463479, 1980. |
|
|
38 |
% [http://dx.doi.org/10.1088/0031-9155/25/3/006] |
|
|
39 |
% |
|
|
40 |
% 2011 (c) Debdoot Sheet, Indian Institute of Technology Kharagpur, India |
|
|
41 |
% Ver 1.0 27 October 2011 |
|
|
42 |
% |
|
|
43 |
% Example |
|
|
44 |
% ------- |
|
|
45 |
% echoModel = imread('phantom.bmp'); |
|
|
46 |
% outputImage = fcnPseudoBmodeUltrasoundSimulator(echoModel); |
|
|
47 |
% figure, subplot 121, imshow(echoModel,[]), subplot 122, |
|
|
48 |
% imshow(outputImage); |
|
|
49 |
% |
|
|
50 |
|
|
|
51 |
% 2011 (c) Debdoot Sheet, Indian Institute of Technology Kharagpur, India |
|
|
52 |
% All rights reserved. |
|
|
53 |
% |
|
|
54 |
% Permission is hereby granted, without written agreement and without |
|
|
55 |
% license or royalty fees, to use, copy, modify, and distribute this code |
|
|
56 |
% (the source files) and its documentation for any purpose, provided that |
|
|
57 |
% the copyright notice in its entirety appear in all copies of this code, |
|
|
58 |
% and the original source of this code. Further Indian Institute of |
|
|
59 |
% Technology Kharagpur (IIT Kharagpur / IITKGP) is acknowledged in any |
|
|
60 |
% publication that reports research or any usage using this code. |
|
|
61 |
% |
|
|
62 |
% In no circumstantial cases or events the Indian Institute of Technology |
|
|
63 |
% Kharagpur or the author(s) of this particular disclosure be liable to any |
|
|
64 |
% party for direct, indirectm special, incidental, or consequential |
|
|
65 |
% damages if any arising out of due usage. Indian Institute of Technology |
|
|
66 |
% Kharagpur and the author(s) disclaim any warranty, including but not |
|
|
67 |
% limited to the implied warranties of merchantability and fitness for a |
|
|
68 |
% particular purpose. The disclosure is provided hereunder "as in" |
|
|
69 |
% voluntarily for community development and the contributing parties have |
|
|
70 |
% no obligation to provide maintenance, support, updates, enhancements, |
|
|
71 |
% or modification. |
|
|
72 |
|
|
|
73 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
|
74 |
|
|
|
75 |
% Input argument support check |
|
|
76 |
iptcheckinput(echoModel,{'uint8','uint16','single','double'}, {'nonsparse','2d'}, mfilename,'I',1); |
|
|
77 |
|
|
|
78 |
if nargin == 1 |
|
|
79 |
f0 = 10e6; |
|
|
80 |
c = 1540; |
|
|
81 |
sigma_x = 2; |
|
|
82 |
sigma_y = 1.5; |
|
|
83 |
speckleVariance = 0.01; |
|
|
84 |
elseif nargin == 6 |
|
|
85 |
if f0 <= 0 |
|
|
86 |
error('Center frequency (f0) should be non-zero positive'); |
|
|
87 |
elseif c<=0 |
|
|
88 |
error('Velocity of sound (c) in media should be non-zero positive'); |
|
|
89 |
elseif sigma_x<=0 |
|
|
90 |
error('Pulse-width (sigma_x) of transmitting ultrasonic wave should be non-zero positive'); |
|
|
91 |
elseif sigma_y<=0 |
|
|
92 |
error('Beam-width (sigma_y) of transmitting ultrasonic wave should be non-zero positive'); |
|
|
93 |
elseif speckleVariance<=0 |
|
|
94 |
error('Variance of Speckle distribution (speckleVariance) of the media should be non-zero positive'); |
|
|
95 |
end |
|
|
96 |
else |
|
|
97 |
error('Unsupported calling of fcnPseudoBmodeUltrasoundSimulator'); |
|
|
98 |
end |
|
|
99 |
|
|
|
100 |
k0 = 2*pi*f0/c; |
|
|
101 |
|
|
|
102 |
[nRows nCols] = size(echoModel); |
|
|
103 |
|
|
|
104 |
echoModel = mat2gray(echoModel); |
|
|
105 |
|
|
|
106 |
G = rand([nRows nCols],'double'); |
|
|
107 |
|
|
|
108 |
G = (G-mean(G(:)))*speckleVariance; |
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
T = double(echoModel).*G; |
|
|
114 |
|
|
|
115 |
x = -10*sigma_x:10*sigma_x; %-20 :20 |
|
|
116 |
y = -10*sigma_y:10*sigma_y; %-15 :15 |
|
|
117 |
|
|
|
118 |
hx = (sin(k0*x).*exp(-(x.^2)/(2*sigma_x^2)))'; |
|
|
119 |
hy = exp(-(y.^2)/(2*sigma_y^2)); |
|
|
120 |
|
|
|
121 |
V = imfilter(imfilter(T,hx),hy); |
|
|
122 |
|
|
|
123 |
Vcap = hilbert(V); |
|
|
124 |
|
|
|
125 |
Va = V + (1i*Vcap); |
|
|
126 |
|
|
|
127 |
rfEnvelope = abs(Va); |
|
|
128 |
imageOut = im2uint8(mat2gray(log10(rfEnvelope))); |