image that shades from white at the image edges to black in the image centre

21 vues (au cours des 30 derniers jours)
ck poon
ck poon le 27 Mar 2019
How do i create an image that graduates color continously from light at the edges to black in the centre like a black + in a white background. So far i've only been able to do this :
% make a 2d array of values.
imageData=[]; % set up an empty array
imSize=100;
numRows=imSize;
numCols=imSize;
%populate using a nested loop
for row=[1:numRows]
imageRow=[]; %empty vector for row
for col=[1:numCols]
pixelVal=(row+col)/(imSize*2); % make a pixel val in 0..1
imageRow=[imageRow pixelVal]; %add value for pixel
end
imageData=[imageData; imageRow]; % add row of pixels
end
% display as an image
imshow(imageData);
% save as an image
imwrite(imageData,'test.png');
% load an image
newImageData=imread('test.png');
whos newImageData;

Réponses (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by