Ask Your Question
1

stack of images tif with C++ & OpenCV

asked 2013-11-06 05:16:52 -0600

lo gravatar image

updated 2020-11-01 06:38:43 -0600

Hello,

I am working with stacks of images in tif format. I am programming in C++ and I have 42 slides stored in one tif file. I am trying to read the file with "imread" but it only reads the very first image of the stack.

I would like to know if there is some possibility to read the whole stack with OpenCV or, in other case, I would appreciate any advice on how to read it.

Thank you for your help.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-11-06 06:19:37 -0600

Geppertm gravatar image

updated 2013-11-06 06:40:46 -0600

I think you have to load the tif file into a char(or byte) array.(buf) Then use Mat imdecode(InputArray buf, int flags) Then you will get the size of the first image out of the returnend Mat. With the size of the first image you can delete it from the buffer and you will get the second image.

http://www.awaresystems.be/imaging/tiff/faq.html

edit flag offensive delete link more

Comments

Thank you for your help, I think it is a very good idea! But I don't know how to load the tiff file in a buffer, I am only able to read the first slide, it is like the other 41 slides do not exist, which function should I use to read the whole multiframe image? I am new with image processing...

lo gravatar imagelo ( 2013-11-07 06:24:31 -0600 )edit

Wow, I am so sorry, I just saw the link below your answer, I don't know why I didn't see it the other day. Thank you very much for your help!!

lo gravatar imagelo ( 2013-11-08 04:21:13 -0600 )edit

Hello! I tried this approach several times but I still can't access to the second frame because I cannot find the exact position in the buffer of the next frame. I think TIFF files have an header and I don't know the size of this moreover I don't know if for each next frame there is a new header.

Someone of you knows how to deal with this? Thank you so much in advance!

Best

joetrotta gravatar imagejoetrotta ( 2015-06-09 08:20:06 -0600 )edit
0

answered 2015-06-09 08:19:28 -0600

Hello! I tried this approach several times but I still can't access to the second frame because I cannot find the exact position in the buffer of the next frame. I think TIFF files have an header and I don't know the size of this moreover I don't know if for each next frame there is a new header.

Someone of you knows how to deal with this? Thank you so much in advance!

Best

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-11-06 05:16:52 -0600

Seen: 4,328 times

Last updated: Nov 06 '13