필터 지우기
필터 지우기

how to design Siemens star pattern like on the image?

조회 수: 25 (최근 30일)
soleils
soleils 2015년 10월 3일
댓글: DGM 2023년 2월 12일
how to create Siemens star pattern using meshgrid and cart2pol?

답변 (4개)

Jack
Jack 2017년 9월 5일
편집: Jack 2017년 9월 5일
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
Image Analyst 2016년 1월 20일
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
Toto
Toto 2016년 1월 21일
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
Toto 2016년 1월 20일
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
Toto
Toto 2016년 1월 21일
이동: DGM 2023년 2월 12일
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
DGM 2023년 2월 12일
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
Jack 2017년 9월 5일
편집: Jack 2017년 9월 5일
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)

Community Treasure Hunt

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

Start Hunting!

Translated by