Hello.
It is the exact same image file, it is an indexed TIFF file which this forum engine forbids to upload unfortunately. I made test code in both C++ and Python:
C++
#include <opencv.hpp>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
cv::Mat input_image;
cv::Size size;
int numChannels = 0;
string imageFile = "test.tif";
input_image = cv::imread(imageFile, -1);
if (input_image.data == NULL)
{
cout << "Could not open file " << imageFile << endl;
return -1;
}
size = input_image.size();
numChannels = input_image.channels();
cout << imageFile << ": height=" << size.height << ", width=" << size.width << ", channels=" << numChannels << endl;
return 0;
}
And Python:
import sys
import cv2
if __name__ == "__main__":
imageFile="test.tif"
inputImage = None
try:
inputImage = cv2.imread(imageFile, -1)
if inputImage is None:
print("Could not load image.")
exit()
except Exception as e:
print("Exception - ",str(e))
exit()
imgHeight, imgWidth, numChannels = inputImage.shape
print(f"{imageFile}: height={imgHeight}, width={imgWidth}, channels={numChannels}")
exit()
Output from C++:
test.tif: height=512, width=512, channels=1
Output from Python:
test.tif: height=512, width=512, channels=3