saving image file using imread
Afficher commentaires plus anciens
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.
Réponses (2)
Jan
le 16 Avr 2021
0 votes
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 commentaires
Sumera Yamin
le 16 Avr 2021
Modifié(e) : Sumera Yamin
le 16 Avr 2021
Rik
le 16 Avr 2021
Do you want to write them as separate images, or do you indeed want a 30-channel image?
Sumera Yamin
le 16 Avr 2021
Rik
le 16 Avr 2021
If you have a list of 2D images (which you have stored in a 3D array for convenience), you should write them as 2D images as well. Only if your 3rd dimension actually encodes something like color should you save the entire array as a hyperspectral/multi-channel image.
Sumera Yamin
le 19 Avr 2021
Image Analyst
le 16 Avr 2021
0 votes
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 commentaires
Sumera Yamin
le 19 Avr 2021
Image Analyst
le 19 Avr 2021
I haven't used it either. Call tech support if you can't figure it out. Sorry but I don't have time to figure it out myself and explain it to you - hope you understand.
Sumera Yamin
le 20 Avr 2021
Catégories
En savoir plus sur Images dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!