----------------------------------------------------------------------------- ! ImageViewerWindow::updateStatistics */
| 264 | ImageViewerWindow::updateStatistics |
| 265 | */ |
| 266 | void ImageViewerWindow::updateStatistics(IPLImage* image) |
| 267 | { |
| 268 | qDebug() << "ImageViewerWindow::updateStatistics"; |
| 269 | if(!image) |
| 270 | { |
| 271 | ui->statisticsLabel->setText("-"); |
| 272 | return; |
| 273 | } |
| 274 | |
| 275 | // only update if panel is not hidden |
| 276 | if(ui->statisticsLabel->isVisible()) |
| 277 | { |
| 278 | // image information |
| 279 | QString statistics("<table>"); |
| 280 | statistics.append("<tr><td><b>Height: </b></td><td>%1px</td></tr>"); |
| 281 | statistics.append("<tr><td><b>Width: </b></td><td>%2px</td></tr>"); |
| 282 | statistics.append("<tr><td><b>Image Type: </b></td><td>%3</td></tr>"); |
| 283 | statistics.append("<tr><td><b>Image Planes: </b></td><td>%4</td></tr>"); |
| 284 | statistics.append("</table>"); |
| 285 | |
| 286 | QString imageType = "COLOR"; |
| 287 | if(image->type() == IPL_IMAGE_GRAYSCALE) |
| 288 | imageType = "GRAY"; |
| 289 | else if(image->type() == IPL_IMAGE_BW) |
| 290 | imageType = "BW"; |
| 291 | |
| 292 | statistics = statistics.arg(image->height()).arg(image->width()).arg(imageType).arg(image->getNumberOfPlanes()); |
| 293 | |
| 294 | |
| 295 | // histogram statistics |
| 296 | |
| 297 | if(image->type() == IPL_IMAGE_COLOR) |
| 298 | { |
| 299 | IPLHistogram* histogramR = ui->histogramWidget->histogramR(); |
| 300 | IPLHistogram* histogramG = ui->histogramWidget->histogramG(); |
| 301 | IPLHistogram* histogramB = ui->histogramWidget->histogramB(); |
| 302 | |
| 303 | QString statistics2("<table>"); |
| 304 | statistics2.append("<tr><td><b>Min: </b></td><td style=\"color:#FF0000;\">%1 </td><td style=\"color:#41DB00;\">%2 </td><td style=\"color:#0094FF;\">%3</td></tr>"); |
| 305 | statistics2 = statistics2.arg(histogramR->minLevel()).arg(histogramG->minLevel()).arg(histogramB->minLevel()); |
| 306 | statistics2.append("<tr><td><b>Max: </b></td><td style=\"color:#FF0000;\">%1 </td><td style=\"color:#41DB00;\">%2 </td><td style=\"color:#0094FF;\">%3</td></tr>"); |
| 307 | statistics2 = statistics2.arg(histogramR->maxLevel()).arg(histogramG->maxLevel()).arg(histogramB->maxLevel()); |
| 308 | statistics2.append("<tr><td><b>Mean: </b></td><td style=\"color:#FF0000;\">%1 </td><td style=\"color:#41DB00;\">%2 </td><td style=\"color:#0094FF;\">%3</td></tr>"); |
| 309 | statistics2 = statistics2.arg(histogramR->meanLevel()).arg(histogramG->meanLevel()).arg(histogramB->meanLevel()); |
| 310 | statistics2.append("<tr><td><b>Median: </b></td><td style=\"color:#FF0000;\">%1 </td><td style=\"color:#41DB00;\">%2 </td><td style=\"color:#0094FF;\">%3</td></tr>"); |
| 311 | statistics2 = statistics2.arg(histogramR->medianLevel()).arg(histogramG->medianLevel()).arg(histogramB->medianLevel()); |
| 312 | statistics2.append("<tr><td><b>Mode: </b></td><td style=\"color:#FF0000;\">%1 </td><td style=\"color:#41DB00;\">%2 </td><td style=\"color:#0094FF;\">%3</td></tr>"); |
| 313 | statistics2 = statistics2.arg(histogramR->modeLevel()).arg(histogramG->modeLevel()).arg(histogramB->modeLevel()); |
| 314 | |
| 315 | statistics2.append("</table>"); |
| 316 | |
| 317 | statistics += statistics2; |
| 318 | } |
| 319 | else if(image->type() == IPL_IMAGE_GRAYSCALE || image->type() == IPL_IMAGE_BW) |
| 320 | { |
| 321 | IPLHistogram* histogram = ui->histogramWidget->histogram(); |
| 322 | |
| 323 | QString statistics2("<table>"); |
no test coverage detected