ahojnnes · GitHub

Hello ! I had some issues reading 16bit per channel pngs with the feature extractor. I tracked the issue to this line returning a null pointer.

Turns out FreeImage cant transform these images directly into grayscale as described here. This happens at line 104 in the FreeImage Conversion8.cpp file:

FIBITMAP * DLL_CALLCONV
FreeImage_ConvertTo8Bits(FIBITMAP *dib) {  // Called by FreeImage_ConvertToGreyscale
	if (!FreeImage_HasPixels(dib)) {
		return NULL;
	}
	const FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(dib);
	if (image_type != FIT_BITMAP && image_type != FIT_UINT16) {   // <----- Here -----
		return NULL;
	}
	...

My solution is just transforming the image to 8bits per channel before transforming to grayscale.

Read the original on github.com ↗