Hi, I need to Create a 256X256 image with 8-bit image intensity values, generate three circles in radii of 96, 64, 32 aligned to the center of the image . Fill intensity value 250 to the inner circle (r<32), intensity value of 200 between the first and second circle (32
Prashant Kumar answered .
2025-11-20
m = 256 ; n = 256 ; I = 100*ones(m,n) ; % center of image [X,Y] = meshgrid(1:n,1:m) ; C = [mean(1:n) ,mean(1:m)] ; th = linspace(0,2*pi,m) ; % First circle R1 = 32 ; x1 = C(1)+R1*cos(th) ; y1 = C(2)+R1*sin(th) ; idx1 = inpolygon(X,Y,x1,y1) ; I(idx1) = 250 ; % SEcond circle R2 = 64 ; x2 = C(1)+R2*cos(th) ; y2 = C(2)+R2*sin(th) ; idx2 = inpolygon(X,Y,x2,y2) ; I(logical(idx2-idx1)) = 200 ; % Third circle R3 = 96 ; x2 = C(1)+R3*cos(th) ; y2 = C(2)+R3*sin(th) ; idx3 = inpolygon(X,Y,x2,y2) ; I(logical(idx3-idx2)) = 150 ; % plot imagesc(I)
