MATLAB: Error using image Error using image TrueColor – How to plot images created by joining arrays instead of using imread

error truecolor cdata

Hello there, i have a question.
Let's suppose i have a image of 3×3 pixels with only a blue dot on the center.
>> image=imread('dot.bmp')
image(:,:,1) =
255 255 255
255 0 255
255 255 255
image(:,:,2) =
255 255 255
255 162 255
255 255 255
image(:,:,3) =
255 255 255
255 232 255
255 255 255
If i get the arrays separately and join them into an array:
dot(:,:,1) = [255 255 255; 255 0 255; 255 255 255] dot(:,:,2) = [255 255 255; 255 162 255; 255 255 255] dot(:,:,3) = [ 255 255 255; 255 232 255; 255 255 255]
>> image(dot) Error using image Error using image TrueColor CData contains element out of range 0.0 <= value <= 1.0
The question is, what should i do to make it work?
Regards.

Best Answer

image( uint8( dot ) )
should work, although just doing what you put works for me too in R2016b