First time here? Check out the FAQ!

Ask Your Question
1

stack of images tif with C++ & OpenCV

asked Nov 6 '13

lo gravatar image

updated Nov 1 '0

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.

Preview: (hide)

2 answers

Sort by » oldest newest most voted
1

answered Nov 6 '13

Geppertm gravatar image

updated Nov 6 '13

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

Preview: (hide)

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 (Nov 7 '13)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 (Nov 8 '13)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 (Jun 9 '15)edit
0

answered Jun 9 '15

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

Preview: (hide)

Question Tools

Stats

Asked: Nov 6 '13

Seen: 4,460 times

Last updated: Nov 06 '13