[gdal-dev] RFC 15: Band Masks vs #5621

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

[gdal-dev] RFC 15: Band Masks vs #5621

Ivan Lucena-4
That question is probably for Even, Frank or some the developer of drivers that support mask band.

I am working on ticket #5621 and trying to adapt it to the RFC 15 but I am not quite sure that I am getting it right.

In GeoRaster, I can have a bitmap mask band that can be applied to all bands, similar to the concept of GMF_PER_DATASET, I guess. I can also have one bitmap mask band per raster band, but that does not correspond to the others mask flags (GMF_ALL_VALID, GMF_ALHA, GMF_NO_DATA). The data type of my bitmap mask is 1 bit, and there is no implicit connection with Alpha Channel or No Data in a binary bitmap mask, of course.

So if I have a dataset with just one bitmap mask shared between all the bands, I think I can return the flag GMF_PER_DATASET and promote the values to GDT_BYTE. But if I have bitmap masks for each raster bands, then I don't know what flag to return. I might just lie and say "GMF_PER_DATASET" and when the mask is requested I will take care of returning the correct one.

Would that works for others drivers participating on gdal_translate/CreateCopy()?

Of course, if the output driver support just one mask per dataset, there is nothing much we can do.

By the way, are there any driver that support overviews of mask band?

Regards,

Ivan

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

Re: RFC 15: Band Masks vs #5621

Even Rouault-2
Ivan,

You can declare a mask flag to 0 to indicate that this is a per-band mask band.
This is perfectly legal.
You might decide either to set NBITS=1 as metadata to that mask band, or promote
it to full 8 bit (0->0, 1->255).
As far as which format natively supports that, I can't think to any. However the
generic handling in an external .msk file should be able to deal with that, so
hopefully CreateCopy() will generate a .msk file. FYI, as far as internal mask
is concerned, the TIFF specification only allows per-dataset masks (we support
in reading an extension to per-band masks, but we don't generate that)
The generic overview computation code should also be able to generate overviews
of mask band.
You can also play with VRT that should support per-dataset or per-band mask
band.
And you can have a look at autotest/gcore/mask.py to have a sense of what is
supported.

Even

> That question is probably for Even, Frank or some the developer of drivers
> that support mask band.
>
> I am working on ticket #5621 and trying to adapt it to the RFC 15 but I am
> not quite sure that I am getting it right.
>
> In GeoRaster, I can have a bitmap mask band that can be applied to all bands,
> similar to the concept of GMF_PER_DATASET, I guess. I can also have one
> bitmap mask band per raster band, but that does not correspond to the others
> mask flags (GMF_ALL_VALID, GMF_ALHA, GMF_NO_DATA). The data type of my bitmap
> mask is 1 bit, and there is no implicit connection with Alpha Channel or No
> Data in a binary bitmap mask, of course.
>
> So if I have a dataset with just one bitmap mask shared between all the
> bands, I think I can return the flag GMF_PER_DATASET and promote the values
> to GDT_BYTE. But if I have bitmap masks for each raster bands, then I don't
> know what flag to return. I might just lie and say "GMF_PER_DATASET" and when
> the mask is requested I will take care of returning the correct one.
>
> Would that works for others drivers participating on
> gdal_translate/CreateCopy()?
>
> Of course, if the output driver support just one mask per dataset, there is
> nothing much we can do.
>
> By the way, are there any driver that support overviews of mask band?
>
> Regards,
>
> Ivan
>


--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: RFC 15: Band Masks vs #5621

Ivan Lucena-4
Even,
> Date: Wed, 20 Aug 2014 10:28:14 +0200
> From: [hidden email]
> To: [hidden email]
> CC: [hidden email]
> Subject: Re: [gdal-dev] RFC 15: Band Masks vs #5621
>
> Ivan,
>
> You can declare a mask flag to 0 to indicate that this is a per-band mask band.
> This is perfectly legal.

OK. That should works.

Back in 1.6 when I developed that code I think the idea was a little bit different. We tried to support just what GeoTiff would support. I will try that approach.

> You might decide either to set NBITS=1 as metadata to that mask band, or promote
> it to full 8 bit (0->0, 1->255).
> As far as which format natively supports that, I can't think to any. However the
> generic handling in an external .msk file should be able to deal with that, so
> hopefully CreateCopy() will generate a .msk file. FYI, as far as internal mask
> is concerned, the TIFF specification only allows per-dataset masks (we support
> in reading an extension to per-band masks, but we don't generate that)
> The generic overview computation code should also be able to generate overviews
> of mask band.
> You can also play with VRT that should support per-dataset or per-band mask
> band.

I am trying to help a developer how wants to use VRTs as an intermediary between a GeoRaster and a PNG, in order to produce thumbnails. In that case, does the VRT needs to describe the mask band so that the PNG's driver will received the filtered image, with the zeroes regions masked out?

Well, I guess that is something to be tested.

Thanks,

Ivan

> And you can have a look at autotest/gcore/mask.py to have a sense of what is
> supported.

I will check that.

>
> Even
>
> > That question is probably for Even, Frank or some the developer of drivers
> > that support mask band.
> >
> > I am working on ticket #5621 and trying to adapt it to the RFC 15 but I am
> > not quite sure that I am getting it right.
> >
> > In GeoRaster, I can have a bitmap mask band that can be applied to all bands,
> > similar to the concept of GMF_PER_DATASET, I guess. I can also have one
> > bitmap mask band per raster band, but that does not correspond to the others
> > mask flags (GMF_ALL_VALID, GMF_ALHA, GMF_NO_DATA). The data type of my bitmap
> > mask is 1 bit, and there is no implicit connection with Alpha Channel or No
> > Data in a binary bitmap mask, of course.
> >
> > So if I have a dataset with just one bitmap mask shared between all the
> > bands, I think I can return the flag GMF_PER_DATASET and promote the values
> > to GDT_BYTE. But if I have bitmap masks for each raster bands, then I don't
> > know what flag to return. I might just lie and say "GMF_PER_DATASET" and when
> > the mask is requested I will take care of returning the correct one.
> >
> > Would that works for others drivers participating on
> > gdal_translate/CreateCopy()?
> >
> > Of course, if the output driver support just one mask per dataset, there is
> > nothing much we can do.
> >
> > By the way, are there any driver that support overviews of mask band?
> >
> > Regards,
> >
> > Ivan
> >
>
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com

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

Re: RFC 15: Band Masks vs #5621

Even Rouault-2
>
> I am trying to help a developer how wants to use VRTs as an intermediary
> between a GeoRaster and a PNG, in order to produce thumbnails. In that
> case, does the VRT needs to describe the mask band so that the PNG's
> driver will received the filtered image, with the zeroes regions masked
> out?

You need to explicitely declare mask bands in the VRT. See the VRT
documentation for that. But that will just declare the existence of the mask
band, and will not do any processing such as zeroing masked regions.

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: RFC 15: Band Masks vs #5621

Ivan Lucena-4
Hi Even,

> From: [hidden email]

> To: [hidden email]
> Subject: Re: [gdal-dev] RFC 15: Band Masks vs #5621
> Date: Wed, 20 Aug 2014 20:39:29 +0200
> CC: [hidden email]
>
> >
> > I am trying to help a developer how wants to use VRTs as an intermediary
> > between a GeoRaster and a PNG, in order to produce thumbnails. In that
> > case, does the VRT needs to describe the mask band so that the PNG's
> > driver will received the filtered image, with the zeroes regions masked
> > out?
>
> You need to explicitely declare mask bands in the VRT. See the VRT
> documentation for that. But that will just declare the existence of the mask
> band, and will not do any processing such as zeroing masked regions.

You are right. GDAL can copy the mask from one dataset to another, depending on the driver.

But there is no way to indicate that you want the result of the masking, not in the API, not on command line tools.

Maybe we should add that to the wish list.

Regards,

Ivan
 


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

Re: RFC 15: Band Masks vs #5621

Even Rouault-2
Selon Ivan Lucena <[hidden email]>:

> Hi Even,
>
> > From: [hidden email]
> > To: [hidden email]
> > Subject: Re: [gdal-dev] RFC 15: Band Masks vs #5621
> > Date: Wed, 20 Aug 2014 20:39:29 +0200
> > CC: [hidden email]
> >
> > >
> > > I am trying to help a developer how wants to use VRTs as an intermediary
> > > between a GeoRaster and a PNG, in order to produce thumbnails. In that
> > > case, does the VRT needs to describe the mask band so that the PNG's
> > > driver will received the filtered image, with the zeroes regions masked
> > > out?
> >
> > You need to explicitely declare mask bands in the VRT. See the VRT
> > documentation for that. But that will just declare the existence of the
> mask
> > band, and will not do any processing such as zeroing masked regions.
>
> You are right. GDAL can copy the mask from one dataset to another, depending
> on the driver.
>
> But there is no way to indicate that you want the result of the masking, not
> in the API, not on command line tools.
>
> Maybe we should add that to the wish list.

Eh eh seems there is no limit to the wish list ;-)
More seriously, I can imagine this could be done through a new VRT mechanism,
that could be triggered by a new option of gdal_translate

That would be mostly needed for per-band mask, since for per-dataset mask, you
can already trick the mask to be considered as an alpha band (e.g.
gdal_translate -b 1 -b 2 -b 3 -b mask in.tif out.tif will transform a RGB+mask
into a RGBA dataset).
For per-band mask, the value of the pixels that are masked should also be
specified in the VRT syntax.

Even

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev