Memory management of Image

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Memory management of Image

Bhaskar Reddy
Hi,

Thank you for your libtiff information.
I need to know how IFD's are arranged in memory.
How data structures are arranged in memory.

I would like to how the image will be stored in Memory.

Thanks, 
Bhaskar

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Memory management of Image

Kemp Watson-2
One of the beauties of open source software is that you can see all that by inspecting the code.
On a more practical level, the idea behind libtiff and similar libraries is that you don’t need to know that detail generally – if it’s very important, code is there, or you can reference the TIFF specifications and “roll your own”.

You may Google “TIFF IFD structure pointers” or anything similar to find published information about TIFF.

W. Kemp Watson


Objective Pathology Services Limited

8250 Lawson Road
Milton, Ontario
Canada  L9T 5C6

www.objectivepathology.com
tel. +1 (416) 970-7284


From: <[hidden email]> on behalf of Bhaskar Reddy <[hidden email]>
Date: Tuesday, October 10, 2017 at 1:43 AM
To: <[hidden email]>
Subject: [Tiff] Memory management of Image

Hi,

Thank you for your libtiff information.
I need to know how IFD's are arranged in memory.
How data structures are arranged in memory.

I would like to how the image will be stored in Memory.

Thanks, 
Bhaskar
_______________________________________________ Tiff mailing list: [hidden email] http://lists.maptools.org/mailman/listinfo/tiff http://www.remotesensing.org/libtiff/

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Memory management of Image

Phil Harvey-2
In reply to this post by Bhaskar Reddy

> Date: Tue, 10 Oct 2017 00:43:11 -0500
> From: Bhaskar Reddy <[hidden email]>
> I need to know how IFD's are arranged in memory.

You can use the ExifTool -htmldump feature to see how the IFD's are organized in an image.  Here is an example of this for a JPEG image, showing the TIFF IFD's of the EXIF information:

http://owl.phy.queensu.ca/~phil/exiftool/htmldump.html

        - Phil


_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Memory management of Image

Bhaskar Reddy
In reply to this post by Kemp Watson-2
Hi Kemp,

Thanks for your advice.
I understood the IFD structure from TIFF 6.0 specifications but I need to know how the 'data' are stored in Memory.

I have seen the libtiff source code but need help in understanding the memory management of IFDs and Data etc..

It would be great if you provide any documents for storing the IFDs/data in memory from computer Hard drive.

Thanks,
Bhaskar.

On Oct 10, 2017 06:54, "Kemp Watson" <[hidden email]> wrote:
One of the beauties of open source software is that you can see all that by inspecting the code.
On a more practical level, the idea behind libtiff and similar libraries is that you don’t need to know that detail generally – if it’s very important, code is there, or you can reference the TIFF specifications and “roll your own”.

You may Google “TIFF IFD structure pointers” or anything similar to find published information about TIFF.

W. Kemp Watson


Objective Pathology Services Limited


www.objectivepathology.com
tel. <a href="tel:(416)%20970-7284" value="+14169707284" target="_blank">+1 (416) 970-7284


From: <[hidden email]> on behalf of Bhaskar Reddy <[hidden email]>
Date: Tuesday, October 10, 2017 at 1:43 AM
To: <[hidden email]>
Subject: [Tiff] Memory management of Image

Hi,

Thank you for your libtiff information.
I need to know how IFD's are arranged in memory.
How data structures are arranged in memory.

I would like to how the image will be stored in Memory.

Thanks, 
Bhaskar
_______________________________________________ Tiff mailing list: [hidden email] http://lists.maptools.org/mailman/listinfo/tiff http://www.remotesensing.org/libtiff/

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Memory management of Image

Bhaskar Reddy
In reply to this post by Phil Harvey-2
Hi Phil,

Thank you for your suggestion.
I am using sxiv tool in ubantu.
I need to add new IFD entry/Tag ID as part of my study. For this, I need to understand how IFDs and Data are stored in memory from the existing libtiff source code.

Much appreciated if you provide any documents for memory management of IFDs using libtiff.

Thanks,
Bhaskar.

On Oct 10, 2017 07:12, "Phil Harvey" <[hidden email]> wrote:

> Date: Tue, 10 Oct 2017 00:43:11 -0500
> From: Bhaskar Reddy <[hidden email]>
> I need to know how IFD's are arranged in memory.

You can use the ExifTool -htmldump feature to see how the IFD's are organized in an image.  Here is an example of this for a JPEG image, showing the TIFF IFD's of the EXIF information:

http://owl.phy.queensu.ca/~phil/exiftool/htmldump.html

        - Phil


_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Memory management of Image

Kemp Watson-2
Why do you need to know the details? Can you not just use TIFFWriteDirectory, TIFFCreateCustomDirectory, TIFFWriteCustomDirectory, etc?

W. Kemp Watson


Objective Pathology Services Limited

8250 Lawson Road
Milton, Ontario
Canada  L9T 5C6

www.objectivepathology.com
tel. +1 (416) 970-7284


From: <[hidden email]> on behalf of Bhaskar Reddy <[hidden email]>
Date: Tuesday, October 10, 2017 at 9:06 AM
To: Phil Harvey <[hidden email]>
Cc: <[hidden email]>
Subject: Re: [Tiff] Memory management of Image

Hi Phil,

Thank you for your suggestion.
I am using sxiv tool in ubantu.
I need to add new IFD entry/Tag ID as part of my study. For this, I need to understand how IFDs and Data are stored in memory from the existing libtiff source code.

Much appreciated if you provide any documents for memory management of IFDs using libtiff.

Thanks,
Bhaskar.

On Oct 10, 2017 07:12, "Phil Harvey" <[hidden email]> wrote:

> Date: Tue, 10 Oct 2017 00:43:11 -0500
> From: Bhaskar Reddy <[hidden email]>
> I need to know how IFD's are arranged in memory.

You can use the ExifTool -htmldump feature to see how the IFD's are organized in an image.  Here is an example of this for a JPEG image, showing the TIFF IFD's of the EXIF information:

http://owl.phy.queensu.ca/~phil/exiftool/htmldump.html

        - Phil


_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
_______________________________________________ Tiff mailing list: [hidden email] http://lists.maptools.org/mailman/listinfo/tiff http://www.remotesensing.org/libtiff/

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Memory management of Image

Bhaskar Reddy
Kemp,

Before adding new IFD entry/Tag ID, we should understand how does it work with existing IFDs. If not, the entire code with new tag ID may not work, if we add blindly.

So, I need to understand it.
Can you please help me in getting tree diagram of libtiff source code particularly with pointer/array structures from root to leaf level if you have any idea.

Thanks,
Bhaskar.

On Thu, Oct 12, 2017 at 7:48 PM, Kemp Watson <[hidden email]> wrote:
Why do you need to know the details? Can you not just use TIFFWriteDirectory, TIFFCreateCustomDirectory, TIFFWriteCustomDirectory, etc?

W. Kemp Watson


Objective Pathology Services Limited


www.objectivepathology.com
tel. <a href="tel:(416)%20970-7284" value="+14169707284" target="_blank">+1 (416) 970-7284


From: <[hidden email]> on behalf of Bhaskar Reddy <[hidden email]>
Date: Tuesday, October 10, 2017 at 9:06 AM
To: Phil Harvey <[hidden email]>
Cc: <[hidden email]>
Subject: Re: [Tiff] Memory management of Image

Hi Phil,

Thank you for your suggestion.
I am using sxiv tool in ubantu.
I need to add new IFD entry/Tag ID as part of my study. For this, I need to understand how IFDs and Data are stored in memory from the existing libtiff source code.

Much appreciated if you provide any documents for memory management of IFDs using libtiff.

Thanks,
Bhaskar.

On Oct 10, 2017 07:12, "Phil Harvey" <[hidden email]> wrote:

> Date: Tue, 10 Oct 2017 00:43:11 -0500
> From: Bhaskar Reddy <[hidden email]>
> I need to know how IFD's are arranged in memory.

You can use the ExifTool -htmldump feature to see how the IFD's are organized in an image.  Here is an example of this for a JPEG image, showing the TIFF IFD's of the EXIF information:

http://owl.phy.queensu.ca/~phil/exiftool/htmldump.html

        - Phil


_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
_______________________________________________ Tiff mailing list: [hidden email] http://lists.maptools.org/mailman/listinfo/tiff http://www.remotesensing.org/libtiff/



--
Bhaskar.

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Memory management of Image

Kemp Watson-2
I’m not sure I understand your question – are you adding images or significant binary data of some sort, or metadata associated with that? Technically, you can put anything you like into either, although IFDs are really meant for image data. Re tags, if your metadata is custom, you can use a private tag, or if you intend to have it reused , you can register the tag with Adobe. there are no restrictions on the content of private tags, you should have no need to know any kind of memory layout beyond your own tag. Your own tag should not interfere with any well-behaved TIFF application, it would simply be ignored by other applications not knowing or caring about it.

W. Kemp Watson


Objective Pathology Services Limited

8250 Lawson Road
Milton, Ontario
Canada  L9T 5C6

www.objectivepathology.com
tel. +1 (416) 970-7284


From: Bhaskar Reddy <[hidden email]>
Date: Thursday, October 12, 2017 at 9:41 PM
To: Watson Kemp <[hidden email]>
Cc: <[hidden email]>
Subject: Re: [Tiff] Memory management of Image

Kemp,

Before adding new IFD entry/Tag ID, we should understand how does it work with existing IFDs. If not, the entire code with new tag ID may not work, if we add blindly.

So, I need to understand it.
Can you please help me in getting tree diagram of libtiff source code particularly with pointer/array structures from root to leaf level if you have any idea.

Thanks,
Bhaskar.

On Thu, Oct 12, 2017 at 7:48 PM, Kemp Watson <[hidden email]> wrote:
Why do you need to know the details? Can you not just use TIFFWriteDirectory, TIFFCreateCustomDirectory, TIFFWriteCustomDirectory, etc?

W. Kemp Watson


Objective Pathology Services Limited


www.objectivepathology.com
tel. <a href="tel:(416)%20970-7284" value="+14169707284" target="_blank">+1 (416) 970-7284


From: <[hidden email]> on behalf of Bhaskar Reddy <[hidden email]>
Date: Tuesday, October 10, 2017 at 9:06 AM
To: Phil Harvey <[hidden email]>
Cc: <[hidden email]>
Subject: Re: [Tiff] Memory management of Image

Hi Phil,

Thank you for your suggestion.
I am using sxiv tool in ubantu.
I need to add new IFD entry/Tag ID as part of my study. For this, I need to understand how IFDs and Data are stored in memory from the existing libtiff source code.

Much appreciated if you provide any documents for memory management of IFDs using libtiff.

Thanks,
Bhaskar.

On Oct 10, 2017 07:12, "Phil Harvey" <[hidden email]> wrote:

> Date: Tue, 10 Oct 2017 00:43:11 -0500
> From: Bhaskar Reddy <[hidden email]>
> I need to know how IFD's are arranged in memory.

You can use the ExifTool -htmldump feature to see how the IFD's are organized in an image.  Here is an example of this for a JPEG image, showing the TIFF IFD's of the EXIF information:

http://owl.phy.queensu.ca/~phil/exiftool/htmldump.html

        - Phil


_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
_______________________________________________ Tiff mailing list: [hidden email]http://lists.maptools.org/mailman/listinfo/tiffhttp://www.remotesensing.org/libtiff/



--
Bhaskar.

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Memory management of Image

Bhaskar Reddy
Thank you, Kemp Watson.

I need to add new "distance data" in image data and need to add new IFD entry (Tag, type, count, offset values) with respective offset address.

~Bhaskar.

On Mon, Oct 16, 2017 at 7:15 PM, Kemp Watson <[hidden email]> wrote:
I’m not sure I understand your question – are you adding images or significant binary data of some sort, or metadata associated with that? Technically, you can put anything you like into either, although IFDs are really meant for image data. Re tags, if your metadata is custom, you can use a private tag, or if you intend to have it reused , you can register the tag with Adobe. there are no restrictions on the content of private tags, you should have no need to know any kind of memory layout beyond your own tag. Your own tag should not interfere with any well-behaved TIFF application, it would simply be ignored by other applications not knowing or caring about it.

W. Kemp Watson


Objective Pathology Services Limited


www.objectivepathology.com
tel. <a href="tel:(416)%20970-7284" value="+14169707284" target="_blank">+1 (416) 970-7284


From: Bhaskar Reddy <[hidden email]>
Date: Thursday, October 12, 2017 at 9:41 PM
To: Watson Kemp <[hidden email]>

Cc: <[hidden email]>
Subject: Re: [Tiff] Memory management of Image

Kemp,

Before adding new IFD entry/Tag ID, we should understand how does it work with existing IFDs. If not, the entire code with new tag ID may not work, if we add blindly.

So, I need to understand it.
Can you please help me in getting tree diagram of libtiff source code particularly with pointer/array structures from root to leaf level if you have any idea.

Thanks,
Bhaskar.

On Thu, Oct 12, 2017 at 7:48 PM, Kemp Watson <[hidden email]> wrote:
Why do you need to know the details? Can you not just use TIFFWriteDirectory, TIFFCreateCustomDirectory, TIFFWriteCustomDirectory, etc?

W. Kemp Watson


Objective Pathology Services Limited


www.objectivepathology.com
tel. <a href="tel:(416)%20970-7284" value="+14169707284" target="_blank">+1 (416) 970-7284


From: <[hidden email]> on behalf of Bhaskar Reddy <[hidden email]>
Date: Tuesday, October 10, 2017 at 9:06 AM
To: Phil Harvey <[hidden email]>
Cc: <[hidden email]>
Subject: Re: [Tiff] Memory management of Image

Hi Phil,

Thank you for your suggestion.
I am using sxiv tool in ubantu.
I need to add new IFD entry/Tag ID as part of my study. For this, I need to understand how IFDs and Data are stored in memory from the existing libtiff source code.

Much appreciated if you provide any documents for memory management of IFDs using libtiff.

Thanks,
Bhaskar.

On Oct 10, 2017 07:12, "Phil Harvey" <[hidden email]> wrote:

> Date: Tue, 10 Oct 2017 00:43:11 -0500
> From: Bhaskar Reddy <[hidden email]>
> I need to know how IFD's are arranged in memory.

You can use the ExifTool -htmldump feature to see how the IFD's are organized in an image.  Here is an example of this for a JPEG image, showing the TIFF IFD's of the EXIF information:

http://owl.phy.queensu.ca/~phil/exiftool/htmldump.html

        - Phil


_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
_______________________________________________ Tiff mailing list: [hidden email]http://lists.maptools.org/mailman/listinfo/tiffhttp://www.remotesensing.org/libtiff/



--
Bhaskar.



--
Bhaskar.

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Memory management of Image

sulau
In reply to this post by Bhaskar Reddy
Dear Bhaskar,

there are two ways to add additional, user defined or custom tags to the TIFF library:
a.)    Patch the libtiff and compile your own, private libtiff version.
b.)    Keep the official libtiff and add the custom tags from your own code by a feature of libtiff, which allows to define new custom directories with your own tags and handle them with libtiff functions.

----- For a.): -----
Look into the libtiff files  
- tiff_dirinfo.c    definition of tiff tags in tiffFields[]; just extend the field at the end with the definition of your tags.
- tiff.h              definition of the tiff tag numbers; you should use unused tags, e.g. above 66000

That’s it.
However, tag definition and correct usage of TIFFSetField() and TIFFGetField() is also not easy, because some unwritten rules apply.
For custom tags, the LibTiff  TiffSetField() and TiffGetField() functions are using va_arg() lists. Thus, there won’t be a compiler error, if the wrong parameter type is used.

Note the "variable promotion" of va_arg() lists:
If an argument has not been declared, the compiler doesn’t have any information needed to perform standard type checking and type conversion for it. Since use of ellipsis doesn’t impose type safety which is one of the major goals of C++, it is sometimes considered a bad programming practice. But at times, you may need to use variable argument function particularly dealing with old C style functions.
Different conversions are applied to functions declared with ellipses than to those functions for which the formal and actual argument types are known
_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|

Re: Memory management of Image

Bhaskar Reddy
Thanks a lot! 

Very useful information.
I will get back to you with my questions when adding tags.

Thanks,
Bhaskar.

On Oct 22, 2017 11:59, <[hidden email]> wrote:
Dear Bhaskar,

there are two ways to add additional, user defined or custom tags to the TIFF library:
a.)    Patch the libtiff and compile your own, private libtiff version.
b.)    Keep the official libtiff and add the custom tags from your own code by a feature of libtiff, which allows to define new custom directories with your own tags and handle them with libtiff functions.

----- For a.): -----
Look into the libtiff files
- tiff_dirinfo.c    definition of tiff tags in tiffFields[]; just extend the field at the end with the definition of your tags.
- tiff.h              definition of the tiff tag numbers; you should use unused tags, e.g. above 66000

That’s it.
However, tag definition and correct usage of TIFFSetField() and TIFFGetField() is also not easy, because some unwritten rules apply.
For custom tags, the LibTiff  TiffSetField() and TiffGetField() functions are using va_arg() lists. Thus, there won’t be a compiler error, if the wrong parameter type is used.

Note the "variable promotion" of va_arg() lists:
If an argument has not been declared, the compiler doesn’t have any information needed to perform standard type checking and type conversion for it. Since use of ellipsis doesn’t impose type safety which is one of the major goals of C++, it is sometimes considered a bad programming practice. But at times, you may need to use variable argument function particularly dealing with old C style functions.
Different conversions are applied to functions declared with ellipses than to those functions for which the formal and actual argument types are known

_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/