I'm using the Matlab function checkerboard
to create a checkerboard and then display it as a circle rather than a square or rectangle. I have written the code below to do this but because my meshgrid seems to be so coarse, when I do imshow(checks)
you can see that the edges of the circle are jagged and not at all smooth. Could anyone tell me how to overcome this problem?
Alternatively, the reason why I have had to set such a small meshgrid is that I need the K
matrix generated from checkerboard
to be really small as I want there to display less of the checkerboard to make it appear as though the squares have a bigger distance. If anybody knows of a way of doing this without creating a meshgrid, that will also work.
This is part of my script that uses Psychtoolbox
so I'm a little bit restricted in what I can do. Once I have created checks
I use it to generate a texture
to draw up to the screen while scaling it up to make it bigger.
Can anyone help?
Code:
K=checkerboard(9); % using Matlab checkerboard function to create a checkerboard
K=K(1:27,1:27); % using a small part of the checkerboard as I want to have a wide distances between the lines
cmap = [0.48 0.48 0.48; 0.54 0.54 0.54]; % colour map to make the colour grey
bw1 = ind2rgb(uint8(K), cmap);
white = 1;
grey = white/2;
rcycles = 8;
% Now we make our checkerboard pattern
xylim = 1;
[x,y] = meshgrid(-1.25:0.0932:1.25,-1.25:0.0932:1.25);
checks = bw1;
circle = x.^2 + y.^2 <= xylim^2;
checks = circle .* checks + grey * ~circle;
imshow(checks);