MATLAB: White 256×256 image gives me 256x256x3

read imagewhite image

I need a white 256×256 pixels image to use it in an assignment. I tried to make it using Paint and downloaded white images from the internet, but for some reason when I read the image, it stored in a 256x256x3 variable (color image format). I tried different extensions (jpg, png).
What is the reason? I attached the images I used and here is the code to read the image.
img = double(imread('white.jpg'));
[l,w] = size(img);
figure
imshow(uint8(img)) % display the test image
title('Original image')

Best Answer

Try this:
whiteImage = 255 * ones(256, 256, 'uint8');
imwrite(whiteImage, 'White Image.png'); % Save to disk.
Related Question