Skip to content

Commit

Permalink
no demosicing for foveon sensors #185
Browse files Browse the repository at this point in the history
  • Loading branch information
fcomida committed Jun 16, 2019
1 parent 391986f commit bf84b34
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/Libpfs/colorspace/gamma.h
Expand Up @@ -30,11 +30,15 @@ namespace pfs {
namespace colorspace {

struct Gamma2_2 {
static float gamma() { return 1 / 2.2f; }
static float gamma() { return 1.f / 2.2f; }
};

struct Gamma1_8 {
static float gamma() { return 1 / 1.8f; }
static float gamma() { return 1.f / 1.8f; }
};

struct Gamma1_0 {
static float gamma() { return 1.f; }
};

template <typename GammaFactor>
Expand Down
34 changes: 26 additions & 8 deletions src/Libpfs/io/rawreader.cpp
Expand Up @@ -466,14 +466,14 @@ void RAWReader::read(Frame &frame, const Params &params) {
cout << "Decoder name: " << dec_info->decoder_name << endl;
free (dec_info);

bool isFoveon = P1.is_foveon;
unsigned filters = P1.filters;

if (m_processor.dcraw_process() != LIBRAW_SUCCESS) {
m_processor.recycle();
throw pfs::io::ReadException("Error Processing RAW File");
}

bool isFoveon = P1.is_foveon;
unsigned filters = P1.filters;

libraw_processed_image_t *image = m_processor.dcraw_make_mem_image();

if (!image) // ret != LIBRAW_SUCCESS ||
Expand All @@ -494,7 +494,25 @@ void RAWReader::read(Frame &frame, const Params &params) {

const uint16_t *raw_data = reinterpret_cast<const uint16_t *>(image->data);

/* utils::transform( */
if (isFoveon) {

utils::transform(
FixedStrideIterator<const uint16_t *, 3>(raw_data),
FixedStrideIterator<const uint16_t *, 3>(raw_data + H * W * 3),
FixedStrideIterator<const uint16_t *, 3>(raw_data + 1),
FixedStrideIterator<const uint16_t *, 3>(raw_data + 2), Xc->begin(),
Yc->begin(), Zc->begin(),
colorspace::Gamma<pfs::colorspace::Gamma1_0>());

LibRaw::dcraw_clear_mem(image);
m_processor.recycle();

FrameReader::read(tempFrame, params);
frame.swap(tempFrame);
return;
}

/* utils::transform( */
/* FixedStrideIterator<const uint16_t *, 3>(raw_data), */
/* FixedStrideIterator<const uint16_t *, 3>(raw_data + H * W * 3), */
/* FixedStrideIterator<const uint16_t *, 3>(raw_data + 1), */
Expand Down Expand Up @@ -537,7 +555,7 @@ void RAWReader::read(Frame &frame, const Params &params) {
rawdata[i] = rawdata[i-1] + W;
}

if ((!isFoveon) && (filters != 9)) {
if (filters != 9) {
#ifdef _OPENMP
#pragma omp parallel for
#endif
Expand Down Expand Up @@ -598,12 +616,12 @@ void RAWReader::read(Frame &frame, const Params &params) {
//igv_demosaic(W, H, rawdata, r, g, b, cf_array, callback);
//hphd_demosaic(W, H, rawdata, r, g, b, cf_array, callback);
//dcb_demosaic(W, H, rawdata, r, g, b, cf_array, callback, 3, true);
if ( (!isFoveon) && (filters != 9) ) {
if ( filters != 9 ) {
amaze_demosaic(W, H, 0, 0, W, H, rawdata, r, g, b, cf_array, callback, 1.0, 0, 1.0, 1.0, 4);
}
else {
//xtransfast_demosaic(W, H, rawdata, r, g, b, x_trans, callback);
markesteijn_demosaic(W, H, rawdata, r, g, b,x_trans, C.rgb_cam, callback, 1, false);
xtransfast_demosaic(W, H, rawdata, r, g, b, x_trans, callback);
//markesteijn_demosaic(W, H, rawdata, r, g, b, x_trans, C.rgb_cam, callback, 1, false);
}
}
catch(...) {
Expand Down

0 comments on commit bf84b34

Please sign in to comment.