Skip to content
Snippets Groups Projects
Commit 2213bc31 authored by Sacha Percot-Tétu's avatar Sacha Percot-Tétu
Browse files

Improved RGB image generator, moved ImageListBox

parent e3ebf050
No related branches found
No related tags found
No related merge requests found
......@@ -49,3 +49,11 @@ QColor ColorDialog::getColor() const {
return QColor::fromHsv(h, s, v);
}
}
unsigned int ColorDialog::getWidth() const {
return ui->widthBox->value();
}
unsigned int ColorDialog::getHeight() const {
return ui->heightBox->value();
}
......@@ -34,7 +34,9 @@ public:
explicit ColorDialog(QWidget *parent = 0);
~ColorDialog();
QColor getColor() const;
unsigned int getWidth() const;
unsigned int getHeight() const;
private:
Ui::ColorDialog *ui;
};
......
......@@ -6,14 +6,51 @@
<rect>
<x>0</x>
<y>0</y>
<width>194</width>
<height>349</height>
<width>305</width>
<height>561</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>RGB image generator</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Image size</string>
</property>
<layout class="QFormLayout" name="formLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Width : </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="widthBox">
<property name="maximum">
<number>65536</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Height : </string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="heightBox">
<property name="maximum">
<number>65536</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
......@@ -157,6 +194,7 @@
<zorder>groupBox</zorder>
<zorder>rgbWidget</zorder>
<zorder>hsvWidget</zorder>
<zorder>groupBox_2</zorder>
</widget>
<resources/>
<connections>
......
......@@ -31,7 +31,7 @@
#include "ColorDialog.h"
using namespace imagein;
ColorimetryOp::ColorimetryOp() : Operation(qApp->translate("Operations", "Colorimetry").toStdString())
ColorimetryOp::ColorimetryOp() : Operation(qApp->translate("Operations", "Generate RGB image").toStdString())
{
}
......@@ -42,12 +42,12 @@ bool ColorimetryOp::needCurrentImg() const {
void ColorimetryOp::operator()(const imagein::Image*, const std::map<const imagein::Image*, std::string>&) {
ColorDialog* dialog = new ColorDialog(QApplication::activeWindow());
dialog->setWindowTitle(QString(qApp->translate("Operations", "Colorimetry")));
dialog->setWindowTitle(QString(qApp->translate("Operations", "RGB image generator")));
QDialog::DialogCode code = static_cast<QDialog::DialogCode>(dialog->exec());
QColor color = dialog->getColor();
if(code!=QDialog::Accepted) return;
Image* resImg = new Image(512, 512, 3);
Image* resImg = new Image(dialog->getWidth(), dialog->getHeight(), 3);
for(unsigned int j = 0; j < resImg->getHeight(); ++j) {
for(unsigned int i = 0; i < resImg->getWidth(); ++i) {
resImg->setPixelAt(i, j, 0, color.red());
......
......@@ -28,7 +28,7 @@
#include <Converter.h>
#include <ImgWidget.h>
#include "ImageListBox.h"
#include <Widgets/ImageListBox.h>
#include "CombineColorOp.h"
#include "../Tools.h"
......
/*
* Copyright 2011-2012 INSA Rennes
*
* This file is part of EIImage.
*
* EIImage 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.
*
* EIImage 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 EIImage. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ImageListBox.h"
using namespace std;
using namespace imagein;
/*
* Copyright 2011-2012 INSA Rennes
*
* This file is part of EIImage.
*
* EIImage 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.
*
* EIImage 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 EIImage. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IMAGELISTBOX_H
#define IMAGELISTBOX_H
#include <QComboBox>
#include <map>
#include <string>
#include <Image.h>
template<typename D>
class ImageListBox_t : public QComboBox
{
public:
explicit ImageListBox_t(QWidget *parent, const imagein::Image_t<D>* img, const std::map<const imagein::Image_t<D>*, std::string>& imgList)
: QComboBox(parent)
{
int i = 0, index = 0;
for(typename std::map<const imagein::Image_t<D>*, std::string>::const_iterator it = imgList.begin(); it != imgList.end(); ++it) {
_images.insert(std::pair<std::string, const imagein::Image_t<D>*>(it->second, it->first));
this->insertItem(i, QString(it->second.c_str()));
if(it->first == img) index = i;
}
this->setCurrentIndex(index);
}
const imagein::Image_t<D>* currentImage() {
std::string name = this->currentText().toStdString();
typename std::map<std::string, const imagein::Image_t<D>*>::iterator it = _images.find(name);
if(it != _images.end()) {
return _images[name];
}
return NULL;
}
protected:
std::map<std::string, const imagein::Image_t<D>*> _images;
};
typedef ImageListBox_t<imagein::Image::depth_t> ImageListBox;
class MixImageListBox : public QComboBox
{
public:
enum ImageType {STDIMG, DBLIMG};
explicit MixImageListBox(QWidget *parent,
std::string currentImg,
std::map<const imagein::Image*,std::string> stdImgs,
std::map<const imagein::Image_t<double>*,std::string> dblImgs)
: QComboBox(parent)
{
int i = 0, index = 0;
for(typename std::map<const imagein::Image*, std::string>::const_iterator it = stdImgs.begin(); it != stdImgs.end(); ++it) {
_images.insert(std::pair<std::string, ImageType>(it->second, STDIMG));
_stdImgs.insert(std::pair<std::string, const imagein::Image*>(it->second, it->first));
this->insertItem(i, QString(it->second.c_str()));
if(it->second == currentImg) index = i;
}
for(typename std::map<const imagein::Image_t<double>*, std::string>::const_iterator it = dblImgs.begin(); it != dblImgs.end(); ++it) {
_images.insert(std::pair<std::string, ImageType>(it->second, DBLIMG));
_dblImgs.insert(std::pair<std::string, const imagein::Image_t<double>*>(it->second, it->first));
this->insertItem(i, QString(it->second.c_str()));
if(it->second == currentImg) index = i;
}
this->setCurrentIndex(index);
}
ImageType currentType() {
std::string name = this->currentText().toStdString();
return _images[name];
}
const imagein::Image* getStdImage(std::string name) {
typename std::map<std::string, const imagein::Image*>::iterator it = _stdImgs.find(name);
if(it != _stdImgs.end()) {
return _stdImgs[name];
}
return NULL;
}
const imagein::Image_t<double>* getDblImage(std::string name) {
typename std::map<std::string, const imagein::Image_t<double>*>::iterator it = _dblImgs.find(name);
if(it != _dblImgs.end()) {
return _dblImgs[name];
}
return NULL;
}
protected:
std::map<std::string, ImageType> _images;
std::map<std::string, const imagein::Image*> _stdImgs;
std::map<std::string, const imagein::Image_t<double>*> _dblImgs;
};
#endif // IMAGELISTBOX_H
......@@ -23,7 +23,7 @@
#include <QFormLayout>
#include <Image.h>
#include "ImageListBox.h"
#include <Widgets/ImageListBox.h>
#include "../Tools.h"
#include "MeanSquaredErrorOp.h"
......
......@@ -31,9 +31,9 @@
#include "PointOp.h"
#include "ImgWidget.h"
#include "ImageListBox.h"
#include "Widgets/ImageWidgets/StandardImageWindow.h"
#include "Widgets/ImageWidgets/DoubleImageWindow.h"
#include <Widgets/ImageListBox.h>
#include <Widgets/ImageWidgets/StandardImageWindow.h>
#include <Widgets/ImageWidgets/DoubleImageWindow.h>
#include <Converter.h>
#include "../Tools.h"
......
......@@ -22,7 +22,7 @@
#include <QFormLayout>
#include <Image.h>
#include "ImageListBox.h"
#include <Widgets/ImageListBox.h>
#include "../Tools.h"
#include "SignalToNoiseOp.h"
......
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