Skip to content

Commit 3645abe

Browse files
committed
Misc bugfix. Crop, Align, Ycc.
1 parent a63ae8c commit 3645abe

File tree

8 files changed

+9377
-8006
lines changed

8 files changed

+9377
-8006
lines changed

demo/openlime.js

+9,347-7,982
Large diffs are not rendered by default.

demo/openlime.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

relight-cli/rtibuilder.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void RtiBuilder::savePixel(Color3f *p, int side, const QString &file) {
167167
*/
168168

169169
bool RtiBuilder::init(std::function<bool(QString stage, int percent)> *_callback) {
170-
if((type == PTM || type == HSH || type == SH || type == H) && colorspace == MRGB) {
170+
if((type == PTM || type == HSH || type == SH || type == H) && (colorspace == MRGB || colorspace == MYCC)) {
171171
error = "PTM and HSH do not support MRGB";
172172
return false;
173173
}
@@ -293,7 +293,7 @@ MaterialBuilder RtiBuilder::pickBasePCA(PixelArray &sample) {
293293
vector<double> means;
294294

295295
for(int component = 0; component < 3; component++) {
296-
std::vector<PCA *> pcas;
296+
//std::vector<PCA *> pcas;
297297
means.resize(dim, 0.0);
298298

299299
PCA pca(dim, nsamples);
@@ -343,8 +343,10 @@ MaterialBuilder RtiBuilder::pickBasePCA(PixelArray &sample) {
343343
p = yccplanes[1]*2 + yp;
344344
} else
345345
p = yp*3 + component;
346-
for(uint32_t k = 0; k < dim; k++)
346+
for(uint32_t k = 0; k < dim; k++) {
347+
assert(k*3 + component + p*dim*3 < mat.proj.size());
347348
mat.proj[k*3 + component + p*dim*3] = pca.proj()(k, yp);
349+
}
348350
}
349351

350352

relightlab/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if (APPLE)
2020
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
2121
else()
2222
set(OPENCV_RELIGHT_LIBS opencv_core opencv_imgcodecs opencv_imgproc opencv_video)
23-
# add_compile_definitions(WITH_OPENCV)
23+
add_compile_definitions(WITH_OPENCV)
2424
endif()
2525

2626

relightlab/mainwindow.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ MainWindow::MainWindow() {
5454
}
5555

5656
void MainWindow::showQueue() {
57-
tabs->setCurrentIndex(8);
57+
tabs->setCurrentIndex(9);
5858
}
5959

6060
void MainWindow::setTabIndex(int index) {

relightlab/rtiframe.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void RtiFrame::exportRti() {
121121
rti_task->setProject(project);
122122
rti_task->setParameters(parameters);
123123
rti_task->output = parameters.path;
124-
rti_task->crop = project.crop;
124+
125125

126126
} catch(QString error) {
127127
QMessageBox::critical(this, "Something went wrong", error);
@@ -153,7 +153,7 @@ void RtiFrame::updateNPlanes() {
153153
break;
154154
case Rti::RBF:
155155
case Rti::BILINEAR:
156-
if(parameters.colorspace != Rti::YCC) nchroma = 0;
156+
nchroma = parameters.colorspace == Rti::MYCC ? 1 : 0;
157157
planes_row->forceNPlanes(-1);
158158
default:
159159
break;
@@ -178,7 +178,7 @@ void RtiFrame::basisChanged() {
178178
colorspace = Rti::RGB;
179179

180180
} else {
181-
if(colorspace != Rti::MRGB && colorspace != Rti::YCC)
181+
if(colorspace != Rti::MRGB && colorspace != Rti::MYCC)
182182
colorspace = Rti::MRGB;
183183
}
184184
colorspace_row->setColorspace(colorspace);

relightlab/rtiplan.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ RtiColorSpaceRow::RtiColorSpaceRow(RtiParameters &parameters, QFrame *parent): R
7676
connect(rgb, &QAbstractButton::clicked, this, [this](){ setColorspace(Rti::RGB, true); });
7777
connect(lrgb, &QAbstractButton::clicked, this, [this](){ setColorspace(Rti::LRGB, true); });
7878
connect(mrgb, &QAbstractButton::clicked, this, [this](){ setColorspace(Rti::MRGB, true); });
79-
connect(ycc, &QAbstractButton::clicked, this, [this](){ setColorspace(Rti::YCC, true); });
79+
connect(ycc, &QAbstractButton::clicked, this, [this](){ setColorspace(Rti::MYCC, true); });
8080

8181
QButtonGroup *group = new QButtonGroup(this);
8282
group->addButton(rgb);
@@ -106,7 +106,7 @@ void RtiColorSpaceRow::setColorspace(Rti::ColorSpace colorspace, bool emitting)
106106
case Rti::RGB: rgb->setChecked(true); break;
107107
case Rti::LRGB: lrgb->setChecked(true); break;
108108
case Rti::MRGB: mrgb->setChecked(true); break;
109-
case Rti::YCC: ycc->setChecked(true); break;
109+
case Rti::MYCC: ycc->setChecked(true); break;
110110
default:
111111
break; //TODO check MYCC!
112112
}
@@ -157,7 +157,7 @@ void RtiPlanesRow::forceNPlanes(int nplanes) {
157157
}
158158

159159
void RtiPlanesRow::setNPlanes(int nplanes, bool emitting) {
160-
nchromabox->setEnabled(parameters.colorspace == Rti::YCC);
160+
nchromabox->setEnabled(parameters.colorspace == Rti::MYCC);
161161

162162
parameters.nplanes = nplanes;
163163
if(emitting) {
@@ -171,7 +171,7 @@ void RtiPlanesRow::setNPlanes(int nplanes, bool emitting) {
171171
}
172172

173173
void RtiPlanesRow::setNChroma(int nchroma, bool emitting) {
174-
nchromabox->setEnabled(parameters.colorspace == Rti::YCC);
174+
nchromabox->setEnabled(parameters.colorspace == Rti::MYCC);
175175

176176
parameters.nchroma = nchroma;
177177
if(emitting) {

relightlab/rtitask.cpp

+15-11
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@ void RtiTask::setProject(Project &project) {
5353
builder->samplingram = QSettings().value("ram", 512).toInt();
5454

5555

56+
5657
ImageSet &imageset = builder->imageset;
5758

5859
imageset.images = project.getImages();
5960
imageset.initImages(project.dir.absolutePath().toStdString().c_str());
6061

6162
imageset.initFromDome(project.dome); //lights after images
62-
imageset.setCrop(crop, project.offsets);
63+
imageset.setCrop(project.crop, project.offsets);
6364
imageset.pixel_size = project.pixelSize;
65+
builder->sigma = 0.125*100/imageset.images.size();
66+
cout << "builder->sigma: " << builder->sigma << endl;
6467

65-
//TODO too many crop locations!
66-
if(!crop.isNull()) {
67-
builder->crop[0] = imageset.left;
68-
builder->crop[1] = imageset.top;
69-
builder->crop[2] = imageset.width;
70-
builder->crop[3] = imageset.height;
71-
}
68+
builder->crop[0] = imageset.left;
69+
builder->crop[1] = imageset.top;
70+
builder->crop[2] = imageset.width;
71+
builder->crop[3] = imageset.height;
7272

7373
builder->width = imageset.width;
7474
builder->height = imageset.height;
@@ -86,11 +86,15 @@ void RtiTask::setParameters(RtiParameters &p) {
8686
builder->type = parameters.basis;
8787
builder->colorspace = parameters.colorspace;
8888
builder->nplanes = parameters.nplanes;
89-
builder->yccplanes[0] = parameters.nchroma;
89+
builder->yccplanes[1] = builder->yccplanes[2] = parameters.nchroma;
9090

9191
if( builder->colorspace == Rti::MYCC) {
92-
builder->yccplanes[1] = builder->yccplanes[2] = (builder->nplanes - builder->yccplanes[0])/2;
93-
builder->nplanes = builder->yccplanes[0] + 2*builder->yccplanes[1];
92+
if((parameters.nchroma + parameters.nplanes)%2 == 1) {
93+
builder->nplanes += 3;
94+
}
95+
builder->yccplanes[0] = (builder->nplanes - 2*builder->yccplanes[1]);
96+
//builder->yccplanes[1] = builder->yccplanes[2] = (builder->nplanes - builder->yccplanes[0])/2;
97+
//builder->nplanes = builder->yccplanes[0] + 2*builder->yccplanes[1];
9498
}
9599

96100
//legacy format uses the same scale and bias for each component (RBG)

0 commit comments

Comments
 (0)