Example #1
0
void PseudoColorOp::operator()(const imagein::Image* image, const std::map<const imagein::Image*, std::string>&) {
   GrayscaleImage* tmpImg = Converter<GrayscaleImage>::convert(*image);
   Image* resImg = new Image(tmpImg->getWidth(), tmpImg->getHeight(), 3);
    for(unsigned int j = 0; j < tmpImg->getHeight(); ++j) {
        for(unsigned int i = 0; i < tmpImg->getWidth(); ++i) {
            Image::depth_t value = tmpImg->getPixel(i, j);
            const int nhue = 256;
            const int ngrad = ceil(256. / (double)nhue);
            const int hue = floor(value * nhue / 256); /* € [0, nhue[ */
            const int grad = value - ceil((double)hue * 256. / (double)nhue); /* € [0, ngrad[ */
            QColor color = QColor::fromHsl(300 - hue * 300 / nhue, 255, (grad + 1) * 255 / (ngrad + 1));
            resImg->setPixel(i, j, 0, color.red());
            resImg->setPixel(i, j, 1, color.green());
            resImg->setPixel(i, j, 2, color.blue());
        }
    }
    delete tmpImg;
    outImage(resImg, qApp->translate("PseudoColorOp", "Pseudo color").toStdString());

}
Example #2
0
void SplitColorOp:: operator()(const imagein::Image* image, const std::map<const imagein::Image*, std::string>&) {

    for(unsigned int c = 0; c < image->getNbChannels(); ++c) {
        GrayscaleImage* resImg = new GrayscaleImage(image->getWidth(), image->getHeight());
        for(unsigned int j = 0; j < resImg->getHeight(); ++j) {
            for(unsigned int i = 0; i < resImg->getWidth(); ++i) {
                resImg->setPixel(i, j, image->getPixel(i, j, c));
            }
        }
        QString name("");
        name += Tools::colorName(c, image->getNbChannels());
        this->outImage(resImg, name.toStdString());
    }

}