NITF image metadata domain field in GDAL - SUBDATASETS

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

NITF image metadata domain field in GDAL - SUBDATASETS

Alison Luo
I need to extract image data from NITF format metadata
field. I know there is a SUBDATASETS domain field for
this purpose. I used libraries from
http://vterrain.org/Distrib/gdal.html .

But the SUBDATASETS domain is not recognized. Here's
my code:

        GDALAccess access = GA_ReadOnly;
        GDALDataset*  imgDataset = NULL;
        const char* pszFilename =
ASFileSysDisplayStringFromPath(inFileSys, inPath);
        imgDataset = (GDALDataset*)GDALOpen(pszFilename,
access);

        GDALDriver* gDriver = imgDataset->GetDriver();
        const char* str =
gDriver->GetMetadataItem(SUBDATASETS);




      ____________________________________________________________________________________
Luggage? GPS? Comic books?
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz
_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: NITF image metadata domain field in GDAL - SUBDATASETS

Frank Warmerdam
Alison Luo wrote:

> I need to extract image data from NITF format metadata
> field. I know there is a SUBDATASETS domain field for
> this purpose. I used libraries from
> http://vterrain.org/Distrib/gdal.html .
>
> But the SUBDATASETS domain is not recognized. Here's
> my code:
>
> GDALAccess access = GA_ReadOnly;
> GDALDataset*  imgDataset = NULL;
> const char* pszFilename =
> ASFileSysDisplayStringFromPath(inFileSys, inPath);
> imgDataset = (GDALDataset*)GDALOpen(pszFilename,
> access);
>
> GDALDriver* gDriver = imgDataset->GetDriver();
> const char* str =
> gDriver->GetMetadataItem(SUBDATASETS);

Alison,

I'm not exactly clear on what you want to do.

NITF files that contain multiple images will provide
special dataset names to access the specific images via
the SUBDATASETS metadata domain.  But in a normal one-image
NITF file there will be no subdatasets.

What does gdalinfo report for your file?  You might want to try
with the FWTools binaries if the vterrain build does not include
utilities.

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, [hidden email]
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org

_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: NITF image metadata domain field in GDAL - SUBDATASETS

Alison Luo
Hi Frank,

Thank you for the comment. Indeed I discovered that in
a normal one-image NITF file there will be no
subdatasets. In that case, how do I acquire the image
data?

In the addition, it seems the image data is compressed
either as jpeg or jp2k in NITF. How do I pull out the
compress image data using GDAL?

Thanks,
Alison


--- Frank Warmerdam <[hidden email]> wrote:

> Alison Luo wrote:
> > I need to extract image data from NITF format
> metadata
> > field. I know there is a SUBDATASETS domain field
> for
> > this purpose. I used libraries from
> > http://vterrain.org/Distrib/gdal.html .
> >
> > But the SUBDATASETS domain is not recognized.
> Here's
> > my code:
> >
> > GDALAccess access = GA_ReadOnly;
> > GDALDataset*  imgDataset = NULL;
> > const char* pszFilename =
> > ASFileSysDisplayStringFromPath(inFileSys, inPath);
> > imgDataset = (GDALDataset*)GDALOpen(pszFilename,
> > access);
> >
> > GDALDriver* gDriver = imgDataset->GetDriver();
> > const char* str =
> > gDriver->GetMetadataItem(SUBDATASETS);
>
> Alison,
>
> I'm not exactly clear on what you want to do.
>
> NITF files that contain multiple images will provide
> special dataset names to access the specific images
> via
> the SUBDATASETS metadata domain.  But in a normal
> one-image
> NITF file there will be no subdatasets.
>
> What does gdalinfo report for your file?  You might
> want to try
> with the FWTools binaries if the vterrain build does
> not include
> utilities.
>
> Best regards,
> --
>
---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up   | Frank
> Warmerdam, [hidden email]
> light and sound - activate the windows |
> http://pobox.com/~warmerdam
> and watch the world go round - Rush    | President
> OSGeo, http://osgeo.org
>
>



       
____________________________________________________________________________________
Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/
_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: NITF image metadata domain field in GDAL - SUBDATASETS

Frank Warmerdam
Alison Luo wrote:

> Hi Frank,
>
> Thank you for the comment. Indeed I discovered that in
> a normal one-image NITF file there will be no
> subdatasets. In that case, how do I acquire the image
> data?
>
> In the addition, it seems the image data is compressed
> either as jpeg or jp2k in NITF. How do I pull out the
> compress image data using GDAL?

Alison,

If you GDALOpen() an NITF file, the return GDALDataset is
implicitly for the first image in the NITF file.  So just
use normal mechanism (GetRasterBand(1)->RasterIO(), etc) to
access the image data.

JPEG and JPEG2000 decompression should be handled automatically
by GDAL if you are using an appropriately configured and reasonably
recent build of GDAL (ie. 1.4.0 or newer and with the Kakadu or ECW
SDK built in for jpeg2000 support).

You can refer to the GDAL API tutorial for additional details on
general image access.

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, [hidden email]
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org

_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Can GDAL GDALDataset return compressed image data

Alison Luo
I have my own JPEG and JP2K decoder. I do not need
decompressed image data stream acquired from
GDALDataset::RasterIO. I would simply like to get the
JPEG or JP2K compressed image stream from a NITF file
through GDAL. Can this be accomplished?

Thanks,
Alison


       
____________________________________________________________________________________
Get the free Yahoo! toolbar and rest assured with the added security of spyware protection.
http://new.toolbar.yahoo.com/toolbar/features/norton/index.php
_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Can GDAL GDALDataset return compressed image data

Alison Luo
In reply to this post by Frank Warmerdam
I have my own JPEG and JP2K decoder. I do not need
decompressed image data stream acquired from
GDALDataset::RasterIO. I would simply like to get the
JPEG or JP2K compressed image stream from a NITF file
through GDAL. Can this be accomplished?

Thanks,
Alison


       
____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
http://smallbusiness.yahoo.com/webhosting 
_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can GDAL GDALDataset return compressed image data

Ivan Lucena
Alison,

Anyone, Correct me If I am wrong but I don't think that in the GDAL API
there is a function that delivers the haw compressed data block in a
buffer. But if you look at that piece of code:

http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/nitf/nitfdataset.cpp#L908

That is where the NITF JPEG buffer is passed to the GDAL JPEG driver to
be decoded. Then, take a look at the code at:

http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/jpeg/jpgdataset.cpp#L1099

And line 1274 where generic JPEG tables are loaded to make it look like
a JFIF file so that the libjpeg can decode it.

Regards,

Ivan


Alison Luo wrote:

> I have my own JPEG and JP2K decoder. I do not need
> decompressed image data stream acquired from
> GDALDataset::RasterIO. I would simply like to get the
> JPEG or JP2K compressed image stream from a NITF file
> through GDAL. Can this be accomplished?
>
> Thanks,
> Alison
>
>
>        
> ____________________________________________________________________________________
> Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
> http://smallbusiness.yahoo.com/webhosting 
> _______________________________________________
> Gdal-dev mailing list
> [hidden email]
> http://lists.maptools.org/mailman/listinfo/gdal-dev
>
>
_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can GDAL GDALDataset return compressed image data

Alison Luo
Hi Ivan,

Thank you so much for your help. I have more questions
regarding the block of code you referred to in
nitifdataset.cpp. I also took a look of class
NITFSegmentInfo in nitflilb.h:

NITFSegmentInfo has a member hAccess, which is the
NITF image stream. I suppose other pasSegmentInfo
member    
    GUInt32 nSegmentHeaderStart;
    GUInt32 nSegmentHeaderSize;
    GUInt32 nSegmentStart;
    GUInt32 nSegmentSize;
would somehow indicate how to get the encoded jpeg
stream from hAccess? Could you please explain how the
jpeg buffer is filled given this information?

Why doesn't GDAL provide APIs to access encoded image
stream, but only provide API to get raw image stream?

Thanks,
Alison
--- "Lucena, Ivan" <[hidden email]> wrote:

> Alison,
>
> Anyone, Correct me If I am wrong but I don't think
> that in the GDAL API
> there is a function that delivers the haw compressed
> data block in a
> buffer. But if you look at that piece of code:
>
>
http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/nitf/nitfdataset.cpp#L908
>
> That is where the NITF JPEG buffer is passed to the
> GDAL JPEG driver to
> be decoded. Then, take a look at the code at:
>
>
http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/jpeg/jpgdataset.cpp#L1099

>
> And line 1274 where generic JPEG tables are loaded
> to make it look like
> a JFIF file so that the libjpeg can decode it.
>
> Regards,
>
> Ivan
>
>
> Alison Luo wrote:
> > I have my own JPEG and JP2K decoder. I do not need
> > decompressed image data stream acquired from
> > GDALDataset::RasterIO. I would simply like to get
> the
> > JPEG or JP2K compressed image stream from a NITF
> file
> > through GDAL. Can this be accomplished?
> >
> > Thanks,
> > Alison
> >
> >
> >        
> >
>
____________________________________________________________________________________

> > Building a website is a piece of cake. Yahoo!
> Small Business gives you all the tools to get
> online.
> > http://smallbusiness.yahoo.com/webhosting 
> > _______________________________________________
> > Gdal-dev mailing list
> > [hidden email]
> >
> http://lists.maptools.org/mailman/listinfo/gdal-dev
> >
> >
>



       
____________________________________________________________________________________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.
http://tv.yahoo.com/
_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can GDAL GDALDataset return compressed image data

Frank Warmerdam
Alison Luo wrote:
> Hi Ivan,
>
> Thank you so much for your help. I have more questions
> regarding the block of code you referred to in
> nitifdataset.cpp. I also took a look of class
> NITFSegmentInfo in nitflilb.h:
>
> NITFSegmentInfo has a member hAccess, which is the
> NITF image stream.

Alison,

It is a pointer to the NITFImage structure for image segemnts.

 >  I suppose other pasSegmentInfo
> member    
>     GUInt32 nSegmentHeaderStart;
>     GUInt32 nSegmentHeaderSize;
>     GUInt32 nSegmentStart;
>     GUInt32 nSegmentSize;
> would somehow indicate how to get the encoded jpeg
> stream from hAccess? Could you please explain how the
> jpeg buffer is filled given this information?

They are information on where the image header, and image
data chunks are in the file.  So compressed data stream
would consist of nSegmentSize bytes started at byte nSegmentStart
in the file.

> Why doesn't GDAL provide APIs to access encoded image
> stream, but only provide API to get raw image stream?

GDAL does not provide direct access to compressed datastreams
because the purpose of GDAL is to provide a "normalized" view to
different datasets, not to provide low level access.

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, [hidden email]
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org

_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can GDAL GDALDataset return compressed image data

Ivan Lucena
I think that Frank gave you the all answers.

Frank Warmerdam wrote:

> Alison Luo wrote:
>> Hi Ivan,
>>
>> Thank you so much for your help. I have more questions
>> regarding the block of code you referred to in
>> nitifdataset.cpp. I also took a look of class
>> NITFSegmentInfo in nitflilb.h:
>>
>> NITFSegmentInfo has a member hAccess, which is the
>> NITF image stream.
>
> Alison,
>
> It is a pointer to the NITFImage structure for image segemnts.
>
>  >  I suppose other pasSegmentInfo
>> member         GUInt32 nSegmentHeaderStart;
>>     GUInt32 nSegmentHeaderSize;
>>     GUInt32 nSegmentStart;
>>     GUInt32 nSegmentSize;
>> would somehow indicate how to get the encoded jpeg
>> stream from hAccess? Could you please explain how the
>> jpeg buffer is filled given this information?
>
> They are information on where the image header, and image
> data chunks are in the file.  So compressed data stream
> would consist of nSegmentSize bytes started at byte nSegmentStart
> in the file.
>
>> Why doesn't GDAL provide APIs to access encoded image
>> stream, but only provide API to get raw image stream?
>
> GDAL does not provide direct access to compressed datastreams
> because the purpose of GDAL is to provide a "normalized" view to
> different datasets, not to provide low level access.
>
> Best regards,
_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can GDAL GDALDataset return compressed image data

Alison Luo
In reply to this post by Frank Warmerdam
Hi Frank,

I still can not get the correct compressed data stream
using NITFSegmentInfo. I add the offset nSegmentStart
to the pointer hAccess, which should bring me to the
beginning of the compressed data stream. Then I read
nSegmentSize bytes of data from there. But from what I
read in memory, the returned block of data is not
correct. I expect to see the exact jpeg compressed
data returned.

I don't know what's wrong with my workflow. I'm
attaching the sample file I've been using.

By the way, is there any free NITF file viewer for
Windows platform to download?

Thanks,
Alison

--- Frank Warmerdam <[hidden email]> wrote:

> Alison Luo wrote:
> > Hi Ivan,
> >
> > Thank you so much for your help. I have more
> questions
> > regarding the block of code you referred to in
> > nitifdataset.cpp. I also took a look of class
> > NITFSegmentInfo in nitflilb.h:
> >
> > NITFSegmentInfo has a member hAccess, which is the
> > NITF image stream.
>
> Alison,
>
> It is a pointer to the NITFImage structure for image
> segemnts.
>
>  >  I suppose other pasSegmentInfo
> > member    
> >     GUInt32 nSegmentHeaderStart;
> >     GUInt32 nSegmentHeaderSize;
> >     GUInt32 nSegmentStart;
> >     GUInt32 nSegmentSize;
> > would somehow indicate how to get the encoded jpeg
> > stream from hAccess? Could you please explain how
> the
> > jpeg buffer is filled given this information?
>
> They are information on where the image header, and
> image
> data chunks are in the file.  So compressed data
> stream
> would consist of nSegmentSize bytes started at byte
> nSegmentStart
> in the file.
>
> > Why doesn't GDAL provide APIs to access encoded
> image
> > stream, but only provide API to get raw image
> stream?
>
> GDAL does not provide direct access to compressed
> datastreams
> because the purpose of GDAL is to provide a
> "normalized" view to
> different datasets, not to provide low level access.
>
> Best regards,
> --
>
---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up   | Frank
> Warmerdam, [hidden email]
> light and sound - activate the windows |
> http://pobox.com/~warmerdam
> and watch the world go round - Rush    | President
> OSGeo, http://osgeo.org
>
>



      ____________________________________________________________________________________
Shape Yahoo! in your own image.  Join our Network Research Panel today!   http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 


_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev

i_3008a.ntf (28K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Can GDAL GDALDataset return compressed image data

Alison Luo
In reply to this post by Alison Luo
Never mind. I finally got the compressed data!!!
nSegmentStart is the offset from the file handler, not
from the image handler. Once I changed my code to
compute the offset from the file handler, I got the
compressed data correctly.

Alison

--- Alison Luo <[hidden email]> wrote:

> Hi Frank,
>
> I still can not get the correct compressed data
> stream
> using NITFSegmentInfo. I add the offset
> nSegmentStart
> to the pointer hAccess, which should bring me to the
> beginning of the compressed data stream. Then I read
> nSegmentSize bytes of data from there. But from what
> I
> read in memory, the returned block of data is not
> correct. I expect to see the exact jpeg compressed
> data returned.
>
> I don't know what's wrong with my workflow. I'm
> attaching the sample file I've been using.
>
> By the way, is there any free NITF file viewer for
> Windows platform to download?
>
> Thanks,
> Alison
>
> --- Frank Warmerdam <[hidden email]> wrote:
>
> > Alison Luo wrote:
> > > Hi Ivan,
> > >
> > > Thank you so much for your help. I have more
> > questions
> > > regarding the block of code you referred to in
> > > nitifdataset.cpp. I also took a look of class
> > > NITFSegmentInfo in nitflilb.h:
> > >
> > > NITFSegmentInfo has a member hAccess, which is
> the
> > > NITF image stream.
> >
> > Alison,
> >
> > It is a pointer to the NITFImage structure for
> image
> > segemnts.
> >
> >  >  I suppose other pasSegmentInfo
> > > member    
> > >     GUInt32 nSegmentHeaderStart;
> > >     GUInt32 nSegmentHeaderSize;
> > >     GUInt32 nSegmentStart;
> > >     GUInt32 nSegmentSize;
> > > would somehow indicate how to get the encoded
> jpeg
> > > stream from hAccess? Could you please explain
> how
> > the
> > > jpeg buffer is filled given this information?
> >
> > They are information on where the image header,
> and
> > image
> > data chunks are in the file.  So compressed data
> > stream
> > would consist of nSegmentSize bytes started at
> byte
> > nSegmentStart
> > in the file.
> >
> > > Why doesn't GDAL provide APIs to access encoded
> > image
> > > stream, but only provide API to get raw image
> > stream?
> >
> > GDAL does not provide direct access to compressed
> > datastreams
> > because the purpose of GDAL is to provide a
> > "normalized" view to
> > different datasets, not to provide low level
> access.
> >
> > Best regards,
> > --
> >
>
---------------------------------------+--------------------------------------

> > I set the clouds in motion - turn up   | Frank
> > Warmerdam, [hidden email]
> > light and sound - activate the windows |
> > http://pobox.com/~warmerdam
> > and watch the world go round - Rush    | President
> > OSGeo, http://osgeo.org
> >
> >
>
>
>
>      
>
____________________________________________________________________________________
> Shape Yahoo! in your own image.  Join our Network
> Research Panel today!  
>
http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
>
>
>



       
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

How to get NITF image resolution

Alison Luo
In reply to this post by Frank Warmerdam
I need to get the resolution of NITF images. I read
through all the nitf-related code in GDAL source code,
but I do not seem to be able to find the code to get
NITF image resolution.

Thanks,
Alison


       
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/ 
_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: How to get NITF image resolution

Frank Warmerdam
Alison Luo wrote:
> I need to get the resolution of NITF images. I read
> through all the nitf-related code in GDAL source code,
> but I do not seem to be able to find the code to get
> NITF image resolution.

Alison,

The GDALGetGeoTransform() function or GetGeoTransform() method on
the GDALDataset will return an affine transformation mapping pixel/line
coordinates to georeferenced coordinates.  For unrotated (north up)
images the pixel width will be the second entry in this array, and
the pixel height will be the negative of the sixth element of this
array.

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, [hidden email]
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org

_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

NITF viewer

Alison Luo
Is there any free NITF image viewer for Windows to
download? I have a ntf file that I can not decode
using GDAL. I'm wondering if this is a corrupted NITF
file. So I need a NITF viewer to verify.

Thanks,
Alison


       
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/ 
_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: NITF viewer

Ivan Lucena
XnView: http://www.xnview.com/

Alison Luo wrote:

> Is there any free NITF image viewer for Windows to
> download? I have a ntf file that I can not decode
> using GDAL. I'm wondering if this is a corrupted NITF
> file. So I need a NITF viewer to verify.
>
> Thanks,
> Alison
>
>
>        
> ____________________________________________________________________________________
> Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
> http://sims.yahoo.com/ 
> _______________________________________________
> Gdal-dev mailing list
> [hidden email]
> http://lists.maptools.org/mailman/listinfo/gdal-dev
>
>
_______________________________________________
Gdal-dev mailing list
[hidden email]
http://lists.maptools.org/mailman/listinfo/gdal-dev