No background written for images with empty tiles

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

No background written for images with empty tiles

RolandH
Hi All,

Firstly, thank you for the ossim library. I am just getting in to using it and starting to figure it out.

My problem is that I have an input grid (1 band of Float32s) that is 'L' shaped. I have got an image chain to work to turn this into a greyscale tiff, except that the output has some areas that are not written to, apparently containing random data (actually comes out as black & white bands). It looks like this happens when an input tile is empty, so gets short circuited and not passed through to the writer.

The image below shows the problem.

Is there a way to initialise the output image with some background value, or something else I have missed?

This is the code I am using:

        ossimRefPtr<ossimImageHandler> handler = ossimGdalFactory::instance()->open(ossimFilename(argv[2]));
        ossimRefPtr<ossimImageFileWriter> writer = ossimImageWriterFactoryRegistry::instance()->createWriter(ossimString(argv[1]));

        writer->setFilename(ossimFilename(argv[3]));

        ossimRefPtr<ossimImageStatisticsSource> stats = new ossimImageStatisticsSource;
        stats->connectMyInputTo(handler.get());
        stats->computeStatistics();

        double pixmin = stats->getMin()[0];
        double pixmax = stats->getMax()[0];

        ossimRefPtr<ossimImageHistogramSource> histoSource = new ossimImageHistogramSource;
        histoSource->connectMyInputTo(handler.get());
        histoSource->setMinValueOverride(pixmin);
        histoSource->setMaxValueOverride(pixmax);

        ossimRefPtr<ossimHistogramRemapper> histRemapper = new ossimHistogramRemapper;

        ossimRefPtr<ossimIndexToRgbLutFilter> lut = new ossimIndexToRgbLutFilter;
        lut->setLut("lut_grey.kwl");

        ossimRefPtr<ossimImageChain> chain = new ossimImageChain;
        chain->addLast(handler.get());
        chain->insertRight(histRemapper.get(), handler.get());
        chain->insertRight(lut.get(), histRemapper.get());
        writer->connectMyInputTo(0, chain.get());

      histRemapper->setHistogram(histoSource->getHistogram());
      histRemapper->setMinOutputValue(1.0);
      histRemapper->setMaxOutputValue(255.0);
      histRemapper->setStretchMode(ossimHistogramRemapper::LINEAR_ONE_PIECE);

      ossimStdOutProgress progress(0, true);
      writer->addListener(&progress);

      writer->execute();

      writer->removeListener(&progress);





Thanks for your help.

Regards,
Roland


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

David Burken
Hi Roland,

First question, does "ossim-info -i <file>" pick up the correct null value?  Float data is always in question.  I'm guessing it does if you're getting a "blank" tile.

If it doesn't you could do:

// Create overviews, histograms, scan for min, max and set null in dot omd file.
ossim-preproc --null <your_null(like -9999.0> -r -o --ch --compute-min-max <file>

Once you have the correct null it looks like you should just add an ossimScalarRemapper in between the existing chain and the writer. It defaults to 8 bit. That is if you want 8 bit out.  Blank tiles will be written as zero's.  Png writer can add an alpha if you need one.  I think your blank data are the float null which is not what you want.

A good reference for this would be ossim-chipper:
http://trac.osgeo.org/ossim/doxygen/classossimChipperUtil.html
http://trac.osgeo.org/ossim/wiki/ossim-chipper

Hope that helps,
Dave


On 03/08/2015 03:43 AM, Roland Hill wrote:
Hi All,

Firstly, thank you for the ossim library. I am just getting in to using it and starting to figure it out.

My problem is that I have an input grid (1 band of Float32s) that is 'L' shaped. I have got an image chain to work to turn this into a greyscale tiff, except that the output has some areas that are not written to, apparently containing random data (actually comes out as black & white bands). It looks like this happens when an input tile is empty, so gets short circuited and not passed through to the writer.

The image below shows the problem.

Is there a way to initialise the output image with some background value, or something else I have missed?

This is the code I am using:

        ossimRefPtr<ossimImageHandler> handler = ossimGdalFactory::instance()->open(ossimFilename(argv[2]));
        ossimRefPtr<ossimImageFileWriter> writer = ossimImageWriterFactoryRegistry::instance()->createWriter(ossimString(argv[1]));

        writer->setFilename(ossimFilename(argv[3]));

        ossimRefPtr<ossimImageStatisticsSource> stats = new ossimImageStatisticsSource;
        stats->connectMyInputTo(handler.get());
        stats->computeStatistics();

        double pixmin = stats->getMin()[0];
        double pixmax = stats->getMax()[0];

        ossimRefPtr<ossimImageHistogramSource> histoSource = new ossimImageHistogramSource;
        histoSource->connectMyInputTo(handler.get());
        histoSource->setMinValueOverride(pixmin);
        histoSource->setMaxValueOverride(pixmax);

        ossimRefPtr<ossimHistogramRemapper> histRemapper = new ossimHistogramRemapper;

        ossimRefPtr<ossimIndexToRgbLutFilter> lut = new ossimIndexToRgbLutFilter;
        lut->setLut("lut_grey.kwl");

        ossimRefPtr<ossimImageChain> chain = new ossimImageChain;
        chain->addLast(handler.get());
        chain->insertRight(histRemapper.get(), handler.get());
        chain->insertRight(lut.get(), histRemapper.get());
        writer->connectMyInputTo(0, chain.get());

      histRemapper->setHistogram(histoSource->getHistogram());
      histRemapper->setMinOutputValue(1.0);
      histRemapper->setMaxOutputValue(255.0);
      histRemapper->setStretchMode(ossimHistogramRemapper::LINEAR_ONE_PIECE);

      ossimStdOutProgress progress(0, true);
      writer->addListener(&progress);

      writer->execute();

      writer->removeListener(&progress);





Thanks for your help.

Regards,
Roland



------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/


_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

RolandH
Hi Dave,

Thanks for your suggestions.

Yes, the null values are being picked up by ossim-info and I can see
them at breakpoints while debugging.

I've isolated the problem to being that HistogramRemapper supplies a
null pointer from getTile if all the values in the tile are not valid. I
don't think this should be the correct behaviour as the
HistogramRemapper doesn't know what the intention is for null values
further up the chain.

A similar thing is happening in IndexToRGBLutFilter, where all-null
tiles (OSSIM_EMPTY) are not being processed, as neither are null values
in full and partial tiles. In some filters that might be appropriate,
but in this case something has to go into the RGB buffers and it should
probably be a null colour value. I would think that nulls should only be
ignored if there is a 'more valid' alternative.

Anyway, I made a few changes to process all-null tiles in these filters
and propagate null grid values to null rgb pixels and I get the expected
output now.

Maybe I have missed something in how these things are handled in ossim?

Thanks again,

Roland


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

David Burken
Hi Roland,

Oscar's been working on propagating a thread safe getTile in filters.  
That could be the histogram issue.  I will ping him on that.

Take care,
Dave

On 03/08/2015 11:24 PM, Roland Hill wrote:

> Hi Dave,
>
> Thanks for your suggestions.
>
> Yes, the null values are being picked up by ossim-info and I can see
> them at breakpoints while debugging.
>
> I've isolated the problem to being that HistogramRemapper supplies a
> null pointer from getTile if all the values in the tile are not valid.
> I don't think this should be the correct behaviour as the
> HistogramRemapper doesn't know what the intention is for null values
> further up the chain.
>
> A similar thing is happening in IndexToRGBLutFilter, where all-null
> tiles (OSSIM_EMPTY) are not being processed, as neither are null
> values in full and partial tiles. In some filters that might be
> appropriate, but in this case something has to go into the RGB buffers
> and it should probably be a null colour value. I would think that
> nulls should only be ignored if there is a 'more valid' alternative.
>
> Anyway, I made a few changes to process all-null tiles in these
> filters and propagate null grid values to null rgb pixels and I get
> the expected output now.
>
> Maybe I have missed something in how these things are handled in ossim?
>
> Thanks again,
>
> Roland
>
>


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

Oscar Kramer
In reply to this post by RolandH
Hi Roland,

I looked at the code in question and it is unrelated to recent changes I made to the baseline. However, I do see that ossimHistogramRemapper::getTile() would indeed return a null tile because of the:

if ( (tile_status != OSSIM_NULL) && (tile_status != OSSIM_EMPTY) )

Without an "else" to handle those cases. This was a change made by Garrett back in Apr 2014.  I'm pretty surprised this wasn't caught before.

Thanks Roland for the catch. We'll be sure to put the proper handling (leave nulls as nulls) shortly.

Oscar


From: Roland Hill <[hidden email]>
To: David Burken <[hidden email]>; [hidden email]
Sent: Sunday, March 8, 2015 11:24 PM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Dave,

Thanks for your suggestions.

Yes, the null values are being picked up by ossim-info and I can see
them at breakpoints while debugging.

I've isolated the problem to being that HistogramRemapper supplies a
null pointer from getTile if all the values in the tile are not valid. I
don't think this should be the correct behaviour as the
HistogramRemapper doesn't know what the intention is for null values
further up the chain.

A similar thing is happening in IndexToRGBLutFilter, where all-null
tiles (OSSIM_EMPTY) are not being processed, as neither are null values
in full and partial tiles. In some filters that might be appropriate,
but in this case something has to go into the RGB buffers and it should
probably be a null colour value. I would think that nulls should only be
ignored if there is a 'more valid' alternative.

Anyway, I made a few changes to process all-null tiles in these filters
and propagate null grid values to null rgb pixels and I get the expected
output now.

Maybe I have missed something in how these things are handled in ossim?

Thanks again,




Roland


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer



------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

Oscar Kramer
In reply to this post by David Burken
I just committed a fix to ossimHistogramRemapper.
I'll look at IndexToRGBLutFilter next.
Thanks for reporting the bug, Roland.
-Oscar


From: David Burken <[hidden email]>
To: Roland Hill <[hidden email]>; [hidden email]
Sent: Monday, March 9, 2015 2:42 AM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Roland,

Oscar's been working on propagating a thread safe getTile in filters. 
That could be the histogram issue.  I will ping him on that.

Take care,
Dave



On 03/08/2015 11:24 PM, Roland Hill wrote:

> Hi Dave,
>
> Thanks for your suggestions.
>
> Yes, the null values are being picked up by ossim-info and I can see
> them at breakpoints while debugging.
>
> I've isolated the problem to being that HistogramRemapper supplies a
> null pointer from getTile if all the values in the tile are not valid.
> I don't think this should be the correct behaviour as the
> HistogramRemapper doesn't know what the intention is for null values
> further up the chain.
>
> A similar thing is happening in IndexToRGBLutFilter, where all-null
> tiles (OSSIM_EMPTY) are not being processed, as neither are null
> values in full and partial tiles. In some filters that might be
> appropriate, but in this case something has to go into the RGB buffers
> and it should probably be a null colour value. I would think that
> nulls should only be ignored if there is a 'more valid' alternative.
>
> Anyway, I made a few changes to process all-null tiles in these
> filters and propagate null grid values to null rgb pixels and I get
> the expected output now.
>
> Maybe I have missed something in how these things are handled in ossim?
>
> Thanks again,
>
> Roland
>
>


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer



------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

Oscar Kramer
In reply to this post by RolandH
IndexToRGBLutFilter was my bad. Committed fix. Thanks again Roland. Keep'em coming!


From: Roland Hill <[hidden email]>
To: David Burken <[hidden email]>; [hidden email]
Sent: Sunday, March 8, 2015 11:24 PM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Dave,

Thanks for your suggestions.

Yes, the null values are being picked up by ossim-info and I can see
them at breakpoints while debugging.

I've isolated the problem to being that HistogramRemapper supplies a
null pointer from getTile if all the values in the tile are not valid. I
don't think this should be the correct behaviour as the
HistogramRemapper doesn't know what the intention is for null values
further up the chain.

A similar thing is happening in IndexToRGBLutFilter, where all-null
tiles (OSSIM_EMPTY) are not being processed, as neither are null values
in full and partial tiles. In some filters that might be appropriate,
but in this case something has to go into the RGB buffers and it should
probably be a null colour value. I would think that nulls should only be
ignored if there is a 'more valid' alternative.

Anyway, I made a few changes to process all-null tiles in these filters
and propagate null grid values to null rgb pixels and I get the expected
output now.

Maybe I have missed something in how these things are handled in ossim?

Thanks again,




Roland


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer



------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

RolandH
In reply to this post by David Burken
Thanks Dave. I should have mentioned I am using an up to date trunk version.

Cheers,

Roland


--
ROLAND HILL
Director
Four Winds Technology Pty Ltd
Ph/Fax :  +61 (0)2 6366 9425
Mobile :  +61 (0)41 880 7472
[hidden email]

Privacy and Confidentiality Notice
The information contained herein and any attachments are intended solely for the named recipients. It may contain privileged confidential information. If you are not an intended recipient, please delete the message and any attachments then notify the sender of miss-delivery. Any use or disclosure of the contents of either is unauthorised and may be unlawful. All liability for viruses are excluded to the fullest extent permitted by law.

On 09/03/15 17:42, David Burken wrote:
Hi Roland,

Oscar's been working on propagating a thread safe getTile in filters.  That could be the histogram issue.  I will ping him on that.

Take care,
Dave

On 03/08/2015 11:24 PM, Roland Hill wrote:
Hi Dave,

Thanks for your suggestions.

Yes, the null values are being picked up by ossim-info and I can see them at breakpoints while debugging.

I've isolated the problem to being that HistogramRemapper supplies a null pointer from getTile if all the values in the tile are not valid. I don't think this should be the correct behaviour as the HistogramRemapper doesn't know what the intention is for null values further up the chain.

A similar thing is happening in IndexToRGBLutFilter, where all-null tiles (OSSIM_EMPTY) are not being processed, as neither are null values in full and partial tiles. In some filters that might be appropriate, but in this case something has to go into the RGB buffers and it should probably be a null colour value. I would think that nulls should only be ignored if there is a 'more valid' alternative.

Anyway, I made a few changes to process all-null tiles in these filters and propagate null grid values to null rgb pixels and I get the expected output now.

Maybe I have missed something in how these things are handled in ossim?

Thanks again,

Roland





------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

RolandH
In reply to this post by Oscar Kramer
Hi Oscar,

Thanks for the fix to ossimHistogramRemapper. Your changes are working for me.

I changed it to process EMPTY tiles, but I see now that just passing the input tile through results in the same thing (I'm slowly figuring out how things work!).

Cheers,

Roland




--
ROLAND HILL
Director
Four Winds Technology Pty Ltd
Ph/Fax :  +61 (0)2 6366 9425
Mobile :  +61 (0)41 880 7472
[hidden email]

Privacy and Confidentiality Notice
The information contained herein and any attachments are intended solely for the named recipients. It may contain privileged confidential information. If you are not an intended recipient, please delete the message and any attachments then notify the sender of miss-delivery. Any use or disclosure of the contents of either is unauthorised and may be unlawful. All liability for viruses are excluded to the fullest extent permitted by law.

On 10/03/15 01:32, Oscar Kramer wrote:
I just committed a fix to ossimHistogramRemapper.
I'll look at IndexToRGBLutFilter next.
Thanks for reporting the bug, Roland.
-Oscar


From: David Burken [hidden email]
To: Roland Hill [hidden email]; [hidden email]
Sent: Monday, March 9, 2015 2:42 AM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Roland,

Oscar's been working on propagating a thread safe getTile in filters. 
That could be the histogram issue.  I will ping him on that.

Take care,
Dave



On 03/08/2015 11:24 PM, Roland Hill wrote:
> Hi Dave,
>
> Thanks for your suggestions.
>
> Yes, the null values are being picked up by ossim-info and I can see
> them at breakpoints while debugging.
>
> I've isolated the problem to being that HistogramRemapper supplies a
> null pointer from getTile if all the values in the tile are not valid.
> I don't think this should be the correct behaviour as the
> HistogramRemapper doesn't know what the intention is for null values
> further up the chain.
>
> A similar thing is happening in IndexToRGBLutFilter, where all-null
> tiles (OSSIM_EMPTY) are not being processed, as neither are null
> values in full and partial tiles. In some filters that might be
> appropriate, but in this case something has to go into the RGB buffers
> and it should probably be a null colour value. I would think that
> nulls should only be ignored if there is a 'more valid' alternative.
>
> Anyway, I made a few changes to process all-null tiles in these
> filters and propagate null grid values to null rgb pixels and I get
> the expected output now.
>
> Maybe I have missed something in how these things are handled in ossim?
>
> Thanks again,
>
> Roland
>
>


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer




------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

RolandH
In reply to this post by Oscar Kramer
Hi Oscar,

The changes to ossimIndexToRgbLut caused a seg fault for me:

*** Error in `./ossimtest': double free or corruption (!prev): 0x00000000024a1f50 ***

I am guessing it is because the input tile is a 1 band Float32, while the output tile is a 3 band Uint8, so just passing the tile through won't work like it did with ossimHistogramRemapper.

Also, when ossimIndexToRgbLut does process a tile it just ignores null pixels. This is OK if the tile being created has been initialized with the null colour, but at the moment it is initialized with the input tile's float value (or part of it). The diff below also sets the null colour for the new tile.

This works except for the very first tile (which is empty) because ossimImageData::makeBlank also has a sentry to short circuit EMPTY tiles. I can't think why this should be the case, so removed it and all works now. See second diff

I suggest the changes in the diff below.

diff --git a/ossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp b/ossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp
index 0eb357b..8fb5616 100644
--- a/ossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp
+++ b/ossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp
@@ -54,14 +54,13 @@ ossimRefPtr<ossimImageData> ossimIndexToRgbLutFilter::getTile(const ossimIrect&
    ossimRefPtr<ossimImageData> tile = theInputConnection->getTile(tileRect, resLevel);
    if (!tile || !tile->getBuf())
       return 0;
-   if  (tile->getDataObjectStatus() == OSSIM_EMPTY)
-      return tile;
 
    if(!theTile)
    {
       allocate();
       if (!theTile)
          return 0;
+      theTile->setNullPix(0.0);
    }
 
    theTile->setImageRectangle(tileRect);
@@ -74,7 +73,7 @@ ossimRefPtr<ossimImageData> ossimIndexToRgbLutFilter::getTile(const ossimIrect&
 
    ossim_uint32 maxLength = tile->getWidth()*tile->getHeight();
    ossimRgbVector color;
-   const ossimRgbVector null_color (0,0,0);
+   const ossimRgbVector null_color (theTile->getNullPix(0), theTile->getNullPix(1), theTile->getNullPix(2));
    double index;
    std::map<double, ossimRgbVector>::const_iterator lut_entry;
    double null_index = theInputConnection->getNullPixelValue();



---------------------------

diff --git a/ossim/src/ossim/imaging/ossimImageData.cpp b/ossim/src/ossim/imaging/ossimImageData.cpp
index 823b324..e96131f 100644
--- a/ossim/src/ossim/imaging/ossimImageData.cpp
+++ b/ossim/src/ossim/imaging/ossimImageData.cpp
@@ -1190,7 +1190,7 @@ ossimDataObjectStatus ossimImageData::validate(T /* dummyTemplate */ ) const
 
 void ossimImageData::makeBlank()
 {
-   if ( (m_dataBuffer.size() == 0) || (getDataObjectStatus() == OSSIM_EMPTY) )
+   if ( m_dataBuffer.size() == 0 )
    {
       return; // nothing to do...
    }




Cheers,

Roland



--
ROLAND HILL
Director
Four Winds Technology Pty Ltd
Ph/Fax :  +61 (0)2 6366 9425
Mobile :  +61 (0)41 880 7472
[hidden email]

Privacy and Confidentiality Notice
The information contained herein and any attachments are intended solely for the named recipients. It may contain privileged confidential information. If you are not an intended recipient, please delete the message and any attachments then notify the sender of miss-delivery. Any use or disclosure of the contents of either is unauthorised and may be unlawful. All liability for viruses are excluded to the fullest extent permitted by law.


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer

ossimIndexToRgbLut.diff (1K) Download Attachment
ossimImageData.diff (543 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

RolandH
In reply to this post by Oscar Kramer
Oscar,

Then this can provide the short circuit in ossimIndexToRgbLut.



diff --git a/ossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp b/ossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp
index 8fb5616..310c9dc 100644
--- a/ossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp
+++ b/ossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp
@@ -66,6 +66,9 @@ ossimRefPtr<ossimImageData> ossimIndexToRgbLutFilter::getTile(const ossimIrect&
    theTile->setImageRectangle(tileRect);
    theTile->makeBlank();
 
+   if  (tile->getDataObjectStatus() == OSSIM_EMPTY)
+      return theTile;
+
    ossim_uint8* outBuf[3];
    outBuf[0] = (ossim_uint8*)(theTile->getBuf(0));
    outBuf[1] = (ossim_uint8*)(theTile->getBuf(1));

Cheers,

Roland


--
ROLAND HILL
Director
Four Winds Technology Pty Ltd
Ph/Fax :  +61 (0)2 6366 9425
Mobile :  +61 (0)41 880 7472
[hidden email]

Privacy and Confidentiality Notice
The information contained herein and any attachments are intended solely for the named recipients. It may contain privileged confidential information. If you are not an intended recipient, please delete the message and any attachments then notify the sender of miss-delivery. Any use or disclosure of the contents of either is unauthorised and may be unlawful. All liability for viruses are excluded to the fullest extent permitted by law.

On 10/03/15 01:39, Oscar Kramer wrote:
IndexToRGBLutFilter was my bad. Committed fix. Thanks again Roland. Keep'em coming!


From: Roland Hill [hidden email]
To: David Burken [hidden email]; [hidden email]
Sent: Sunday, March 8, 2015 11:24 PM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Dave,

Thanks for your suggestions.

Yes, the null values are being picked up by ossim-info and I can see
them at breakpoints while debugging.

I've isolated the problem to being that HistogramRemapper supplies a
null pointer from getTile if all the values in the tile are not valid. I
don't think this should be the correct behaviour as the
HistogramRemapper doesn't know what the intention is for null values
further up the chain.

A similar thing is happening in IndexToRGBLutFilter, where all-null
tiles (OSSIM_EMPTY) are not being processed, as neither are null values
in full and partial tiles. In some filters that might be appropriate,
but in this case something has to go into the RGB buffers and it should
probably be a null colour value. I would think that nulls should only be
ignored if there is a 'more valid' alternative.

Anyway, I made a few changes to process all-null tiles in these filters
and propagate null grid values to null rgb pixels and I get the expected
output now.

Maybe I have missed something in how these things are handled in ossim?

Thanks again,




Roland


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer




------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer

ossimIndexToRgbLut_2.diff (661 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

Oscar Kramer
In reply to this post by RolandH
RE: ossimIndexToRgbLut -- That's what happens when you commit code without testing... Of course the output tile needs to be 3-band where the input is single band, so what I did is wrong. I just committed fix -- without testing of course. Roland: would you mind checking it out since you have the test case set up already?

Thanks,
Oscar


From: Roland Hill <[hidden email]>
To: Oscar Kramer <[hidden email]>; David Burken <[hidden email]>; "[hidden email]" <[hidden email]>
Sent: Monday, March 9, 2015 7:25 PM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Oscar,

The changes to ossimIndexToRgbLut caused a seg fault for me:

*** Error in `./ossimtest': double free or corruption (!prev): 0x00000000024a1f50 ***

I am guessing it is because the input tile is a 1 band Float32, while the output tile is a 3 band Uint8, so just passing the tile through won't work like it did with ossimHistogramRemapper.

Also, when ossimIndexToRgbLut does process a tile it just ignores null pixels. This is OK if the tile being created has been initialized with the null colour, but at the moment it is initialized with the input tile's float value (or part of it). The diff below also sets the null colour for the new tile.

This works except for the very first tile (which is empty) because ossimImageData::makeBlank also has a sentry to short circuit EMPTY tiles. I can't think why this should be the case, so removed it and all works now. See second diff

I suggest the changes in the diff below.

diff --git a/ossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp b/ossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp
index 0eb357b..8fb5616 100644
--- a/ossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp
+++ b/ossim/src/ossim/imaging/ossimIndexToRgbLutFilter.cpp
@@ -54,14 +54,13 @@ ossimRefPtr<ossimImageData> ossimIndexToRgbLutFilter::getTile(const ossimIrect&
    ossimRefPtr<ossimImageData> tile = theInputConnection->getTile(tileRect, resLevel);
    if (!tile || !tile->getBuf())
       return 0;
-   if  (tile->getDataObjectStatus() == OSSIM_EMPTY)
-      return tile;
 
    if(!theTile)
    {
       allocate();
       if (!theTile)
          return 0;
+      theTile->setNullPix(0.0);
    }
 
    theTile->setImageRectangle(tileRect);
@@ -74,7 +73,7 @@ ossimRefPtr<ossimImageData> ossimIndexToRgbLutFilter::getTile(const ossimIrect&
 
    ossim_uint32 maxLength = tile->getWidth()*tile->getHeight();
    ossimRgbVector color;
-   const ossimRgbVector null_color (0,0,0);
+   const ossimRgbVector null_color (theTile->getNullPix(0), theTile->getNullPix(1), theTile->getNullPix(2));
    double index;
    std::map<double, ossimRgbVector>::const_iterator lut_entry;
    double null_index = theInputConnection->getNullPixelValue();



---------------------------

diff --git a/ossim/src/ossim/imaging/ossimImageData.cpp b/ossim/src/ossim/imaging/ossimImageData.cpp
index 823b324..e96131f 100644
--- a/ossim/src/ossim/imaging/ossimImageData.cpp
+++ b/ossim/src/ossim/imaging/ossimImageData.cpp
@@ -1190,7 +1190,7 @@ ossimDataObjectStatus ossimImageData::validate(T /* dummyTemplate */ ) const
 
 void ossimImageData::makeBlank()
 {
-   if ( (m_dataBuffer.size() == 0) || (getDataObjectStatus() == OSSIM_EMPTY) )
+   if ( m_dataBuffer.size() == 0 )
    {
       return; // nothing to do...
    }




Cheers,




Roland




--
ROLAND HILL
Director
Four Winds Technology Pty Ltd
Ph/Fax :  +61 (0)2 6366 9425
Mobile :  +61 (0)41 880 7472
[hidden email]

Privacy and Confidentiality Notice
The information contained herein and any attachments are intended solely for the named recipients. It may contain privileged confidential information. If you are not an intended recipient, please delete the message and any attachments then notify the sender of miss-delivery. Any use or disclosure of the contents of either is unauthorised and may be unlawful. All liability for viruses are excluded to the fullest extent permitted by law.




------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

RolandH
In reply to this post by RolandH
Hi Oscar,

No, I am remapping (0,0,0) to (255,255,255). The red coloured nulls are a bug.

The ImageData constructor sets the null value to 0, but then IndexToRgbLutFilter calls ImageDataFactory->create(...). This involves resetting the null value to the same as the input tile null (see below). So we are setting the null value for a UINT8 band to -999999 in this case. ossimImageData::makeBlank() then does "      const T NP = static_cast<T>(m_nullPixelValue[band]); " which ends up with unexpected values. That's why it is necessary to to put in the "theTile->setNullPix(0.0);" line as well.


ossimRefPtr<ossimImageData> ossimImageDataFactory::create(
   ossimSource* owner,
   ossim_uint32 bands,
   ossimImageSource* inputSource)const
{
   ossimRefPtr<ossimImageData> result = 0;

   if(inputSource)
   {
      ossimScalarType scalar = inputSource->getOutputScalarType();
      ossim_uint32 width  = inputSource->getTileWidth();
      ossim_uint32 height = inputSource->getTileHeight();

      result = create(owner, scalar, bands, width, height);
      if ( result.valid() )
      {
         for(ossim_uint32 band = 0; band < bands; ++band)
         {
            result->setMinPix(inputSource->getMinPixelValue(band),   band);
            result->setMaxPix(inputSource->getMaxPixelValue(band),   band);
            result->setNullPix(inputSource->getNullPixelValue(band), band);              < ----------------------
         }
      }
   }
   else
   {
      ossimNotify(ossimNotifyLevel_WARN)
         << "ossimImageDataFactory::create ERROR:"
         << "\nNULL input source!" << std::endl;
   }
  
   return result;
}

Cheers,

Roland


--
ROLAND HILL
Director
Four Winds Technology Pty Ltd
Ph/Fax :  +61 (0)2 6366 9425
Mobile :  +61 (0)41 880 7472
[hidden email]

Privacy and Confidentiality Notice
The information contained herein and any attachments are intended solely for the named recipients. It may contain privileged confidential information. If you are not an intended recipient, please delete the message and any attachments then notify the sender of miss-delivery. Any use or disclosure of the contents of either is unauthorised and may be unlawful. All liability for viruses are excluded to the fullest extent permitted by law.

On 12/03/15 01:09, Oscar Kramer wrote:
OK I put in:

   const ossimRgbVector null_color (theTile->getNullPix(0), theTile->getNullPix(1), theTile->getNullPix(2));
... to make sure nonzero null values are properly handled. You can update. Thanks for testing.

BTW -- In the example you sent showing red border. You meant you were remapping (0,0,0) to (255, 0, 0) correct? Otherwise I don't understand what is happening.

-Oscar

From: Roland Hill [hidden email]
To: Oscar Kramer [hidden email]; David Burken [hidden email]; [hidden email] [hidden email]
Sent: Tuesday, March 10, 2015 6:12 PM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Oscar,

That fixes the crash and the short circuit tiles work too. However, it leaves an erroneous pixel colour in null pixels within partial tiles, in this case red. See the example below - note that I have remapped (0,0,0) to (255, 255,255).



The diff I sent yesterday addresses this by setting the new tile background to 0,0,0.

With this fix the output is as expected, below.





Cheers,

Roland





------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

Oscar Kramer
Hi Roland,

I looked into it a bit. I'm not seeing the behavior you describe. In IndexToRgbLutFilter::allocate() (where theTile is created), the ImageDataFactory::create() is called with source and inputSource both set to this (the RGB filter), not to the filter's input source. A bit confusing there but if you trace into that allocate() and subsequent factory create(), you should see the correct scalar type being referenced.  The factory uses a scalar type of UINT8 (UCHAR) to assign a null pixel of 0. 

I'm leery of hardcoding a null pixel to 0 in the filter itself. That's not where it should be. The question is: why are you seeing a nonzero null pixel for theTile? That should not happen.

-Oscar


From: Roland Hill <[hidden email]>
To: Oscar Kramer <[hidden email]>; David Burken <[hidden email]>; "[hidden email]" <[hidden email]>
Sent: Wednesday, March 11, 2015 4:27 PM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Oscar,

No, I am remapping (0,0,0) to (255,255,255). The red coloured nulls are a bug.

The ImageData constructor sets the null value to 0, but then IndexToRgbLutFilter calls ImageDataFactory->create(...). This involves resetting the null value to the same as the input tile null (see below). So we are setting the null value for a UINT8 band to -999999 in this case. ossimImageData::makeBlank() then does "      const T NP = static_cast<T>(m_nullPixelValue[band]); " which ends up with unexpected values. That's why it is necessary to to put in the "theTile->setNullPix(0.0);" line as well.


ossimRefPtr<ossimImageData> ossimImageDataFactory::create(
   ossimSource* owner,
   ossim_uint32 bands,
   ossimImageSource* inputSource)const
{
   ossimRefPtr<ossimImageData> result = 0;

   if(inputSource)
   {
      ossimScalarType scalar = inputSource->getOutputScalarType();
      ossim_uint32 width  = inputSource->getTileWidth();
      ossim_uint32 height = inputSource->getTileHeight();

      result = create(owner, scalar, bands, width, height);
      if ( result.valid() )
      {
         for(ossim_uint32 band = 0; band < bands; ++band)
         {
            result->setMinPix(inputSource->getMinPixelValue(band),   band);
            result->setMaxPix(inputSource->getMaxPixelValue(band),   band);
            result->setNullPix(inputSource->getNullPixelValue(band), band);              < ----------------------
         }
      }
   }
   else
   {
      ossimNotify(ossimNotifyLevel_WARN)
         << "ossimImageDataFactory::create ERROR:"
         << "\nNULL input source!" << std::endl;
   }
  
   return result;
}

Cheers,

Roland


--
ROLAND HILL
Director
Four Winds Technology Pty Ltd
Ph/Fax :  +61 (0)2 6366 9425
Mobile :  +61 (0)41 880 7472
[hidden email]

Privacy and Confidentiality Notice
The information contained herein and any attachments are intended solely for the named recipients. It may contain privileged confidential information. If you are not an intended recipient, please delete the message and any attachments then notify the sender of miss-delivery. Any use or disclosure of the contents of either is unauthorised and may be unlawful. All liability for viruses are excluded to the fullest extent permitted by law.



On 12/03/15 01:09, Oscar Kramer wrote:
OK I put in:

   const ossimRgbVector null_color (theTile->getNullPix(0), theTile->getNullPix(1), theTile->getNullPix(2));
... to make sure nonzero null values are properly handled. You can update. Thanks for testing.

BTW -- In the example you sent showing red border. You meant you were remapping (0,0,0) to (255, 0, 0) correct? Otherwise I don't understand what is happening.

-Oscar

From: Roland Hill [hidden email]
To: Oscar Kramer [hidden email]; David Burken [hidden email]; [hidden email] [hidden email]
Sent: Tuesday, March 10, 2015 6:12 PM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Oscar,

That fixes the crash and the short circuit tiles work too. However, it leaves an erroneous pixel colour in null pixels within partial tiles, in this case red. See the example below - note that I have remapped (0,0,0) to (255, 255,255).



The diff I sent yesterday addresses this by setting the new tile background to 0,0,0.

With this fix the output is as expected, below.





Cheers,

Roland







------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

RolandH
Hi Oscar,

I agree with you on those points. However, ossimImageDataFactory::create(this,3,this) then goes on to call result->setNullPix(inputSource->getNullPixelValue(band), band);, which gets it's null pixel value from getInput(0) of the IndexToRgbLut, which is a 1 band Float32 histogram remapper.


double ossimImageSource::getNullPixelValue(ossim_uint32 band)const
{
   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                               getInput(0));
   if(inter)
   {
      return inter->getNullPixelValue(band);
   }
  
   return ossim::defaultNull(getOutputScalarType());
}


So the uint8 null pixel value of the IndexToRgbLut filter is set to a value derived from a float32 (-999999 in this case).

When I break in and examine inputSource->getNullPixelValue(band), I can see the -999999 value.

I also agree that hard coding the null pixel value of IndexToRgbLut is not good. Once this issue is sorted out I was going to suggest a IndexToRgbLut->setOutputNull(uint8, unit8, uint8) method.

I can arrange to send the input data and a my test program if you like. The data is not public though.

Cheers,

Roland



--
ROLAND HILL
Director
Four Winds Technology Pty Ltd
Ph/Fax :  +61 (0)2 6366 9425
Mobile :  +61 (0)41 880 7472
[hidden email]

Privacy and Confidentiality Notice
The information contained herein and any attachments are intended solely for the named recipients. It may contain privileged confidential information. If you are not an intended recipient, please delete the message and any attachments then notify the sender of miss-delivery. Any use or disclosure of the contents of either is unauthorised and may be unlawful. All liability for viruses are excluded to the fullest extent permitted by law.

On 13/03/15 04:03, Oscar Kramer wrote:
Hi Roland,

I looked into it a bit. I'm not seeing the behavior you describe. In IndexToRgbLutFilter::allocate() (where theTile is created), the ImageDataFactory::create() is called with source and inputSource both set to this (the RGB filter), not to the filter's input source. A bit confusing there but if you trace into that allocate() and subsequent factory create(), you should see the correct scalar type being referenced.  The factory uses a scalar type of UINT8 (UCHAR) to assign a null pixel of 0. 

I'm leery of hardcoding a null pixel to 0 in the filter itself. That's not where it should be. The question is: why are you seeing a nonzero null pixel for theTile? That should not happen.

-Oscar


From: Roland Hill [hidden email]
To: Oscar Kramer [hidden email]; David Burken [hidden email]; [hidden email] [hidden email]
Sent: Wednesday, March 11, 2015 4:27 PM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Oscar,

No, I am remapping (0,0,0) to (255,255,255). The red coloured nulls are a bug.

The ImageData constructor sets the null value to 0, but then IndexToRgbLutFilter calls ImageDataFactory->create(...). This involves resetting the null value to the same as the input tile null (see below). So we are setting the null value for a UINT8 band to -999999 in this case. ossimImageData::makeBlank() then does "      const T NP = static_cast<T>(m_nullPixelValue[band]); " which ends up with unexpected values. That's why it is necessary to to put in the "theTile->setNullPix(0.0);" line as well.


ossimRefPtr<ossimImageData> ossimImageDataFactory::create(
   ossimSource* owner,
   ossim_uint32 bands,
   ossimImageSource* inputSource)const
{
   ossimRefPtr<ossimImageData> result = 0;

   if(inputSource)
   {
      ossimScalarType scalar = inputSource->getOutputScalarType();
      ossim_uint32 width  = inputSource->getTileWidth();
      ossim_uint32 height = inputSource->getTileHeight();

      result = create(owner, scalar, bands, width, height);
      if ( result.valid() )
      {
         for(ossim_uint32 band = 0; band < bands; ++band)
         {
            result->setMinPix(inputSource->getMinPixelValue(band),   band);
            result->setMaxPix(inputSource->getMaxPixelValue(band),   band);
            result->setNullPix(inputSource->getNullPixelValue(band), band);              < ----------------------
         }
      }
   }
   else
   {
      ossimNotify(ossimNotifyLevel_WARN)
         << "ossimImageDataFactory::create ERROR:"
         << "\nNULL input source!" << std::endl;
   }
  
   return result;
}

Cheers,

Roland


--
ROLAND HILL
Director
Four Winds Technology Pty Ltd
Ph/Fax :  +61 (0)2 6366 9425
Mobile :  +61 (0)41 880 7472
[hidden email]

Privacy and Confidentiality Notice
The information contained herein and any attachments are intended solely for the named recipients. It may contain privileged confidential information. If you are not an intended recipient, please delete the message and any attachments then notify the sender of miss-delivery. Any use or disclosure of the contents of either is unauthorised and may be unlawful. All liability for viruses are excluded to the fullest extent permitted by law.



On 12/03/15 01:09, Oscar Kramer wrote:
OK I put in:

   const ossimRgbVector null_color (theTile->getNullPix(0), theTile->getNullPix(1), theTile->getNullPix(2));
... to make sure nonzero null values are properly handled. You can update. Thanks for testing.

BTW -- In the example you sent showing red border. You meant you were remapping (0,0,0) to (255, 0, 0) correct? Otherwise I don't understand what is happening.

-Oscar

From: Roland Hill [hidden email]
To: Oscar Kramer [hidden email]; David Burken [hidden email]; [hidden email] [hidden email]
Sent: Tuesday, March 10, 2015 6:12 PM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Oscar,

That fixes the crash and the short circuit tiles work too. However, it leaves an erroneous pixel colour in null pixels within partial tiles, in this case red. See the example below - note that I have remapped (0,0,0) to (255, 255,255).



The diff I sent yesterday addresses this by setting the new tile background to 0,0,0.

With this fix the output is as expected, below.





Cheers,

Roland








------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

Oscar Kramer
OK, I see the problem. There is an override in ossimIndexToRgbLutFilter for getNullPixelValue() but not for getNullPixelValue(band) as it should. If that had been in place correctly, then it would have intercepted the call to the default implementation (querying the input source for the null pixel)and would have returned 0. I am changing the ossimIndexToRgbLutFilter.h file to:

       virtual double getNullPixelValue(ossim_uint32 band=0) const;  // this just returns 0

Actually, we should be able to handle any null pixel value.But at least this will fix your problem (I believe). Thanks for pointing it out. It takes a while when you're 12 hours out of phase!

Oscar


From: Roland Hill <[hidden email]>
To: Oscar Kramer <[hidden email]>; David Burken <[hidden email]>; "[hidden email]" <[hidden email]>
Sent: Thursday, March 12, 2015 6:52 PM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Oscar,

I agree with you on those points. However, ossimImageDataFactory::create(this,3,this) then goes on to call result->setNullPix(inputSource->getNullPixelValue(band), band);, which gets it's null pixel value from getInput(0) of the IndexToRgbLut, which is a 1 band Float32 histogram remapper.


double ossimImageSource::getNullPixelValue(ossim_uint32 band)const
{
   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                               getInput(0));
   if(inter)
   {
      return inter->getNullPixelValue(band);
   }
  
   return ossim::defaultNull(getOutputScalarType());
}


So the uint8 null pixel value of the IndexToRgbLut filter is set to a value derived from a float32 (-999999 in this case).

When I break in and examine inputSource->getNullPixelValue(band), I can see the -999999 value.

I also agree that hard coding the null pixel value of IndexToRgbLut is not good. Once this issue is sorted out I was going to suggest a IndexToRgbLut->setOutputNull(uint8, unit8, uint8) method.

I can arrange to send the input data and a my test program if you like. The data is not public though.

Cheers,

Roland



--
ROLAND HILL
Director
Four Winds Technology Pty Ltd
Ph/Fax :  +61 (0)2 6366 9425
Mobile :  +61 (0)41 880 7472
[hidden email]

Privacy and Confidentiality Notice
The information contained herein and any attachments are intended solely for the named recipients. It may contain privileged confidential information. If you are not an intended recipient, please delete the message and any attachments then notify the sender of miss-delivery. Any use or disclosure of the contents of either is unauthorised and may be unlawful. All liability for viruses are excluded to the fullest extent permitted by law.



On 13/03/15 04:03, Oscar Kramer wrote:
Hi Roland,

I looked into it a bit. I'm not seeing the behavior you describe. In IndexToRgbLutFilter::allocate() (where theTile is created), the ImageDataFactory::create() is called with source and inputSource both set to this (the RGB filter), not to the filter's input source. A bit confusing there but if you trace into that allocate() and subsequent factory create(), you should see the correct scalar type being referenced.  The factory uses a scalar type of UINT8 (UCHAR) to assign a null pixel of 0. 

I'm leery of hardcoding a null pixel to 0 in the filter itself. That's not where it should be. The question is: why are you seeing a nonzero null pixel for theTile? That should not happen.

-Oscar


From: Roland Hill [hidden email]
To: Oscar Kramer [hidden email]; David Burken [hidden email]; [hidden email] [hidden email]
Sent: Wednesday, March 11, 2015 4:27 PM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Oscar,

No, I am remapping (0,0,0) to (255,255,255). The red coloured nulls are a bug.

The ImageData constructor sets the null value to 0, but then IndexToRgbLutFilter calls ImageDataFactory->create(...). This involves resetting the null value to the same as the input tile null (see below). So we are setting the null value for a UINT8 band to -999999 in this case. ossimImageData::makeBlank() then does "      const T NP = static_cast<T>(m_nullPixelValue[band]); " which ends up with unexpected values. That's why it is necessary to to put in the "theTile->setNullPix(0.0);" line as well.


ossimRefPtr<ossimImageData> ossimImageDataFactory::create(
   ossimSource* owner,
   ossim_uint32 bands,
   ossimImageSource* inputSource)const
{
   ossimRefPtr<ossimImageData> result = 0;

   if(inputSource)
   {
      ossimScalarType scalar = inputSource->getOutputScalarType();
      ossim_uint32 width  = inputSource->getTileWidth();
      ossim_uint32 height = inputSource->getTileHeight();

      result = create(owner, scalar, bands, width, height);
      if ( result.valid() )
      {
         for(ossim_uint32 band = 0; band < bands; ++band)
         {
            result->setMinPix(inputSource->getMinPixelValue(band),   band);
            result->setMaxPix(inputSource->getMaxPixelValue(band),   band);
            result->setNullPix(inputSource->getNullPixelValue(band), band);              < ----------------------
         }
      }
   }
   else
   {
      ossimNotify(ossimNotifyLevel_WARN)
         << "ossimImageDataFactory::create ERROR:"
         << "\nNULL input source!" << std::endl;
   }
  
   return result;
}

Cheers,

Roland


--
ROLAND HILL
Director
Four Winds Technology Pty Ltd
Ph/Fax :  +61 (0)2 6366 9425
Mobile :  +61 (0)41 880 7472
[hidden email]

Privacy and Confidentiality Notice
The information contained herein and any attachments are intended solely for the named recipients. It may contain privileged confidential information. If you are not an intended recipient, please delete the message and any attachments then notify the sender of miss-delivery. Any use or disclosure of the contents of either is unauthorised and may be unlawful. All liability for viruses are excluded to the fullest extent permitted by law.



On 12/03/15 01:09, Oscar Kramer wrote:
OK I put in:

   const ossimRgbVector null_color (theTile->getNullPix(0), theTile->getNullPix(1), theTile->getNullPix(2));
... to make sure nonzero null values are properly handled. You can update. Thanks for testing.

BTW -- In the example you sent showing red border. You meant you were remapping (0,0,0) to (255, 0, 0) correct? Otherwise I don't understand what is happening.

-Oscar

From: Roland Hill [hidden email]
To: Oscar Kramer [hidden email]; David Burken [hidden email]; [hidden email] [hidden email]
Sent: Tuesday, March 10, 2015 6:12 PM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Oscar,

That fixes the crash and the short circuit tiles work too. However, it leaves an erroneous pixel colour in null pixels within partial tiles, in this case red. See the example below - note that I have remapped (0,0,0) to (255, 255,255).



The diff I sent yesterday addresses this by setting the new tile background to 0,0,0.

With this fix the output is as expected, below.





Cheers,

Roland








------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/

_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer



------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer
Reply | Threaded
Open this post in threaded view
|

Re: No background written for images with empty tiles

RolandH
Hi Oscar,

Ah, didn't think of that. Thanks for figuring it out. I'll give it a try later today.

Cheers,

Roland


--
ROLAND HILL
Director
Four Winds Technology Pty Ltd
Ph/Fax :  +61 (0)2 6366 9425
Mobile :  +61 (0)41 880 7472
[hidden email]

Privacy and Confidentiality Notice
The information contained herein and any attachments are intended solely for the named recipients. It may contain privileged confidential information. If you are not an intended recipient, please delete the message and any attachments then notify the sender of miss-delivery. Any use or disclosure of the contents of either is unauthorised and may be unlawful. All liability for viruses are excluded to the fullest extent permitted by law.

On 14/03/15 00:43, Oscar Kramer wrote:
OK, I see the problem. There is an override in ossimIndexToRgbLutFilter for getNullPixelValue() but not for getNullPixelValue(band) as it should. If that had been in place correctly, then it would have intercepted the call to the default implementation (querying the input source for the null pixel)and would have returned 0. I am changing the ossimIndexToRgbLutFilter.h file to:

       virtual double getNullPixelValue(ossim_uint32 band=0) const;  // this just returns 0

Actually, we should be able to handle any null pixel value.But at least this will fix your problem (I believe). Thanks for pointing it out. It takes a while when you're 12 hours out of phase!

Oscar


From: Roland Hill [hidden email]
To: Oscar Kramer [hidden email]; David Burken [hidden email]; [hidden email] [hidden email]
Sent: Thursday, March 12, 2015 6:52 PM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Oscar,

I agree with you on those points. However, ossimImageDataFactory::create(this,3,this) then goes on to call result->setNullPix(inputSource->getNullPixelValue(band), band);, which gets it's null pixel value from getInput(0) of the IndexToRgbLut, which is a 1 band Float32 histogram remapper.


double ossimImageSource::getNullPixelValue(ossim_uint32 band)const
{
   ossimImageSource* inter = PTR_CAST(ossimImageSource,
                                               getInput(0));
   if(inter)
   {
      return inter->getNullPixelValue(band);
   }
  
   return ossim::defaultNull(getOutputScalarType());
}


So the uint8 null pixel value of the IndexToRgbLut filter is set to a value derived from a float32 (-999999 in this case).

When I break in and examine inputSource->getNullPixelValue(band), I can see the -999999 value.

I also agree that hard coding the null pixel value of IndexToRgbLut is not good. Once this issue is sorted out I was going to suggest a IndexToRgbLut->setOutputNull(uint8, unit8, uint8) method.

I can arrange to send the input data and a my test program if you like. The data is not public though.

Cheers,

Roland



--
ROLAND HILL
Director
Four Winds Technology Pty Ltd
Ph/Fax :  +61 (0)2 6366 9425
Mobile :  +61 (0)41 880 7472
[hidden email]

Privacy and Confidentiality Notice
The information contained herein and any attachments are intended solely for the named recipients. It may contain privileged confidential information. If you are not an intended recipient, please delete the message and any attachments then notify the sender of miss-delivery. Any use or disclosure of the contents of either is unauthorised and may be unlawful. All liability for viruses are excluded to the fullest extent permitted by law.



On 13/03/15 04:03, Oscar Kramer wrote:
Hi Roland,

I looked into it a bit. I'm not seeing the behavior you describe. In IndexToRgbLutFilter::allocate() (where theTile is created), the ImageDataFactory::create() is called with source and inputSource both set to this (the RGB filter), not to the filter's input source. A bit confusing there but if you trace into that allocate() and subsequent factory create(), you should see the correct scalar type being referenced.  The factory uses a scalar type of UINT8 (UCHAR) to assign a null pixel of 0. 

I'm leery of hardcoding a null pixel to 0 in the filter itself. That's not where it should be. The question is: why are you seeing a nonzero null pixel for theTile? That should not happen.

-Oscar


From: Roland Hill [hidden email]
To: Oscar Kramer [hidden email]; David Burken [hidden email]; [hidden email] [hidden email]
Sent: Wednesday, March 11, 2015 4:27 PM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Oscar,

No, I am remapping (0,0,0) to (255,255,255). The red coloured nulls are a bug.

The ImageData constructor sets the null value to 0, but then IndexToRgbLutFilter calls ImageDataFactory->create(...). This involves resetting the null value to the same as the input tile null (see below). So we are setting the null value for a UINT8 band to -999999 in this case. ossimImageData::makeBlank() then does "      const T NP = static_cast<T>(m_nullPixelValue[band]); " which ends up with unexpected values. That's why it is necessary to to put in the "theTile->setNullPix(0.0);" line as well.


ossimRefPtr<ossimImageData> ossimImageDataFactory::create(
   ossimSource* owner,
   ossim_uint32 bands,
   ossimImageSource* inputSource)const
{
   ossimRefPtr<ossimImageData> result = 0;

   if(inputSource)
   {
      ossimScalarType scalar = inputSource->getOutputScalarType();
      ossim_uint32 width  = inputSource->getTileWidth();
      ossim_uint32 height = inputSource->getTileHeight();

      result = create(owner, scalar, bands, width, height);
      if ( result.valid() )
      {
         for(ossim_uint32 band = 0; band < bands; ++band)
         {
            result->setMinPix(inputSource->getMinPixelValue(band),   band);
            result->setMaxPix(inputSource->getMaxPixelValue(band),   band);
            result->setNullPix(inputSource->getNullPixelValue(band), band);              < ----------------------
         }
      }
   }
   else
   {
      ossimNotify(ossimNotifyLevel_WARN)
         << "ossimImageDataFactory::create ERROR:"
         << "\nNULL input source!" << std::endl;
   }
  
   return result;
}

Cheers,

Roland


--
ROLAND HILL
Director
Four Winds Technology Pty Ltd
Ph/Fax :  +61 (0)2 6366 9425
Mobile :  +61 (0)41 880 7472
[hidden email]

Privacy and Confidentiality Notice
The information contained herein and any attachments are intended solely for the named recipients. It may contain privileged confidential information. If you are not an intended recipient, please delete the message and any attachments then notify the sender of miss-delivery. Any use or disclosure of the contents of either is unauthorised and may be unlawful. All liability for viruses are excluded to the fullest extent permitted by law.



On 12/03/15 01:09, Oscar Kramer wrote:
OK I put in:

   const ossimRgbVector null_color (theTile->getNullPix(0), theTile->getNullPix(1), theTile->getNullPix(2));
... to make sure nonzero null values are properly handled. You can update. Thanks for testing.

BTW -- In the example you sent showing red border. You meant you were remapping (0,0,0) to (255, 0, 0) correct? Otherwise I don't understand what is happening.

-Oscar

From: Roland Hill [hidden email]
To: Oscar Kramer [hidden email]; David Burken [hidden email]; [hidden email] [hidden email]
Sent: Tuesday, March 10, 2015 6:12 PM
Subject: Re: [OSSIM] No background written for images with empty tiles

Hi Oscar,

That fixes the crash and the short circuit tiles work too. However, it leaves an erroneous pixel colour in null pixels within partial tiles, in this case red. See the example below - note that I have remapped (0,0,0) to (255, 255,255).



The diff I sent yesterday addresses this by setting the new tile background to 0,0,0.

With this fix the output is as expected, below.





Cheers,

Roland








------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/

_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer




------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
www.ossim.org
Ossim-developer mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ossim-developer