/*
*/
/*
Copyright (C) 2014 Ferrero Andrea
This program 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.
This program 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 this program. If not, see .
*/
/*
These files are distributed with PhotoFlow - http://aferrero2707.github.io/PhotoFlow/
*/
#include
#include "demosaic_common.hh"
#include "../base/processor.hh"
#include "../external/librtprocess/src/include/librtprocess.h"
void PF::init_CFA(int filters, unsigned cfa[2][2])
{
for(int row = 0; row < 2; row++) {
for(int col = 0; col < 2; col++) {
cfa[row][col] = (filters >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3);
}
}
}
PF::PixelBuffer::PixelBuffer(float* buf, int w, int h, int rowstride, int roffs, int coffs)
{
width = w; height = h;
ptr = NULL; rows = NULL;
ptr = new float*[h];
rows = ptr - roffs;
for(int i = 0; i < height; i++) {
ptr[i] = buf - coffs;
buf += rowstride;
}
//std::cout<<"Initialized pixel matrix "<& in, int first,
VipsImage* imap, VipsImage* omap,
unsigned int& level)
{
void *data;
size_t data_length;
if( in.size()<1 || in[0]==NULL ) return NULL;
size_t blobsz;
if( PF_VIPS_IMAGE_GET_BLOB( in[0], "raw_image_data", &image_data, &blobsz ) ) {
std::cout<<"DemosaicBasePar::build(): could not extract raw_image_data."<Ysize-border-2) and with size (in[0]->Xsize,border)
if( vips_crop(in[0], &t[i0], 0, in[0]->Ysize-border-1, in[0]->Xsize, border, NULL) ) {
std::cout<<"DemosaicBasePar::build(): vip_crop(#2) failed"<Ysize)
if( vips_crop(t[i0-1], &t[i0], 1, 0, border, t[i0-1]->Ysize, NULL) ) {
std::cout<<"DemosaicBasePar::build(): vip_crop(#3) failed"<Xsize-2,0) and with size (border,t[i0-1]->Ysize)
if( vips_crop(t[i0-1], &t[i0], t[i0-1]->Xsize-border-1, 0, border, t[i0-1]->Ysize, NULL) ) {
std::cout<<"DemosaicBasePar::build(): vip_crop(#4) failed"< in2; in2.push_back(extended);
VipsImage* img = OpParBase::build( in2, 0, NULL, NULL, level );
PF_UNREF( extended, "DemosaicBasePar::build(): extended unref" );
//std::cout<<"DemosaicBasePar::build(): RAW image = "<Xsize/tw + 1) * 3;
VipsAccess acc = VIPS_ACCESS_RANDOM;
int threaded = 1, persistent = 0;
VipsImage* cached;
if( vips_tilecache(out, &cached,
"tile_width", tw, "tile_height", th, "max_tiles", nt,
"access", acc, "threaded", threaded, "persistent", persistent, NULL) ) {
std::cout<<"DemosaicBasePar::build(): vips_tilecache() failed."<