Skip to content
Snippets Groups Projects
Commit 3f80baaf authored by Antoine Pazat's avatar Antoine Pazat Committed by Sanchez Alexandre
Browse files

Decomposition HSV en images doubles, pas de perte d'informations sur la teinte

parent bc534d2e
No related branches found
No related tags found
No related merge requests found
......@@ -35,7 +35,7 @@
using namespace std;
using namespace imagein;
CombineHSVOp::CombineHSVOp() : Operation(qApp->translate("Operations", "Combine hsv planes").toStdString())
CombineHSVOp::CombineHSVOp() : DoubleOperation(qApp->translate("Operations", "Combine HSV planes").toStdString())
{
}
......@@ -43,7 +43,7 @@ bool CombineHSVOp::needCurrentImg() const {
return false;
}
void CombineHSVOp::operator()(const imagein::Image*, const std::map<const imagein::Image*, std::string>& imgList) {
void CombineHSVOp::operator()(const imagein::Image_t<double>*, const map<const imagein::Image_t<double>*, string>& imgList) {
QDialog* dialog = new QDialog();
dialog->setWindowTitle(qApp->translate("Operations", "Parameters"));
......@@ -51,18 +51,17 @@ void CombineHSVOp::operator()(const imagein::Image*, const std::map<const imagei
QFormLayout* layout = new QFormLayout();
dialog->setLayout(layout);
ImageListBox_t<double>** imageBoxes = new ImageListBox_t<double>*[3*sizeof(ImageListBox_t<double>*)];
ImageListBox** imageBoxes = new ImageListBox*[3*sizeof(ImageListBox*)];
imageBoxes[0] = new ImageListBox(dialog, NULL, imgList);
imageBoxes[0] = new ImageListBox_t<double>(dialog, NULL, imgList);
QLabel* label = new QLabel("Hue", dialog);
layout->insertRow(0, label, imageBoxes[0]);
imageBoxes[1] = new ImageListBox(dialog, NULL, imgList);
imageBoxes[1] = new ImageListBox_t<double>(dialog, NULL, imgList);
QLabel* label1 = new QLabel("Saturation", dialog);
layout->insertRow(1, label1, imageBoxes[1]);
imageBoxes[2] = new ImageListBox(dialog, NULL, imgList);
imageBoxes[2] = new ImageListBox_t<double>(dialog, NULL, imgList);
QLabel* label2 = new QLabel("Value", dialog);
layout->insertRow(2, label2, imageBoxes[2]);
......@@ -83,10 +82,14 @@ void CombineHSVOp::operator()(const imagein::Image*, const std::map<const imagei
int height = imageBoxes[0]->currentImage()->getHeight();
Image* resImg = new Image(width, height, 3);
const Image_t<double>* H = imageBoxes[0]->currentImage();
const Image_t<double>* S = imageBoxes[1]->currentImage();
const Image_t<double>* V = imageBoxes[2]->currentImage();
for(int i=0;i<width;i++){
for(int j=0;j<height;j++){
color.setHsv(imageBoxes[0]->currentImage()->getPixel(i,j,0),imageBoxes[1]->currentImage()->getPixel(i,j,0) ,imageBoxes[2]->currentImage()->getPixel(i,j,0) );
color.setHsv(H->getPixel(i,j,0),S->getPixel(i,j,0) ,V->getPixel(i,j,0) );
resImg->setPixel(i,j,0,color.red());
resImg->setPixel(i,j,1,color.green());
resImg->setPixel(i,j,2,color.blue());
......@@ -94,25 +97,6 @@ void CombineHSVOp::operator()(const imagein::Image*, const std::map<const imagei
}
}
// GrayscaleImage* channels[3];
// unsigned int maxWidth = numeric_limits<unsigned int>::max();
// unsigned int maxHeight = numeric_limits<unsigned int>::max();
// for(unsigned int c = 0; c < nChannel; ++c) {
// const Image* img = imageBoxes[c]->currentImage();
// if(img == NULL) return;
// channels[c] = Converter<GrayscaleImage>::convert(*img);
// maxWidth = min(maxWidth, channels[c]->getWidth());
// maxHeight = min(maxHeight, channels[c]->getHeight());
// }
// Image* resImg = new Image(512, 512, 3);
// for(unsigned int c = 0; c < nChannel; ++c) {
// for(unsigned int j = 0; j < resImg->getHeight(); ++j) {
// for(unsigned int i = 0; i < resImg->getWidth(); ++i) {
// resImg->setPixel(i, j, c, channels[c]->getPixel(i, j));
// }
// }
// }
this->outImage(resImg, qApp->translate("CombineHsvOp", "Reconstructed image").toStdString());
}
......@@ -22,12 +22,12 @@
#include "Operation.h"
class CombineHSVOp : public Operation
class CombineHSVOp : public DoubleOperation
{
public:
CombineHSVOp();
void operator()(const imagein::Image*, const std::map<const imagein::Image*, std::string>&);
void operator()(const imagein::Image_t<double>*, const std::map<const imagein::Image_t<double>*, std::string>&);
bool needCurrentImg() const;
};
......
/*
* Copyright 2011-2012 INSA Rennes
*
* This file is part of ImageINSA.
*
* ImageINSA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ImageINSA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ImageINSA. If not, see <http://www.gnu.org/licenses/>.
*/
#include <GrayscaleImage.h>
#include <QColor>
#include "SplitHsvOp.h"
#include "../Tools.h"
using namespace std;
using namespace imagein;
bool SplitHsvOp::needCurrentImg() const {
return true;
}
SplitHsvOp::SplitHsvOp() : Operation(qApp->translate("Operations", "Split HSV planes").toStdString())
{
}
void SplitHsvOp:: operator()(const imagein::Image* image, const std::map<const imagein::Image*, std::string>&) {
int width = image->getWidth();
int height = image->getHeight();
Image_t<double>* resImgH = new Image_t<double>(width, height, 1);
Image_t<double>* resImgS = new Image_t<double>(width, height, 1);
Image_t<double>* resImgV = new Image_t<double>(width, height, 1);
for(unsigned int i = 0; i < width; i++) {
for(unsigned int j = 0; j < height; j++) {
QColor color = QColor(image->getPixel(i, j, 0), image->getPixel(i, j, 1), image->getPixel(i, j, 2));
resImgH->setPixelAt(i,j,color.hue());
resImgS->setPixelAt(i,j,color.saturation());
resImgV->setPixelAt(i,j,color.value());
}
}
this->outDoubleImage(resImgH, "Hue",false,false);
this->outDoubleImage(resImgS, "Saturation",false,false);
this->outDoubleImage(resImgV, "Value",false,false);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment