Skip to content
This repository has been archived by the owner on Jan 14, 2023. It is now read-only.

Grey scale conversion not functioning properly #19

Open
DougRogers opened this issue Mar 26, 2021 · 5 comments
Open

Grey scale conversion not functioning properly #19

DougRogers opened this issue Mar 26, 2021 · 5 comments

Comments

@DougRogers
Copy link

Attached image does not convert to QImage properly.
gray

@fabiencastan
Copy link
Member

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
Copy link
Author

DougRogers commented Mar 27, 2021

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
Copy link
Member

@DougRogers
Copy link
Author

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

@fabiencastan
Copy link
Member

I have not tested it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants