# Image conversion - raw ultrasound data to convex image

As a project, I'm trying to decipher raw data coming from a medical ultrasound device.

The data contains a 128x1008 matrix. Each one of the 128 columns represents a sensor element. Each row in each column indicates that an object has been detected with certain reflected energy (in a scale of 0-255.)

I'm trying to make the appropriate image, knowing the sensor location are as follows: (with Alpha=0.469 degrees):

As I know what the final image is (it was given to me,) I know that I'm close but I have a few difficulties.

The raw data and the solution:

What I have done so far:

My idea was to start with a black image and represent each one of its pixels with a radius and angle, then for each one of the 128 columns of the raw data, run through all of the black image pixels, and replace those with the appropriate angle with the raw data.

This is the image I get:

I expected those black lines between the raw data, but I have no idea how to deal with them so I could get a clearer image. As you can see, it's close to what I should get but those black lines are to be handled first. I have tried different kinds of filters but to no avail. Any help?

The MATLAB code:

blankImage=zeros(1501,1501); %create blank image
%imshow(blankimage)

%imshow(A)

%we calc the relative raduis (relative to the real pysichal size)
%180mm is 1501 pixels R is 59.739263mm (using trigu-in the pdf) then R_pixels=398.6 pixels
%we go in a loop, for every pixel with raduis bigger then 498.1590765 and with
%angel alpha, we copy the raw data row to the blank image

alpha=0.469;       %degree
%alpha=0.2;       %degree

for row=1:128
raw_data_row=A(:,row);
raw_data_counter=1;
for i=1:size(blankImage)
for j=1:size(blankImage)
%              if (119.7815-alpha*(row-1)-0.2) < teta && teta < (119.7815-alpha*(row-1)+0.2)
if (0.5*alpha+(63-row)*alpha-0.1) < teta && teta < (0.5*alpha+(63-row)*alpha+0.1)
blankImage(y,x)=A(raw_data_counter,row);
if raw_data_counter==1024
break
else
raw_data_counter=raw_data_counter+1;
end
end
end
end
end
end

imshow(blankImage, [0 256])

%Kartezian to Radiel + mideling to coord sys
x_mid=x;
y_mid=y-700;
R=(sqrt(x_mid^2+y_mid^2));
Teta=atand(y_mid/x_mid);
if x_mid<0
Teta=(Teta+180);
else
Teta=(Teta);
end
end
%Radiel to Kartizian + demideling to coord sys
x_mid= round(R*cosd(Teta));
y_mid= round(R*sind(Teta));
x=x_mid;
y=y_mid+700;
if y==0
y=1;
end
if x==0
x=1;
end
end


Each column represents a wedge, like this:

Your program needs to fill the wedge rather than just drawing a line.

For each point on a column, you have to draw an arc rather than a single point.

The width of the arc (in degrees) is given by the number of columns and the viewing angle of the device.

You have to draw arcs along your line of the appropriate length. The length of the arcs (in pixels) depends on the distance from the zero point (the radius.)

Like this:

If you look at the "dots" in your original, comparison image, you will see that they get wider as they get further from the origin.

• thank you for the answer! I will try and let you know Sep 2 '21 at 11:50