alicevision / QtOIIO

Qt Image IO plugin based on OpenImageIO.
http://www.openimageio.org
Other
41 stars 15 forks source link

Grey scale conversion not functioning properly #19

Open DougRogers opened 3 years ago

DougRogers commented 3 years ago

Attached image does not convert to QImage properly. gray

fabiencastan commented 3 years ago

Yes, you're right. It has been created for usage in Meshroom for photogrammetry and we display grayscale images (depth maps) with a jet color map.

We need to add an additional check here: https://github.com/alicevision/QtOIIO/blob/develop/src/imageIOHandler/QtOIIOHandler.cpp#L65 Maybe just based on the filename as there is no way to have options.

DougRogers commented 3 years ago

It still does not work if convertGrayscaleToJetColorMap is set to false.

You will need something like this to support grey scale

            const oiio::TypeDesc typeDesc = oiio::TypeDesc::UINT8;
            oiio::ImageSpec requestedSpec(inSpec.width, inSpec.height, nchannels, typeDesc);

            oiio::ROI exportROI = inBuf.roi();
            exportROI.chbegin   = 0;
            exportROI.chend     = nchannels;

            // qDebug() << "[QtOIIO] fill output QImage";

            std::vector<uint8_t> conversionBuffer(inSpec.height * inSpec.scanline_bytes());
            inBuf.get_pixels(exportROI, typeDesc, conversionBuffer.data());
            auto src = conversionBuffer.data();
            auto dst = result.bits();

            for (int y = 0; y < inSpec.height; ++y)
            {
                memcpy(dst, src, inSpec.width);
                src += inSpec.scanline_bytes();
                dst += result.bytesPerLine();
            }
fabiencastan commented 3 years ago

There is also some commented code: https://github.com/alicevision/QtOIIO/blob/develop/src/imageIOHandler/QtOIIOHandler.cpp#L197

DougRogers commented 3 years ago

Does uncommenting out that code and setting the convertGrayscaleToJetColorMap flag to false, load the test image for you?

fabiencastan commented 3 years ago

I have not tested it.