openexr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Openexr-devel] Problem with deep data


From: Peter Hillman
Subject: Re: [Openexr-devel] Problem with deep data
Date: Fri, 20 Apr 2018 10:36:16 +1200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

Hi Richard,

It may also be instructive to confirm the library built correctly by building and running the IlmImfTest suite. Running IlmImfTest with "deep" as an argument will run only the deep tests.

The source code of those tests should provide further examples of how to read/write deep data. The different tests intentionally use slightly different approaches to read/write data. You might modify one of those tests to disable the file cleanup, which would generate a deep file you can read with your own code, and compare to the known values written into the file.

Are you getting the correct sample counts but entirely incorrect data? That would suggest you have the pointer-to-arrays pointing to the wrong memory locations. If some of the values are correct (e.g. only the first pixel in the image, only the first pixel on each row, or only the first sample of each pixel) that would suggest the pointers are correct, but the yPixelStride,xPixelStride,sampleStride (respectively) values are wrong.

Try writing a small amount of 32 bit float data (e.g. a 2x2 pixel image with 1 channel) with compression set to NO_COMPRESSION and check the file contents in a hex editor: the last 4 bytes of the file should be the last sample of the last pixel of the last channel in the file. That might tell you whether you are writing the file correctly.



On 20/04/18 09:45, Michael Wolf wrote:


Hallo Richard,

This is a snippet from my simple deep reader (half RGBA, float Z)- minus all the cleanup.
It was written some time ago as a simple test, but it works for the purpose. Maybe it helps you find the issue.

--- snip ---

Imf::Array2D< unsigned int > sampleCount;
Imf::Array2D< half* > dataR, dataG, dataB, dataA;

void readDeepExr(const char *filename)
{
  Imf::DeepScanLineInputFile file(filename);
  const Imf::Header &header = file.header();

  dataWindow = header.dataWindow();
  displayWindow = header.displayWindow();
  width = dataWindow.max.x - dataWindow.min.x + 1;
  height = dataWindow.max.y - dataWindow.min.y + 1;

  sampleCount.resizeEraseUnsafe(height, width);
  Imf::Array2D< float* >dataZ(height, width);
  dataR.resizeEraseUnsafe(height, width); dataG.resizeEraseUnsafe(height, width);
  dataB.resizeEraseUnsafe(height, width); dataA.resizeEraseUnsafe(height, width);        

  Imf::DeepFrameBuffer frameBuffer;
  frameBuffer.insertSampleCountSlice (Imf::Slice (Imf::UINT,
    (char *) (&sampleCount[0][0] - dataWindow.min.x - dataWindow.min.y * width),
    sizeof (unsigned int) * 1, // xStride
    sizeof (unsigned int) * width)); // yStride
  frameBuffer.insert ("Z",
    Imf::DeepSlice (Imf::FLOAT, (char *) (&dataZ[0][0] - dataWindow.min.x - dataWindow.min.y * width),
    sizeof (float *) * 1, // xStride for pointer array
    sizeof (float *) * width, // yStride for pointer array
    sizeof (float) * 1)); // stride for Z data sample
  frameBuffer.insert ("R",
    Imf::DeepSlice (Imf::HALF, (char *) (&dataR[0][0] - dataWindow.min.x - dataWindow.min.y * width),
    sizeof (half *), // xStride for pointer array
    sizeof (half *) * width, // yStride for pointer array
    sizeof (half))); // stride for O data sample
  frameBuffer.insert ("G",
    Imf::DeepSlice (Imf::HALF, (char *) (&dataG[0][0] - dataWindow.min.x - dataWindow.min.y * width),
    sizeof (half *), sizeof (half *) * width, sizeof (half)));
  frameBuffer.insert ("B",
    Imf::DeepSlice (Imf::HALF, (char *) (&dataB[0][0] - dataWindow.min.x - dataWindow.min.y * width),
    sizeof (half *), sizeof (half *) * width, sizeof (half)));
  frameBuffer.insert ("A",
    Imf::DeepSlice (Imf::HALF, (char *) (&dataA[0][0] - dataWindow.min.x - dataWindow.min.y * width),
    sizeof (half *), sizeof (half *) * width, sizeof (half)));

  file.setFrameBuffer(frameBuffer);
  file.readPixelSampleCounts(dataWindow.min.y, dataWindow.max.y);

  for (int y = 0; y < height; y++)
  {
    for (int x = 0; x < width; x++)
    {
      int s = sampleCount[y][x];
      dataZ[y][x] = new float[s];
      dataR[y][x] = new half[s];
      dataG[y][x] = new half[s];
      dataB[y][x] = new half[s];
      dataA[y][x] = new half[s];      
    }    
  }
  file.readPixels(dataWindow.min.y, dataWindow.max.y);
  std::cout << "Done.\n";
 
  // clean up etc...
}


--- snip ---

Cheers,
Mike

--
db&w Bornemann und Wolf GbR
Seyfferstr. 34
70197 Stuttgart
Deutschland
 
address@hidden
 
http://www.db-w.com
 
tel: +49 (711) 664 525-3
fax: +49 (711) 664 525-1
mob: +49 (173) 66 37 652
 
skype: lupus_lux
msn:  
address@hidden


_______________________________________________
Openexr-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/openexr-devel


reply via email to

[Prev in Thread] Current Thread [Next in Thread]