MATLAB: Rotating a circle inside of a checkerboard image

circlecropimage analysisimage processingrotate

Hello everyone! I am wondering how I can rotate a perfect circle inside of a checkerboard image. I understand how to get the original checkerboard image but I am stuck on trying to rotate the inside of the checkerboard as a perfect circle. I have tried to rotate the inner part but it is not a perfect circle. Is there any way to crop the center and set bounds to rotate it as a circle? Or am I approaching this the wrong way. Thanks! The code that I have tried is below:
n=10;
if mod(n, 2) == 0
C = zeros(n + 1, n); % create a matrix having a plus row
C(2 : 2 : end) = 1; % select every second element

C(end, :) = []; % remove the last row from the matrix
else
C = zeros(n, n); % create the matrix
C(2 : 2 : end) = 1; % select every second element
end
imshow(C);
%A=checkerboard(10);
A=C;
angle = 45;
T = @(I) imrotate(I,angle,'bilinear','crop');
TA = T(A);
mask = T(ones(size(A)))==1;
A(mask) = TA(mask);
imshow(A);

Best Answer

You can plot a circle given radius and center of the circle using:
x=x0+rcos(th);
Y=y0+rsin(th);
th = linspace(0,2*pi);
You change your origin (x0,y0) and put it in loop. Circle will move accordingly.
Related Question