The aim is to plot a circle using center point and radius in MATLAB without using inbuilt functions for plotting. A black and white image can be represented as a 2 order matrix. The first order is for the rows and the second order is for the columns, the pixel value will determine the color of the pixel based on the grayscale color format.
- We are given with a point and radius. Let the coordinates of the centre point be (x1, y1) and radius be R.
- We find the distance of centre point to every pixel(i, j)th.
dist = sqrt((j-c)^2+(i-r)^2);
- Now if dist=R i.e radius we make that pixel black.
Below is the implementation:
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.