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

4 views (last 30 days)
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;

Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!