Tiff library to export Tiff image uint32

I don't know how exactly to use the tifflib code given by matlab. I have a uint32 image J on matlab and i want to export it in tiff. can anyone tell me how?

3 commentaires

Rik
Rik le 2 Juil 2018
Have a read here and here. Explain what you have tried so far. Show the code.
Have you read the documentation for write?
this is the image that i have on matlab:
J= imopen(I,SE);
this is the code i used
t = Tiff(filename, 'w');
tagstruct.ImageLength = size(A, 1);
tagstruct.ImageWidth = size(A, 2);
tagstruct.Compression = Tiff.Compression.None;
tagstruct.SampleFormat = Tiff.SampleFormat.IEEEFP;
tagstruct.Photometric = Tiff.Photometric.MinIsBlack;
tagstruct.BitsPerSample = 32;
tagstruct.SamplesPerPixel = 1;
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
t.setTag(tagstruct);
t.write(A);
t.close();
tagstruct.SampleFormat = Tiff.SampleFormat.Uint;

Connectez-vous pour commenter.

Réponses (2)

Mirett Boliard
Mirett Boliard le 2 Juil 2018

0 votes

can anyone help please

1 commentaire

Rik
Rik le 2 Juil 2018
Why the impatience? It has only been 20 minutes since you posted the question. People in Europe are probably sleeping or going to sleep, and the US/Canada are still in office hours. For most contributors this is something for their spare time. If you need answers this fast, consider hiring a consultant.
Also, this is not answer. Please only post an answer if you actually solve the question you posed.

Connectez-vous pour commenter.

Rik
Rik le 2 Juil 2018
I generated an example with the line below
A=uint32(randi(uint32(inf),255,255));
Then, running your code resulted in this error:
If SampleFormat is IEEEFP, the image datatype is restricted
to one of the following: single, double.
So your choice of format is incompatible with your choice of input data type. There are two ways to fix this:
  1. Set tagstruct.SampleFormat = Tiff.SampleFormat.Uint;
  2. Cast your data to the single datatype with A=single(A);.

1 commentaire

Rik
Rik le 3 Juil 2018
Did this suggestion solve your problem? If so, please consider marking it as accepted answer. It will make it easier for other people with the same question to find an answer. If this didn't solve your question, please comment with what problems you are still having.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Tags

Commenté :

Rik
le 3 Juil 2018

Community Treasure Hunt

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

Start Hunting!

Translated by