First prototype
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#include "clahe.h"
|
||||
#include <QDebug>
|
||||
|
||||
CLAHE::CLAHE()
|
||||
{
|
||||
_clahe = cv::createCLAHE();
|
||||
}
|
||||
|
||||
void CLAHE::loadFile(const QString &path)
|
||||
{
|
||||
cv::Mat tmp;
|
||||
tmp = cv::imread(path.toStdString(), cv::IMREAD_COLOR | cv::IMREAD_ANYDEPTH);
|
||||
double scale = tmp.depth()==CV_8U ? 1.0/255 : 1.0/65535;
|
||||
tmp.convertTo(tmp, CV_32F, scale);
|
||||
cv::cvtColor(tmp, tmp, cv::COLOR_BGR2Lab);
|
||||
cv::split(tmp, _image);
|
||||
_image[0].convertTo(_lumImage, CV_16U, 655.35);
|
||||
double min, max;
|
||||
cv::minMaxLoc(_image[0], &min, &max);
|
||||
qDebug() << scale << min << max;
|
||||
}
|
||||
|
||||
void CLAHE::saveFile(const QString &path)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CLAHE::apply(float clipLimit, int kernelSize)
|
||||
{
|
||||
cv::Mat lum;
|
||||
_clahe->setClipLimit(clipLimit);
|
||||
_clahe->setTilesGridSize(cv::Size(kernelSize, kernelSize));
|
||||
_clahe->apply(_lumImage, lum);
|
||||
//lum = _lumImage;
|
||||
lum.convertTo(_image[0], CV_32F, 1.0/655.35);
|
||||
double min, max;
|
||||
cv::minMaxLoc(_image[0], &min, &max);
|
||||
qDebug() << min << max;
|
||||
}
|
||||
|
||||
QPixmap CLAHE::getImage() const
|
||||
{
|
||||
cv::Mat tmp;
|
||||
cv::merge(_image, 3, tmp);
|
||||
cv::cvtColor(tmp, tmp, cv::COLOR_Lab2RGB);
|
||||
tmp.convertTo(tmp, CV_8U, 255);
|
||||
QImage ret(tmp.data, tmp.cols, tmp.rows, tmp.step, QImage::Format_RGB888);
|
||||
//ret.bits();//perform deep copy of tmp.data pointer
|
||||
return QPixmap::fromImage(ret);
|
||||
}
|
||||
Reference in New Issue
Block a user