saving image file using imread

2 views (last 30 days)
Sumera Yamin
Sumera Yamin on 16 Apr 2021
Commented: Sumera Yamin on 20 Apr 2021
Hi i try to save an image file but gets the following error. I could not seem to correct it. Any help is appreciated.
imwrite(image,'test.tif');
this is the error
"Writing TIFFs with 30 components is not supported with IMWRITE. Use Tiff instead. Type "help Tiff" for more information.
Error in imwrite (line 472)
feval(fmt_s.write, data, map, filename, paramPairs{:}); "
I tried tosave using other formats like jpg/png then i get following error
"Invalid dimensions for X.
Error in imwrite (line 472)
feval(fmt_s.write, data, map, filename, paramPairs{:}); "
Many thanks.

Answers (2)

Jan
Jan on 16 Apr 2021
The message tells you, that you image has unexpected dimensions. JPG and PNG accept 2D matrices and [M x N x 3] RGB arrays. The 3rd dimension of your image is 30. How did you create it? Why does your image has 30 color channels?
  5 Comments
Sumera Yamin
Sumera Yamin on 19 Apr 2021
Hi i stored the 3D image into 2D image using
Im=imgage(:,:,n)
Im=Im(:,:)
It still gives me the same error. I think i am not doing it correctly. How can i convert a 3D image into 2D image ?

Sign in to comment.


Image Analyst
Image Analyst on 16 Apr 2021
There is a special TIFF class that deals with multi-page tiff images. That's what the error was suggesting you use.
>> doc tiff
  3 Comments
Sumera Yamin
Sumera Yamin on 20 Apr 2021
thanks for pointing it out

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!

Translated by