diff --git a/ColorimetricSegmenter.cpp b/ColorimetricSegmenter.cpp index 9e2433a..9df20a2 100644 --- a/ColorimetricSegmenter.cpp +++ b/ColorimetricSegmenter.cpp @@ -175,6 +175,7 @@ QList ColorimetricSegmenter::getActions() } + if (!m_action_filterRgbWithSegmentation) { // Here we use the default plugin name, description, and icon, @@ -227,7 +228,7 @@ QList ColorimetricSegmenter::getActions() // Here we use the default plugin name, description, and icon, // but each action should have its own. m_action_ToonMapping_Hist = new QAction("Histogram Clustering", this); - m_action_ToonMapping_Hist->setToolTip("Quantified cloud generator using histogram equalization"); + m_action_ToonMapping_Hist->setToolTip("Quantify the number of colors using Histogram Clustering"); m_action_ToonMapping_Hist->setIcon(QIcon(":/CC/plugin/ColorimetricSegmenter/images/icon_quantif_h.png")); // Connect appropriate signal @@ -243,7 +244,7 @@ QList ColorimetricSegmenter::getActions() // Here we use the default plugin name, description, and icon, // but each action should have its own. m_action_ToonMapping_KMeans = new QAction("Kmeans Clustering", this); - m_action_ToonMapping_KMeans->setToolTip("Quantified cloud generator using kmeans method"); + m_action_ToonMapping_KMeans->setToolTip("Quantify the number of colors using Kmeans Clustering"); m_action_ToonMapping_KMeans->setIcon(QIcon(":/CC/plugin/ColorimetricSegmenter/images/icon_quantif_k.png")); // Connect appropriate signal @@ -316,17 +317,27 @@ void ColorimetricSegmenter::filterRgb() // Start timer auto start = std::chrono::high_resolution_clock::now(); - // Get margin value (percent) - double marginError = static_cast(rgbDlg->margin->value()) / 100.0; - // Get all values to make the color range with RGB values - int redInf = std::min(rgbDlg->red_first->value(), rgbDlg->red_second->value()) - (marginError * std::min(rgbDlg->red_first->value(), rgbDlg->red_second->value())); - int redSup = std::max(rgbDlg->red_first->value(), rgbDlg->red_second->value()) + (marginError * std::max(rgbDlg->red_first->value(), rgbDlg->red_second->value())); - int greenInf = std::min(rgbDlg->green_first->value(), rgbDlg->green_second->value()) - (marginError * std::min(rgbDlg->green_first->value(), rgbDlg->green_second->value())); - int greenSup = std::max(rgbDlg->green_first->value(), rgbDlg->green_second->value()) + (marginError * std::max(rgbDlg->green_first->value(), rgbDlg->green_second->value())); - int blueInf = std::min(rgbDlg->blue_first->value(), rgbDlg->blue_second->value()) - (marginError * std::min(rgbDlg->blue_first->value(), rgbDlg->blue_second->value())); - int blueSup = std::max(rgbDlg->blue_first->value(), rgbDlg->blue_second->value()) + (marginError * std::max(rgbDlg->blue_first->value(), rgbDlg->blue_second->value())); + int redInf = std::min(rgbDlg->red_first->value(), rgbDlg->red_second->value()); + int redSup = std::max(rgbDlg->red_first->value(), rgbDlg->red_second->value()); + int greenInf = std::min(rgbDlg->green_first->value(), rgbDlg->green_second->value()); + int greenSup = std::max(rgbDlg->green_first->value(), rgbDlg->green_second->value()); + int blueInf = std::min(rgbDlg->blue_first->value(), rgbDlg->blue_second->value()); + int blueSup = std::max(rgbDlg->blue_first->value(), rgbDlg->blue_second->value()); + if (rgbDlg->margin->value() > 0) { + // Get margin value (percent) + double marginError = static_cast(rgbDlg->margin->value()) / 100.0; + + redInf -= marginError * redInf; + redSup += marginError * redSup; + greenInf -= marginError * greenInf; + greenSup += marginError * greenSup; + blueInf -= marginError * blueInf; + blueSup += marginError * blueSup; + } + + // Set to min or max value (0-255) redInf = (redInf < MIN_VALUE ? MIN_VALUE : redInf); greenInf = (greenInf < MIN_VALUE ? MIN_VALUE : greenInf); blueInf = (blueInf < MIN_VALUE ? MIN_VALUE : blueInf); @@ -347,9 +358,9 @@ void ColorimetricSegmenter::filterRgb() for (unsigned j = 0; j < cloud->size(); ++j) { const ccColor::Rgb& rgb = cloud->getPointColor(j); - (rgb.r > redInf&& rgb.r < redSup && - rgb.g > greenInf&& rgb.g < greenSup && - rgb.b > blueInf&& rgb.b < blueSup) ? addPoint(filteredCloudInside, j) : addPoint(filteredCloudOutside, j); + (rgb.r >= redInf&& rgb.r <= redSup && + rgb.g >= greenInf&& rgb.g <= greenSup && + rgb.b >= blueInf&& rgb.b <= blueSup) ? addPoint(filteredCloudInside, j) : addPoint(filteredCloudOutside, j); } std::string name = "Rmin:" + std::to_string(redInf) + "/Gmin:" + std::to_string(greenInf) + "/Bmin:" + std::to_string(blueInf) + "/Rmax:" + std::to_string(redSup) + "/Gmax:" + std::to_string(greenSup) + "/Bmax:" + std::to_string(blueSup); diff --git a/HSVDialog.ui b/HSVDialog.ui index 2cab510..f3c484f 100644 --- a/HSVDialog.ui +++ b/HSVDialog.ui @@ -279,6 +279,9 @@ Retain + + true + diff --git a/KmeansDlg.ui b/KmeansDlg.ui index ebaf542..1bc77ec 100644 --- a/KmeansDlg.ui +++ b/KmeansDlg.ui @@ -6,75 +6,106 @@ 0 0 - 391 - 230 + 352 + 127 - Dialog + Kmeans clustering setting - - - - -50 - 180 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 20 - 40 - 351 - 111 - - - - - - - 1 - - - 255 - - - - - - - Nombre couleurs - - - - - - - 1 - - - 255 - - - - - - - Nombre itération - - - - - + + + + + + + Number of colors + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 1 + + + 255 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Number of iterations + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 1 + + + 255 + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + diff --git a/QuantiDialog.ui b/QuantiDialog.ui index e267484..b8551a7 100644 --- a/QuantiDialog.ui +++ b/QuantiDialog.ui @@ -6,131 +6,121 @@ 0 0 - 401 - 204 + 325 + 115 - Dialog + Histogram Clustering setting - - - - -40 - 150 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 10 - 40 - 384 - 30 - - - - - - - Indice de Quantification - - - Qt::AlignCenter - - - - - - - 0 - - - 1.000000000000000 - - - 255.000000000000000 - - - - - - - - - 149 - 310 - 384 - 28 - - - - ArrowCursor - - - Use PointPicking - - - - - - 120 - 90 - 174 - 28 - - - - - - - Qt::AlignCenter - - - - - - 10 - 90 - 384 - 30 - - - - - - - Couleurs possibles : - - - Qt::AlignCenter - - - 0 - - - - - - - 1 - - - Qt::AlignCenter - - - - - + + + + + + + Quantification index + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 0 + + + 1.000000000000000 + + + 255.000000000000000 + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + + + + + Colors available : + + + Qt::AlignCenter + + + 0 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 1 + + + Qt::AlignCenter + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + diff --git a/ScalarDialog.ui b/ScalarDialog.ui index 79fb9ff..d84d081 100644 --- a/ScalarDialog.ui +++ b/ScalarDialog.ui @@ -7,7 +7,7 @@ 0 0 564 - 192 + 189