From 42403357195decddb8867d82ca17d4aaef42030f Mon Sep 17 00:00:00 2001 From: Tanguy Raufflet <raufflettanguy@gmail.com> Date: Wed, 26 Jul 2023 08:21:01 +0200 Subject: [PATCH] =?UTF-8?q?Some=20fixes=20-=20Ajout=20warning=20split=20co?= =?UTF-8?q?lor=20RGB=20d'une=20image=20en=20ndg=20(comme=20pour=20le=20spl?= =?UTF-8?q?it=20HSV)=20-=20Ajout=20warning=20Apply=20mask=20diff=C3=A9renc?= =?UTF-8?q?e=20de=20taille=20d'image=20-=20(Detic-t):=20Reset=20de=20la=20?= =?UTF-8?q?s=C3=A9lection=20de=20l'image=20lorsque=20l'on=20quitte=20le=20?= =?UTF-8?q?mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Operations/BinaryMaskOp.cpp | 9 +++++++++ app/Operations/SplitColorOp.cpp | 8 +++++++- lib/detiq-t | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/Operations/BinaryMaskOp.cpp b/app/Operations/BinaryMaskOp.cpp index dd4ef22..90dc868 100644 --- a/app/Operations/BinaryMaskOp.cpp +++ b/app/Operations/BinaryMaskOp.cpp @@ -80,6 +80,10 @@ void BinaryMaskOp::operator()(const ImageWindow *currentWnd, const Image_t<double>* dblImg = imgBox->getDblImage(imgBox->currentText().toStdString()); if(dblImg == nullptr) return; mask = new Image_t<double>(*dblImg); + if(mask->getHeight() != dblImg->getHeight() || mask->getWidth() != dblImg->getWidth()) + QMessageBox::information(nullptr, qApp->translate("BinaryMaskOp", "warning Apply Mask"), + qApp->translate("BinaryMaskOp", + "you have performed a mask operation between two images of different sizes")); } else return; @@ -100,6 +104,11 @@ void BinaryMaskOp::operator()(const ImageWindow *currentWnd, *it = *it / max; } + if(mask->getHeight() != img->getHeight() || mask->getWidth() != img->getWidth()) + QMessageBox::information(nullptr, qApp->translate("BinaryMaskOp", "warning Apply Mask"), + qApp->translate("BinaryMaskOp", + "you have performed a mask operation between two images of different sizes")); + const unsigned int width = min(mask->getWidth(), img->getWidth()); const unsigned int height = min(mask->getHeight(), img->getHeight()); auto* resImg = new Image_t<double>(width, height, img->getNbChannels()); diff --git a/app/Operations/SplitColorOp.cpp b/app/Operations/SplitColorOp.cpp index 1f10027..6c21206 100644 --- a/app/Operations/SplitColorOp.cpp +++ b/app/Operations/SplitColorOp.cpp @@ -17,6 +17,7 @@ * along with ImageINSA. If not, see <http://www.gnu.org/licenses/>. */ #include <GrayscaleImage.h> +#include <QMessageBox> #include "SplitColorOp.h" #include "../Tools.h" @@ -33,9 +34,14 @@ SplitColorOp::SplitColorOp() : Operation(qApp->translate("Operations", "Split co } void SplitColorOp:: operator()(const imagein::Image* image, const std::map<const imagein::Image*, std::string>&) { + if(image->getNbChannels()==1){ + QMessageBox::warning(nullptr, qApp->translate("Operations", "The operation cannot be applied on this image"), + qApp->translate("Operations", "The image is not in color.")); + return; + } for(unsigned int c = 0; c < image->getNbChannels(); ++c) { - GrayscaleImage* resImg = new GrayscaleImage(image->getWidth(), image->getHeight()); + auto* 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)); diff --git a/lib/detiq-t b/lib/detiq-t index 2a63e65..4e8b354 160000 --- a/lib/detiq-t +++ b/lib/detiq-t @@ -1 +1 @@ -Subproject commit 2a63e6517079b78bff5d9ae1fb48d30e32dca653 +Subproject commit 4e8b354dbc606f52edfabe5370010acdc011c5f4 -- GitLab