How can I change the whole QImage pixel value using a color map?

Solution 1:

Before applying a color table, be sure to have an indexed image, otherwise convert it to the desired format:

if(current_image.format() != QImage::Format_Indexed8)
{
    current_image = current_image.convertToFormat(QImage::Format_Indexed8);
}
current_image.setColorTable(
    COLORMAP.inferno); // COLOR_MAP is an attribute of type

Not sure about what you're trying to achieve, but I guess the original image should be in 8-bit grayscale format, so maybe, you can check that, first:

if(current_image.format() != QImage::Format_Grayscale8)
{
    current_image = current_image.convertToFormat(QImage::Format_Grayscale8);
}