MATLAB Answers

how to design Siemens star pattern like on the image?

18 views (last 30 days)
soleils
soleils on 3 Oct 2015
Edited: Jack on 5 Sep 2017
how to create Siemens star pattern using meshgrid and cart2pol?

  0 Comments

Sign in to comment.

Answers (6)

Image Analyst
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.

  1 Comment

Toto
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? :)

Sign in to comment.


Jack
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

Sign in to comment.


Toto
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?

  0 Comments

Sign in to comment.


Toto
Toto on 21 Jan 2016
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?

  0 Comments

Sign in to comment.


Toto
Toto on 28 Jan 2016
Hey Image Analyst,
could you help me? I still didn't figure out how to continue...

  0 Comments

Sign in to comment.


Jack
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

Sign in to comment.

Sign in to answer this question.