/** \brief Draw a finish pixel at the specified position. The finishpixel has at the least-significant bit of their rgb-value r: 3, g: 0, b: 0 * * \param &pixel const Pixel a pixel-struct describing the pixel-position where the finish-pixel should be set. */ void SteganoHide::drawFinishPixel(const Pixel &pixel) { Magick::ColorRGB pixelColor = this->steganoImage.pixelColor(pixel.x, pixel.y); RGB pixelRGB(convert16BitTo8BitRGB(pixelColor.redQuantum()), convert16BitTo8BitRGB(pixelColor.greenQuantum()), convert16BitTo8BitRGB(pixelColor.blueQuantum())); pixelRGB.red = (pixelRGB.red - (pixelRGB.red % 10)) + 3; pixelRGB.green = pixelRGB.green - (pixelRGB.green % 10); pixelRGB.blue = pixelRGB.blue - (pixelRGB.blue % 10); this->steganoImage.pixelColor(pixel.x, pixel.y, Magick::ColorRGB(pixelRGB.toString())); }
bool ColorFilter::pixelFilteredIsOn (const QImage &image, int x, int y) const { bool rtn = false; if ((0 <= x) && (0 <= y) && (x < image.width()) && (y < image.height())) { // Pixel is on if it is closer to black than white in gray scale. This test must be performed // on little endian and big endian systems, with or without alpha bits (which are typically high bits); const int BLACK_WHITE_THRESHOLD = 255 / 2; // Put threshold in middle of range int gray = qGray (pixelRGB (image, x, y)); rtn = (gray < BLACK_WHITE_THRESHOLD); } return rtn; }
// TODO: handle wrong input bool SteganoHide::hideNumberInMagickColorRGB(const unsigned short &smallNumber, Magick::ColorRGB &color) { RGB pixelRGB(convert16BitTo8BitRGB(color.redQuantum()), convert16BitTo8BitRGB(color.greenQuantum()), convert16BitTo8BitRGB(color.blueQuantum())); RGB roundedRGB; roundedRGB.red = pixelRGB.red - (pixelRGB.red % 10); roundedRGB.green = pixelRGB.green - (pixelRGB.green % 10); roundedRGB.blue = pixelRGB.blue - (pixelRGB.blue % 10); unsigned char mostSignificantBit = std::floor(smallNumber / 100); unsigned char middleSigificantBit = std::floor(smallNumber % 100 / 10); unsigned char leastSignificantBit = smallNumber % 10; /* if(mostSignificantBit > 5 || middleSigificantBit > 5 || leastSignificantBit > 5) { throw hideNumber2Big; }*/ // there was an overflow: eg. roundedRGB.blue = 250 and leastSignificantLetterBit = 8 => 258 => 2 // This way to check overflow is possible, because *SignificantLetterBit >= 0 if(roundedRGB.green + middleSigificantBit > 255) { return false; } if(roundedRGB.blue + leastSignificantBit > 255) { return false; } // std::cout << (int)roundedRGB.blue << "+" << (int)leastSignificantBit << "="; roundedRGB.red += mostSignificantBit; roundedRGB.green += middleSigificantBit; roundedRGB.blue += leastSignificantBit; //std::cout << (int)roundedRGB.blue << std::endl; color = Magick::ColorRGB(roundedRGB.toString()); return true; }