MATLAB: How to check if image is two dimensional image or not

image processingImage Processing Toolbox

hi
I have matlab code that edit images, but if this image is two dimension i want to convert it to 3D .. how can i do this please ??

Best Answer

Try this:
if ndims(yourImage) == 2
% It's a 2D image. Convert to 3-D.
yourImage = cat(3, yourImage, yourImage, yourImage);
end