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

34 views (last 30 days)
soleils on 3 Oct 2015
Commented: DGM on 12 Feb 2023
how to create Siemens star pattern using meshgrid and cart2pol?

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

Image Analyst on 20 Jan 2016
It should be straightforward to adapt my colorwheel demo, attached. Let me know if you can't figure it out. Also let me know if you want a binary one or a sinusoid one.
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:
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?
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
The easy way to avoid this problem is simply to build Z such that the Z array is structured WRT the X,Y arrays. The simple way to do that is to start by defining your grids (or vectors) in rectangular coordinates, and then basing your polar operations off of that. See @Jack's answer for an example.

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)

### Categories

Find more on Nearest Neighbors in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!