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 Comments

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;

Sign in to comment.

Answers (2)

can anyone help please

1 Comment

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.

Sign in to comment.

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 Comment

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.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Asked:

on 2 Jul 2018

Commented:

Rik
on 3 Jul 2018

Community Treasure Hunt

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

Start Hunting!