Problem in displaying nifti file

5 views (last 30 days)
Mariia Kishchenko
Mariia Kishchenko on 11 Dec 2019
Answered: Subhadeep Koley on 7 Jan 2020
Hello! I'm trying to load a nifti file but when i want to display it, i get this kind of output
Error using images.internal.imageDisplayValidateParams>validateCData (line 118)
Multi-plane image inputs must be RGB images of size MxNx3.
the size of the 3D image is 512x512x161. Then i did that codes:
rgbImage = I(:,:,1:3);
imshow(rgbImage);
Error using images.internal.imageDisplayValidateParams>validateCData (line 131)
RGB images must be uint8, uint16, single, or double.
after i tried to show it with slice number imshow(I(:,:,1,slicenumber)), but didnt wotk either, the ouput i get is just a grey square.
Coud you please help me to find out what am I doing wrong?

Answers (1)

Subhadeep Koley
Subhadeep Koley on 7 Jan 2020
Hi, Mariia you are getting this error because imshow() expects the input to be any one of these (single, double, int8, int16, int32, int64, uint8, uint16, uint32, uint64, logical) types. Type casting the variable rgbImage can solve the issue. Try the code below.
rgbImage = I(:,:,1:3);
rgbImage = rescale(rgbImage);
figure; imshow(double(rgbImage), []); % Type casted to double
Hope this helps!

Community Treasure Hunt

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

Start Hunting!