saving image file using imread

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.

Respuestas (2)

Jan
Jan el 16 de Abr. de 2021

0 votos

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 comentarios

Sumera Yamin
Sumera Yamin el 16 de Abr. de 2021
Editada: Sumera Yamin el 16 de Abr. de 2021
I am not sure. I have two sets of images with 30 images in each set. i took the average of two sets and subtract one from the other. I check the original images are 2D. averaging 30 images added a third dimension.
Rik
Rik el 16 de Abr. de 2021
Do you want to write them as separate images, or do you indeed want a 30-channel image?
Sumera Yamin
Sumera Yamin el 16 de Abr. de 2021
i want to have one image out of both sets achieved by averaging 30 images in each set. subtract the two averaged images to get one image and save this image. just like we do with two vectors (calculate mean of two vectors and subtract one from the other). the averaging and subtracting part i have in my code, how do i save ths final image. Or let me phrase the question in another way. If i have an image type with 3D, how can i save such an image?
Rik
Rik el 16 de Abr. de 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.
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 ?

Iniciar sesión para comentar.

Image Analyst
Image Analyst el 16 de Abr. de 2021

0 votos

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 comentarios

Sumera Yamin
Sumera Yamin el 19 de Abr. de 2021
How i use it? I looked at the document and does not unerstand much.
Image Analyst
Image Analyst el 19 de Abr. de 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
Sumera Yamin el 20 de Abr. de 2021
thanks for pointing it out

Iniciar sesión para comentar.

Categorías

Más información sobre Images en Centro de ayuda y File Exchange.

Preguntada:

el 16 de Abr. de 2021

Comentada:

el 20 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by