# how to design Siemens star pattern like on the image?

34 views (last 30 days)

Show older comments

how to create Siemens star pattern using meshgrid and cart2pol?

##### 0 Comments

### Answers (4)

Jack
on 5 Sep 2017

Edited: Jack
on 5 Sep 2017

This way you get a sinusoidal as well as a binary Siemens star, don't need the image processing toolbox and it's more intuitive:

r = 256; %px, radius of star

cycles = 36; %number of spokes

[X,Y] = meshgrid(-r:r);

phy = atan2(Y,X) * cycles; %phase at each pixel

int = cos(phy); %relative intensity

sinStar = uint8(int*127.5 + 127.5); %sinusoidal Siemens star

binStar = uint8(zeros(r*2+1));

binStar(int>=0) = 255; %binary Siemens star

##### 0 Comments

Image Analyst
on 20 Jan 2016

##### 1 Comment

Toto
on 21 Jan 2016

Thank you very much! But unfortunately I couldn't figure it out how to draw it b/w. And even less how to draw a sinoidal star.

Could you help me again? :)

Toto
on 20 Jan 2016

I'm also searching for an answer. My idea was to plot a 3D-plot in polar coordinates with:

r=0:0,01:1 %Radius in 100 steps

th = (0:3:360)*pi/180 %theta in 120 steps

z = 255 * (½ + ½ sin((P*th)) %1/2 so that it is only in the positive area, 255 for the grayscale

My idea then is to "look from above" so I only see the r-th-plane and save this picture.

Can anybody help us?

##### 2 Comments

Toto
on 21 Jan 2016

Moved: DGM
on 12 Feb 2023

I used another way. Maybe you could help me with this one as well:

if true

% [r,t]=meshgrid(0:1/10:10, (0:.5:360)*pi/180)

P = 20 % AUFFORDERUNG ZUM EINTIPPEN der Anzahl der schw Balken (=Anzahl Perioden)

Z = 255 .* (0.5 + 0.5 .*sin(P*t)+(pi/2));

[X,Y,Z] = pol2cart(t,r,Z)

colormap(gray)

grid off

star3d = surf(X,Y,Z,'linestyle','none')

view([0 -90])

set(gca,'XTickLabel',[],'YTickLabel',[]);

axis off

end

If i save Z into a Picture I only get stripes (because it isn't in polar coordinates, right?). How can I do it? Any hint?

DGM
on 12 Feb 2023

Jack
on 5 Sep 2017

Edited: Jack
on 5 Sep 2017

This works for a raw binary Siemens Star. It is raw in the sense that there is no anti-aliasing so the edges are truly binary. It uses image processing toolbox function poly2mask to fill triangles given cartesian coordinates of the three corners (x0,y0) (x1,y1) (x2,y2). The result is 'logical' and can be saved and/or converted to a format of choice.

r = 256; %px, radius of star

cycles = 36; %number of spokes (triangles)

a = 2*pi/cycles/2; %angle subtended by 1 spoke

[x,y] = pol2cart(-a/2:a:2*pi-a,r); %coordinates of outer corners

x = [ x(1:2:end); x(2:2:end); zeros(1,length(x)/2) ] + r+1; %(x1;x2;x0)

y = [ y(1:2:end); y(2:2:end); zeros(1,length(y)/2) ] + r+1; %(y1;y2;y0)

star = poly2mask(x(:),y(:),2*r+1,2*r+1); %fills triangles (5x5 subsampling)

##### 0 Comments

### See Also

### Categories

### Products

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!