在Matlab中的某个背景上绘制一个实心的黑色圆圈

Plot a filled black circle on a certain background in Matlab

我有一张只有噪点的 344*344 灰度图像。现在我想在该灰色图像的中间绘制一个实心黑色圆圈作为背景。 我怎样才能做到这一点?我希望我也可以调整图像中间填充的黑色圆圈的大小(比例)。 非常感谢!!

在灰度图像上绘制实心圆

通过计算每个像素距图像中点的距离,可以生成一个圆。通过将每个像素设置为不满足半径阈值的强度 0,可以获得圆的印象。

• 从中心的量级 = (X - X_Midpoint)^2 + (Y - Y_Midpoint)^2

%Adjust for ellipse%
Scaling_Factor_1 = 3;
Scaling_Factor_2 = 1;


%Importing image%
Image = imread('Tiger_Drawing.jpg');
Image = rgb2gray(Image);

%The radius of the filled circle%
Radius = 100;

%Grabbing the dimensions of the image%
[Image_Height,Image_Width] = size(Image);

%Evaluating the midpoint of the image%
Image_Midpoint = [round(Image_Height/2), round(Image_Width/2)];

%Scanning through the pixels of the image%
for Row_Scanner = 1: +1: Image_Height
   for Column_Scanner = 1: +1: Image_Width 
      
      
      
%The pixel coordinate%
Pixel_Coordinate = [Row_Scanner Column_Scanner];
Magnitude_From_Centre = sqrt((abs(Pixel_Coordinate(1,1) - Image_Midpoint(1,1))^2)/Scaling_Factor_1 + abs(Pixel_Coordinate(1,2) - Image_Midpoint(1,2))^2/Scaling_Factor_2);



%If the magnitude from the centre is smaller than the set radius set
%intensity to 0%
if(Magnitude_From_Centre <= Radius) 
    Image(Row_Scanner,Column_Scanner) = 0; 
end 

   end 
end


imshow(Image);

运行 使用 MATLAB R2019b