You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have had success using this library for signed data. However I have a problem with unsigned data. I am using version v3.0.0.0 of the library on Windows 10.
I used the TIFF writer to write a 256x256 image with 32 bits per sample and using the TinyTIFFWriter_UInt format. I set the values of the pixels to x + y*256 where x is the column number and y is the row number.
The written file looks correct and I can check the values with a quick Python script using PIL and numpy (note that PIL uses column-major ordering):
>>> from PIL import Image
>>> import numpy
>>> def check_pixels(array):
... for y in range(arr.shape[0]):
... for x in range(arr.shape[1]):
... expected_value = x + y*arr.shape[1]
... if expected_value != arr[y,x]:
... print(f"[{x},{y}] expected: {expected_value}, got: {arr[y][x]}")
...
>>> check_pixels(arr)
>>> image = Image.open(filepath)
>>> arr = numpy.array(image)
>>> check_pixels(arr)
>>> arr.shape
(256, 256)
However when using the TIFF reader I get some peculiar data at specific repeating points in the image.
I read the image using the following code:
// Open the file using the file reader
TinyTIFFReaderFile *inputFile = TinyTIFFReader_open(fullFileName.c_str());
EXPECT_NE(inputFile, nullptr);
// Check the properties
EXPECT_EQ(1, TinyTIFFReader_countFrames(inputFile));
EXPECT_EQ(xSize, TinyTIFFReader_getWidth(inputFile));
EXPECT_EQ(ySize, TinyTIFFReader_getHeight(inputFile));
EXPECT_EQ(1, TinyTIFFReader_getSamplesPerPixel(inputFile));
EXPECT_EQ(32, TinyTIFFReader_getBitsPerSample(inputFile, 0));
// Read the data and check
unsigned int *inputData = new unsigned int[xSize*ySize];
unsigned int counter = 0;
for (unsigned int y=0; y<ySize; y++)
{
for (unsigned int x=0; x<xSize; x++)
{
TinyTIFFReader_getSampleData(inputFile, inputData, x + y*xSize);
if (TinyTIFFReader_wasError(inputFile))
{
printf("Error reading sample: %s\n", TinyTIFFReader_getLastError(inputFile));
return;
}
if ((x+y*xSize) != inputData[x+y*xSize])
{
printf(
"[%d][%d] does not match. Expected: %u, got: %u\n",
x, y, x+y*xSize, inputData[x+y*xSize]
);
counter++;
if (counter > 10) return;
}
EXPECT_EQ(x+y*xSize, inputData[x+y*xSize]);
}
}
// Close the file
TinyTIFFReader_close(inputFile);
And I get strange values at these [x][y] coordinates:
[255][63] does not match. Expected: 16383, got: 4107264
[255][127] does not match. Expected: 32767, got: 8301568
[255][191] does not match. Expected: 49151, got: 12495872
[255][255] does not match. Expected: 65535, got: 16690176
I don't see anything obviously wrong with my logic, and it's just 4 values in the entire 256x256 image so I'm wondering if there is a bug in the library itself?
The text was updated successfully, but these errors were encountered:
I have had success using this library for signed data. However I have a problem with unsigned data. I am using version v3.0.0.0 of the library on Windows 10.
I used the TIFF writer to write a 256x256 image with 32 bits per sample and using the TinyTIFFWriter_UInt format. I set the values of the pixels to x + y*256 where x is the column number and y is the row number.
The written file looks correct and I can check the values with a quick Python script using PIL and numpy (note that PIL uses column-major ordering):
However when using the TIFF reader I get some peculiar data at specific repeating points in the image.
I read the image using the following code:
And I get strange values at these [x][y] coordinates:
[255][63] does not match. Expected: 16383, got: 4107264
[255][127] does not match. Expected: 32767, got: 8301568
[255][191] does not match. Expected: 49151, got: 12495872
[255][255] does not match. Expected: 65535, got: 16690176
I don't see anything obviously wrong with my logic, and it's just 4 values in the entire 256x256 image so I'm wondering if there is a bug in the library itself?
The text was updated successfully, but these errors were encountered: