| 131 | } |
| 132 | |
| 133 | QImage MeanNoiseReductionFilter::setFilter(const QImage &image) |
| 134 | { |
| 135 | int width = image.width(); |
| 136 | int height = image.height(); |
| 137 | QImage result(width, height, image.format()); |
| 138 | int filterSize = sqrt((float)neighborghoodSize); |
| 139 | int bound = filterSize / 2; |
| 140 | QRgb pix; |
| 141 | int r, g, b; |
| 142 | for (int j = bound; j < height - bound; j++) { |
| 143 | for (int i = bound; i < width - bound; i++) { |
| 144 | r = g = b = 0; |
| 145 | for (int y = j - bound; y <= j + bound; y++) { |
| 146 | for (int x = i - bound; x <= i + bound; x++) { |
| 147 | pix = image.pixel(x, y); |
| 148 | r += qRed(pix); |
| 149 | g += qGreen(pix); |
| 150 | b += qBlue(pix); |
| 151 | } |
| 152 | } |
| 153 | result.setPixel(i, j, QColor(r / neighborghoodSize, g / neighborghoodSize, b / neighborghoodSize).rgb()); |
| 154 | // qDebug((QString::number(redChannel.at(4))+" "+QString::number(greenChannel.at(4))+" "+QString::number(blueChannel.at(4))).toAscii()); |
| 155 | // qDebug((QString::number(redChannel.size())+" "+QString::number(greenChannel.size())+" "+QString::number(blueChannel.size())).toAscii()); |
| 156 | } |
| 157 | } |
| 158 | return result; |
| 159 | } |
| 160 | |
| 161 | //----------------------------------------------------------------------------- |
| 162 | // MedianNoiseReductionFilter |
no test coverage detected