Skip to content

Commit

Permalink
Summary line and align cost
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelaya committed May 18, 2014
1 parent fc44efc commit 4c84c07
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DngFloatWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void DngFloatWriter::write(const string & filename) {
progress.advance(75, "Writing output");
Timer t("Write output");
writePreviews();
measureTime("Write raw", [&] () { writeRawData(); });
writeRawData();
file.seekp(0);
TiffHeader().write(file);
mainIFD.write(file, false);
Expand Down
6 changes: 4 additions & 2 deletions Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ void Image::relativeExposure(const Image & r) {
}


void Image::alignWith(const Image & r) {
if (!good() || !r.good()) return;
size_t Image::alignWith(const Image & r) {
dx = dy = 0;
const double tolerance = 1.0/16;
Histogram histFull(rawPixels.get(), rawPixels.get() + width*height);
double halfLightPercent = histFull.getFraction(max * 0.9) / 2.0;
size_t totalError = 0;
for (int s = scaleSteps - 1; s >= 0; --s) {
size_t curWidth = width >> (s + 1);
size_t curHeight = height >> (s + 1);
Expand Down Expand Up @@ -174,7 +174,9 @@ void Image::alignWith(const Image & r) {
}
dx <<= 1;
dy <<= 1;
totalError += minError;
}
return totalError;
}


Expand Down
2 changes: 1 addition & 1 deletion Image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Image {
return relExp;
}
bool isSameFormat(const Image & ref) const;
void alignWith(const Image & r);
size_t alignWith(const Image & r);
void releaseAlignData() {
scaled.reset();
}
Expand Down
11 changes: 9 additions & 2 deletions ImageStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ int ImageStack::load(const LoadOptions & options, ProgressIndicator & progress)


int ImageStack::save(const SaveOptions & options, ProgressIndicator & progress) {
string cropped("");
if (width != images[0]->getWidth() || height != images[0]->getHeight()) {
cropped = " cropped";
}
Log::msg(2, "Writing ", options.fileName, ", ", options.bps, "bits, ", width, 'x', height, cropped);
DngFloatWriter writer(*this, progress);
writer.setBitsPerSample(options.bps);
writer.setPreviewWidth((options.previewSize * width) / 2);
Expand All @@ -110,12 +115,14 @@ int ImageStack::save(const SaveOptions & options, ProgressIndicator & progress)

void ImageStack::align() {
if (images.size() > 1) {
size_t errors[images.size()];
for (int i = images.size() - 2; i >= 0; --i) {
images[i]->alignWith(*images[i + 1]);
errors[i] = images[i]->alignWith(*images[i + 1]);
}
for (int i = images.size() - 2; i >= 0; --i) {
images[i]->displace(images[i + 1]->getDeltaX(), images[i + 1]->getDeltaY());
Log::msg(Log::DEBUG, "Image ", i, " displaced to (", images[i]->getDeltaX(), ", ", images[i]->getDeltaY(), ")");
Log::msg(Log::DEBUG, "Image ", i, " displaced to (", images[i]->getDeltaX(), ", ", images[i]->getDeltaY(),
") with error ", errors[i]);
}
for (auto & i : images) {
i->releaseAlignData();
Expand Down

0 comments on commit 4c84c07

Please sign in to comment.