本文整理汇总了C++中LibRaw::unpack方法的典型用法代码示例。如果您正苦于以下问题:C++ LibRaw::unpack方法的具体用法?C++ LibRaw::unpack怎么用?C++ LibRaw::unpack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LibRaw
的用法示例。
在下文中一共展示了LibRaw::unpack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadMaster
Image ImageLoader_raw_p::loadMaster ()
{
/**
* Custom raw import:
* half_size = 1
* document_mode = 2
* gamma[0] gamma[1] = 1
*/
// Skip debayer for now
m_rawProcessor.imgdata.params.half_size = 0;
m_rawProcessor.imgdata.params.document_mode = 0;
m_rawProcessor.imgdata.params.use_camera_wb = 1;
m_rawProcessor.imgdata.params.use_auto_wb = 0;
m_rawProcessor.imgdata.params.med_passes = 0;
m_rawProcessor.imgdata.params.no_auto_bright = 1;
m_rawProcessor.imgdata.params.output_color = 1; // sRGB
m_rawProcessor.imgdata.params.output_bps = 16; // 16 bits
m_rawProcessor.unpack();
// Use AHC bayer interpolation
m_rawProcessor.imgdata.params.user_qual = 1;
m_rawProcessor.imgdata.params.threshold = 100;
if (m_rawProcessor.imgdata.other.iso_speed)
m_rawProcessor.imgdata.params.threshold = m_rawProcessor.imgdata.other.iso_speed / 8; // TODO /8 beter?
m_rawProcessor.dcraw_process();
int mem_height = 0;
int mem_width = 0;
int mem_channels = 0;
int mem_bits_per_pixel = 0;
m_rawProcessor.get_mem_image_format(&mem_width, &mem_height, &mem_channels, &mem_bits_per_pixel);
QSize size (mem_width, mem_height);
qDebug () << "Create rawprocessor image:";
qDebug () << mem_width << mem_height << mem_channels << mem_bits_per_pixel;
Image image (size, mem_channels, size.width() * mem_channels * mem_bits_per_pixel, mem_bits_per_pixel);
// image.setMaxValue( m_rawProcessor.imgdata.color.maximum );
m_rawProcessor.copy_mem_image(image.pixels(), image.step(), 0);
return image;
}
示例2: main
int main(int argc, char const *argv[])
{
LibRaw rawProcessor;
rawProcessor.open_file(argv[argc-1]);
rawProcessor.unpack();
// Use 16-bit input.
buffer_t input_buf = {0};
input_buf.host = (uint8_t *)rawProcessor.imgdata.rawdata.raw_image;
input_buf.stride[0] = 1;
input_buf.stride[1] = rawProcessor.imgdata.sizes.width;
input_buf.extent[0] = rawProcessor.imgdata.sizes.width;
input_buf.extent[1] = rawProcessor.imgdata.sizes.height;
input_buf.elem_size = sizeof(*rawProcessor.imgdata.rawdata.raw_image);
// Allocate WxH 16-bit, 3 channel output buffer.
buffer_t output_buf = {0};
output_buf.stride[0] = 1;
output_buf.stride[1] = rawProcessor.imgdata.sizes.width;
output_buf.stride[2] = rawProcessor.imgdata.sizes.width * rawProcessor.imgdata.sizes.height;
output_buf.stride[3] = rawProcessor.imgdata.sizes.width * rawProcessor.imgdata.sizes.height * 3;
output_buf.extent[0] = rawProcessor.imgdata.sizes.width;
output_buf.extent[1] = rawProcessor.imgdata.sizes.height;
output_buf.extent[2] = 3;
output_buf.elem_size = 2;
uint8_t *output_data = new uint8_t[sizeof(uint16_t) * rawProcessor.imgdata.sizes.width * rawProcessor.imgdata.sizes.height * 3];
output_buf.host = output_data;
output_buf.host_dirty = false;
output_buf.dev_dirty = false;
output_buf.dev = 0;
for (int i = 0; i<20; i++) {
igd_demosaic(&input_buf, 0, &output_buf);
}
//Image<uint16_t> output_image = Image<uint16_t>(&output_buf, "output");
//output_image.copy_to_host();
//Tools::save_image(output_image, "test.png");
return 0;
}
示例3: main
int main(int ac, char *av[])
{
int i, ret;
LibRaw RawProcessor;
if(ac<2)
{
printf(
"multirender_test - LibRaw %s sample. Performs 4 different renderings of one file\n"
" %d cameras supported\n"
"Usage: %s raw-files....\n"
,LibRaw::version(), LibRaw::cameraCount(),
av[0]);
return 0;
}
for (i=1;i<ac;i++)
{
printf("Processing file %s\n",av[i]);
if( (ret = RawProcessor.open_file(av[i])) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot open_file %s: %s\n",av[i],libraw_strerror(ret));
continue; // no recycle b/c open file will recycle itself
}
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack %s: %s\n",av[i],libraw_strerror(ret));
continue;
}
process_once(RawProcessor,0,0,0,1,-1,av[i]); // default flip
process_once(RawProcessor,1,0,1,2,-1,av[i]);
process_once(RawProcessor,1,1,0,3,-1,av[i]); // default flip
process_once(RawProcessor,1,1,0,4,1,av[i]); // flip 1
process_once(RawProcessor,1,1,0,5,3,av[i]); // flip 3
process_once(RawProcessor,1,1,0,6,1,av[i]); // 1 again same as 4
process_once(RawProcessor,1,1,0,7,-1,av[i]); // default again, same as 3
process_once(RawProcessor,0,0,0,8,-1,av[i]); // same as 1
RawProcessor.recycle(); // just for show this call
}
return 0;
}
示例4: libraw_unpack
int libraw_unpack(libraw_data_t* lr)
{
if(!lr) return EINVAL;
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->unpack();
}
示例5: main
int main(int ac, char *av[])
{
int i, ret;
int verbose=1,autoscale=0,use_gamma=0;
char outfn[1024];
LibRaw RawProcessor;
if(ac<2)
{
usage:
printf(
"unprocessed_raw - LibRaw %s sample. %d cameras supported\n"
"Usage: %s [-q] [-A] [-g] [-s N] [-N] raw-files....\n"
"\t-q - be quiet\n"
"\t-s N - select Nth image in file (default=0)\n"
"\t-g - use gamma correction with gamma 2.2 (not precise,use for visual inspection only)\n"
"\t-A - autoscaling (by integer factor)\n"
"\t-N - no raw curve\n"
,LibRaw::version(),
LibRaw::cameraCount(),
av[0]);
return 0;
}
#define P1 RawProcessor.imgdata.idata
#define S RawProcessor.imgdata.sizes
#define C RawProcessor.imgdata.color
#define T RawProcessor.imgdata.thumbnail
#define P2 RawProcessor.imgdata.other
#define OUT RawProcessor.imgdata.params
OUT.document_mode=2;
OUT.output_bps=16;
OUT.output_tiff=1;
OUT.user_flip=0;
OUT.no_auto_bright = 1;
OUT.filtering_mode=(LibRaw_filtering)( LIBRAW_FILTERING_NOBLACKS|LIBRAW_FILTERING_NOZEROES);
for (i=1;i<ac;i++)
{
if(av[i][0]=='-')
{
if(av[i][1]=='q' && av[i][2]==0)
verbose=0;
else if(av[i][1]=='A' && av[i][2]==0)
autoscale=1;
else if(av[i][1]=='g' && av[i][2]==0)
use_gamma = 1;
else if(av[i][1]=='N' && av[i][2]==0)
OUT.filtering_mode=LIBRAW_FILTERING_NONE;
else if(av[i][1]=='s' && av[i][2]==0)
{
i++;
OUT.shot_select=atoi(av[i]);
}
else
goto usage;
continue;
}
int c;
if(!use_gamma)
OUT.gamm[0] = OUT.gamm[1] = 1;
if(verbose) printf("Processing file %s\n",av[i]);
if( (ret = RawProcessor.open_file(av[i])) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot open %s: %s\n",av[i],libraw_strerror(ret));
continue; // no recycle b/c open file will recycle itself
}
if(verbose)
{
printf("Image size: %dx%d\nRaw size: %dx%d\n",S.width,S.height,S.raw_width,S.raw_height);
printf("Margins: top=%d, left=%d, right=%d, bottom=%d\n",
S.top_margin,S.left_margin,S.right_margin,S.bottom_margin);
}
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack %s: %s\n",av[i],libraw_strerror(ret));
continue;
}
if(verbose)
printf("Unpacked....\n");
if( (ret = RawProcessor.add_masked_borders_to_bitmap() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot add mask data to bitmap %s\n",av[i]);
}
// move all pixel data to component 0
for(int r=0;r<S.iheight;r++)
for(c=0;c<S.iwidth;c++)
RawProcessor.imgdata.image[r*S.iwidth+c][0]
= RawProcessor.imgdata.image[r*S.iwidth+c][RawProcessor.COLOR(r,c)];
P1.colors=1;
if(autoscale)
{
unsigned max=0,scale;
for(int j=0; j<S.iheight*S.iwidth; j++)
//.........这里部分代码省略.........
示例6: main
//.........这里部分代码省略.........
{
fprintf(stderr,"Cannot open %s: %s\n",argv[arg],strerror(errno));
continue;
}
if(fstat(file,&st))
{
fprintf(stderr,"Cannot stat %s: %s\n",argv[arg],strerror(errno));
close(file);
continue;
}
if(!(iobuffer = malloc(st.st_size)))
{
fprintf(stderr,"Cannot allocate %d kbytes for memory buffer\n",(int)(st.st_size/1024));
close(file);
continue;
}
int rd;
if(st.st_size!=(rd=read(file,iobuffer,st.st_size)))
{
fprintf(stderr,"Cannot read %d bytes instead of %d to memory buffer\n",(int)rd,(int)st.st_size);
close(file);
free(iobuffer);
continue;
}
close(file);
if( (ret = RawProcessor.open_buffer(iobuffer,st.st_size) != LIBRAW_SUCCESS))
{
fprintf(stderr,"Cannot open_buffer %s: %s\n",argv[arg],libraw_strerror(ret));
free(iobuffer);
continue; // no recycle b/c open file will recycle itself
}
}
else
{
if(use_bigfile)
// force open_file switch to bigfile processing
ret = RawProcessor.open_file(argv[arg],1);
else
ret = RawProcessor.open_file(argv[arg]);
if( ret != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot open %s: %s\n",argv[arg],libraw_strerror(ret));
continue; // no recycle b/c open_file will recycle itself
}
}
if(use_timing)
timerprint("LibRaw::open_file()",argv[arg]);
timerstart();
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack %s: %s\n",argv[arg],libraw_strerror(ret));
continue;
}
if(use_timing)
timerprint("LibRaw::unpack()",argv[arg]);
timerstart();
if (LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_process()))
{
fprintf(stderr,"Cannot do postpocessing on %s: %s\n",argv[arg],libraw_strerror(ret));
if(LIBRAW_FATAL_ERROR(ret))
continue;
}
if(use_timing)
timerprint("LibRaw::dcraw_process()",argv[arg]);
snprintf(outfn,sizeof(outfn),
"%s.%s",
argv[arg], OUT.output_tiff ? "tiff" : (P1.colors>1?"ppm":"pgm"));
if(verbosity)
{
printf("Writing file %s\n",outfn);
}
if( LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_ppm_tiff_writer(outfn)))
fprintf(stderr,"Cannot write %s: %s\n",outfn,libraw_strerror(ret));
#ifndef WIN32
if(use_mmap && iobuffer)
{
munmap(iobuffer,msize);
iobuffer=0;
}
#endif
else if(use_mem && iobuffer)
{
free(iobuffer);
iobuffer = 0;
}
RawProcessor.recycle(); // just for show this call
}
return 0;
}
示例7: main
int main(int ac, char *av[])
{
int i, ret;
int autoscale=0,black_subtraction=1, use_gamma=0;
char outfn[1024];
LibRaw RawProcessor;
if(ac<2)
{
usage:
printf(
"4channeld - LibRaw %s sample. %d cameras supported\n"
"Usage: %s [-s N] [-g] [-A] [-B] [-N] raw-files....\n"
"\t-s N - select Nth image in file (default=0)\n"
"\t-g - use gamma correction with gamma 2.2 (not precise,use for visual inspection only)\n"
"\t-A - autoscaling (by integer factor)\n"
"\t-B - no black subtraction\n"
,LibRaw::version(),
LibRaw::cameraCount(),
av[0]);
return 0;
}
#define P1 RawProcessor.imgdata.idata
#define S RawProcessor.imgdata.sizes
#define C RawProcessor.imgdata.color
#define T RawProcessor.imgdata.thumbnail
#define P2 RawProcessor.imgdata.other
#define OUT RawProcessor.imgdata.params
OUT.document_mode=2;
OUT.output_bps=16;
OUT.output_tiff=1;
OUT.user_flip=0;
OUT.no_auto_bright = 1;
OUT.half_size=1;
for (i=1;i<ac;i++)
{
if(av[i][0]=='-')
{
if(av[i][1]=='s' && av[i][2]==0)
{
i++;
OUT.shot_select=atoi(av[i]);
}
else if(av[i][1]=='g' && av[i][2]==0)
use_gamma = 1;
else if(av[i][1]=='A' && av[i][2]==0)
autoscale=1;
else if(av[i][1]=='B' && av[i][2]==0)
{
black_subtraction=0;
}
else
goto usage;
continue;
}
if(!use_gamma)
OUT.gamm[0] = OUT.gamm[1] = 1;
int c;
printf("Processing file %s\n",av[i]);
if( (ret = RawProcessor.open_file(av[i])) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot open %s: %s\n",av[i],libraw_strerror(ret));
continue; // no recycle b/c open file will recycle itself
}
if(P1.is_foveon)
{
printf("Cannot process Foveon image %s\n",av[i]);
continue ;
}
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack %s: %s\n",av[i],libraw_strerror(ret));
continue;
}
RawProcessor.raw2image();
if(black_subtraction)
{
RawProcessor.subtract_black();
}
if(autoscale)
{
unsigned max=0,scale=1;
for(int j=0; j<S.iheight*S.iwidth; j++)
for(int c = 0; c< 4; c++)
if(max < RawProcessor.imgdata.image[j][c])
max = RawProcessor.imgdata.image[j][c];
if (max >0 && max< 1<<15)
{
scale = (1<<16)/max;
printf("Scaling with multiplier=%d (max=%d)\n",scale,max);
for(int j=0; j<S.iheight*S.iwidth; j++)
for(c=0;c<4;c++)
RawProcessor.imgdata.image[j][c] *= scale;
}
printf("Black level (scaled)=%d\n",C.black*scale);
//.........这里部分代码省略.........
示例8: main
int main(int ac, char *av[])
{
int i, ret;
int verbose=1,autoscale=0,use_gamma=0,out_tiff=0;
char outfn[1024];
LibRaw RawProcessor;
if(ac<2)
{
usage:
printf(
"unprocessed_raw - LibRaw %s sample. %d cameras supported\n"
"Usage: %s [-q] [-A] [-g] [-s N] raw-files....\n"
"\t-q - be quiet\n"
"\t-s N - select Nth image in file (default=0)\n"
"\t-g - use gamma correction with gamma 2.2 (not precise,use for visual inspection only)\n"
"\t-A - autoscaling (by integer factor)\n"
"\t-T - write tiff instead of pgm\n"
,LibRaw::version(),
LibRaw::cameraCount(),
av[0]);
return 0;
}
#define S RawProcessor.imgdata.sizes
#define OUT RawProcessor.imgdata.params
for (i=1; i<ac; i++)
{
if(av[i][0]=='-')
{
if(av[i][1]=='q' && av[i][2]==0)
verbose=0;
else if(av[i][1]=='A' && av[i][2]==0)
autoscale=1;
else if(av[i][1]=='g' && av[i][2]==0)
use_gamma = 1;
else if(av[i][1]=='T' && av[i][2]==0)
out_tiff = 1;
else if(av[i][1]=='s' && av[i][2]==0)
{
i++;
OUT.shot_select=av[i]?atoi(av[i]):0;
}
else
goto usage;
continue;
}
if(verbose) printf("Processing file %s\n",av[i]);
if( (ret = RawProcessor.open_file(av[i])) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot open %s: %s\n",av[i],libraw_strerror(ret));
continue; // no recycle b/c open file will recycle itself
}
if(verbose)
{
printf("Image size: %dx%d\nRaw size: %dx%d\n",S.width,S.height,S.raw_width,S.raw_height);
printf("Margins: top=%d, left=%d\n",
S.top_margin,S.left_margin);
}
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack %s: %s\n",av[i],libraw_strerror(ret));
continue;
}
if(verbose)
printf("Unpacked....\n");
if(!(RawProcessor.imgdata.idata.filters || RawProcessor.imgdata.idata.colors == 1))
{
printf("Only Bayer-pattern RAW files supported, sorry....\n");
continue;
}
if(autoscale)
{
unsigned max=0,scale;
for(int j=0; j<S.raw_height*S.raw_width; j++)
if(max < RawProcessor.imgdata.rawdata.raw_image[j])
max = RawProcessor.imgdata.rawdata.raw_image[j];
if (max >0 && max< 1<<15)
{
scale = (1<<16)/max;
if(verbose)
printf("Scaling with multiplier=%d (max=%d)\n",scale,max);
for(int j=0; j<S.raw_height*S.raw_width; j++)
RawProcessor.imgdata.rawdata.raw_image[j] *= scale;
}
}
if(use_gamma)
{
unsigned short curve[0x10000];
gamma_curve(curve);
for(int j=0; j<S.raw_height*S.raw_width; j++)
RawProcessor.imgdata.rawdata.raw_image[j]
//.........这里部分代码省略.........
示例9: main
int main(int argc, char const *argv[])
{
LibRaw rawProcessor;
rawProcessor.open_file(argv[argc-1]);
rawProcessor.unpack();
// Use 16-bit input.
buffer_t input_buf = {0};
input_buf.host = (uint8_t *)rawProcessor.imgdata.rawdata.raw_image;
input_buf.stride[0] = 1;
input_buf.stride[1] = rawProcessor.imgdata.sizes.width;
input_buf.extent[0] = rawProcessor.imgdata.sizes.width;
input_buf.extent[1] = rawProcessor.imgdata.sizes.height;
input_buf.elem_size = sizeof(*rawProcessor.imgdata.rawdata.raw_image);
// Allocate WxH 16-bit, 3 channel output buffer.
buffer_t output_buf = {0};
output_buf.stride[0] = 1;
output_buf.stride[1] = rawProcessor.imgdata.sizes.width;
output_buf.stride[2] = rawProcessor.imgdata.sizes.width * rawProcessor.imgdata.sizes.height;
output_buf.stride[3] = rawProcessor.imgdata.sizes.width * rawProcessor.imgdata.sizes.height * 3;
output_buf.extent[0] = rawProcessor.imgdata.sizes.width;
output_buf.extent[1] = rawProcessor.imgdata.sizes.height;
output_buf.extent[2] = 3;
output_buf.elem_size = 2;
uint8_t *output_data = new uint8_t[sizeof(uint16_t) * rawProcessor.imgdata.sizes.width * rawProcessor.imgdata.sizes.height * 3];
output_buf.host = output_data;
output_buf.host_dirty = false;
output_buf.dev_dirty = false;
output_buf.dev = 0;
for (int i = 0; i<20; i++) {
auto start = std::chrono::system_clock::now();
input_buf.host_dirty = true;
halide_copy_to_device(NULL, &input_buf, halide_opencl_device_interface());
std::cout << "Input: " << std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now()-start).count() << std::endl;
buffer_t input_no_host = *(&input_buf);
input_no_host.host = NULL;
buffer_t output_no_host = *(&output_buf);
output_no_host.host = (uint8_t *)1;
igd_demosaic(&input_no_host, 0, &output_no_host);
std::cout << "Halide: " << std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now()-start).count() << std::endl;
output_no_host.host = output_data;
halide_copy_to_host(NULL, &output_no_host);
std::cout << "Output: " << std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now()-start).count() << std::endl << std::endl;
}
//Halide::Tools::Image<uint16_t> output_image = Image<uint16_t>(&output_buf, "output");
//output_image.copy_to_host();
//Tools::save_image(output_image, "test.png");
return 0;
}
示例10: if
bool
RawInput::open (const std::string &name, ImageSpec &newspec,
const ImageSpec &config)
{
int ret;
// open the image
if ( (ret = m_processor.open_file(name.c_str()) ) != LIBRAW_SUCCESS) {
error ("Could not open file \"%s\", %s", name.c_str(), libraw_strerror(ret));
return false;
}
if ( (ret = m_processor.unpack() ) != LIBRAW_SUCCESS) {
error ("Could not unpack \"%s\", %s",name.c_str(), libraw_strerror(ret));
return false;
}
// Forcing the Libraw to adjust sizes based on the capture device orientation
m_processor.adjust_sizes_info_only();
// Set file information
m_spec = ImageSpec(m_processor.imgdata.sizes.iwidth,
m_processor.imgdata.sizes.iheight,
3, // LibRaw should only give us 3 channels
TypeDesc::UINT16);
// Output 16 bit images
m_processor.imgdata.params.output_bps = 16;
// Set the gamma curve to Linear
m_spec.attribute("oiio:ColorSpace","Linear");
m_processor.imgdata.params.gamm[0] = 1.0;
m_processor.imgdata.params.gamm[1] = 1.0;
// Check to see if the user has explicitly set the output colorspace primaries
std::string cs = config.get_string_attribute ("raw:ColorSpace", "sRGB");
if (cs.size()) {
static const char *colorspaces[] = { "raw",
"sRGB",
"Adobe",
"Wide",
"ProPhoto",
"XYZ", NULL
};
size_t c;
for (c=0; c < sizeof(colorspaces) / sizeof(colorspaces[0]); c++)
if (cs == colorspaces[c])
break;
if (cs == colorspaces[c])
m_processor.imgdata.params.output_color = c;
else {
error("raw:ColorSpace set to unknown value");
return false;
}
// Set the attribute in the output spec
m_spec.attribute("raw:ColorSpace", cs);
} else {
// By default we use sRGB primaries for simplicity
m_processor.imgdata.params.output_color = 1;
m_spec.attribute("raw:ColorSpace", "sRGB");
}
// Exposure adjustment
float exposure = config.get_float_attribute ("raw:Exposure", -1.0f);
if (exposure >= 0.0f) {
if (exposure < 0.25f || exposure > 8.0f) {
error("raw:Exposure invalid value. range 0.25f - 8.0f");
return false;
}
m_processor.imgdata.params.exp_correc = 1; // enable exposure correction
m_processor.imgdata.params.exp_shift = exposure; // set exposure correction
// Set the attribute in the output spec
m_spec.attribute ("raw:Exposure", exposure);
}
// Interpolation quality
// note: LibRaw must be compiled with demosaic pack GPL2 to use
// demosaic algorithms 5-9. It must be compiled with demosaic pack GPL3 for
// algorithm 10. If either of these packs are not includeded, it will silently use option 3 - AHD
std::string demosaic = config.get_string_attribute ("raw:Demosaic");
if (demosaic.size()) {
static const char *demosaic_algs[] = { "linear",
"VNG",
"PPG",
"AHD",
"DCB",
"Modified AHD",
"AFD",
"VCD",
"Mixed",
"LMMSE",
"AMaZE",
// Future demosaicing algorithms should go here
NULL
};
size_t d;
for (d=0; d < sizeof(demosaic_algs) / sizeof(demosaic_algs[0]); d++)
if (demosaic == demosaic_algs[d])
break;
//.........这里部分代码省略.........
示例11: try_reading_file_with_libraw
// reads the RAW as it is.
// If multi-frame RAW, reads each frame to a different channel (available from libraw 1.8)
int try_reading_file_with_libraw(const char *fname, struct iio_image *x)
{
int ret;
int verbose=0;
LibRaw RawProcessor;
#define P1 RawProcessor.imgdata.idata
#define S RawProcessor.imgdata.sizes
#define OUT RawProcessor.imgdata.params
// Open to obtain raw_count
if(verbose) fprintf(stderr,"LIBRAW: Processing file %s\n",fname);
if( (ret = RawProcessor.open_file(fname)) != LIBRAW_SUCCESS)
{
if(verbose) fprintf(stderr,"LIBRAW: Cannot open %s: %s\n",fname,libraw_strerror(ret));
return 0; // no recycle b/c open file will recycle itself
}
if(verbose)
fprintf(stderr, "FRAMES: %d\n", P1.raw_count);
// allocate output assuming that all frames are the same size as the first one
x->type = 3; //IIO_TYPE_INT16;
x->pixel_dimension=P1.raw_count;
x->dimension = 2;
x->format = 0; //IIO_FORMAT_WHATEVER;
x->contiguous_data = false;
//bool caca[3];
x->sizes[0] = S.raw_width;
x->sizes[1] = S.raw_height;
x->data = (void*) malloc(sizeof(char)*2*S.raw_width*S.raw_height*P1.raw_count);
for(int f=0;f<P1.raw_count; f++) {
// select each frame in turn (assuming that all frames are the same size)
OUT.shot_select=f;
if(verbose) fprintf(stderr,"LIBRAW: Processing file %s\n",fname);
if( (ret = RawProcessor.open_file(fname)) != LIBRAW_SUCCESS)
{
if(verbose) fprintf(stderr,"LIBRAW: Cannot open %s: %s\n",fname,libraw_strerror(ret));
return 0; // no recycle b/c open file will recycle itself
}
if(verbose)
{
fprintf(stderr,"LIBRAW: Image size: %dx%d\nRaw size: %dx%d\n",S.width,S.height,S.raw_width,S.raw_height);
fprintf(stderr,"LIBRAW: Margins: top=%d, left=%d\n",
S.top_margin,S.left_margin);
}
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
if(verbose) fprintf(stderr,"LIBRAW: Cannot unpack %s: %s\n",fname,libraw_strerror(ret));
return 0;
}
if(verbose)
fprintf(stderr,"LIBRAW: Unpacked....\n");
if(!(RawProcessor.imgdata.idata.filters || RawProcessor.imgdata.idata.colors == 1))
{
if(verbose) fprintf(stderr,"LIBRAW: Only Bayer-pattern RAW files supported, sorry....\n");
return 0;
}
const int stride = P1.raw_count;
const int sz = S.raw_width*S.raw_height;
uint16_t* odata = (uint16_t*)x->data;
if (P1.raw_count==1) {
memcpy(odata, RawProcessor.imgdata.rawdata.raw_image, sizeof(uint16_t)*sz*stride);
} else {
for(int t=0; t<sz; t++) odata[stride*t+f] = RawProcessor.imgdata.rawdata.raw_image[t];
}
}
if(verbose) fprintf(stderr,"LIBRAW: Sent to IIO\n");
return 1;
}
示例12: try_reading_file_with_libraw_4channels
// reads the RAW and builds a 4 channel image
int try_reading_file_with_libraw_4channels(const char *fname, struct iio_image *x)
{
int ret;
int verbose=0;
int shot_select = 0;
LibRaw RawProcessor;
#define S RawProcessor.imgdata.sizes
#define OUT RawProcessor.imgdata.params
//
//OUT.shot_select=shot_selected;
if(verbose) fprintf(stderr,"LIBRAW: Processing file %s\n",fname);
if( (ret = RawProcessor.open_file(fname)) != LIBRAW_SUCCESS)
{
if(verbose) fprintf(stderr,"LIBRAW: Cannot open %s: %s\n",fname,libraw_strerror(ret));
return 0; // no recycle b/c open file will recycle itself
}
if(RawProcessor.imgdata.idata.is_foveon)
{
if(verbose) fprintf(stderr,"LIBRAW: Cannot process Foveon image %s\n",fname);
return 0;
}
if(verbose)
{
fprintf(stderr,"LIBRAW: Image size: %dx%d\nRaw size: %dx%d\n",S.width,S.height,S.raw_width,S.raw_height);
fprintf(stderr,"LIBRAW: Margins: top=%d, left=%d\n",
S.top_margin,S.left_margin);
}
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
if(verbose) fprintf(stderr,"LIBRAW: Cannot unpack %s: %s\n",fname,libraw_strerror(ret));
return 0;
}
if(verbose)
fprintf(stderr,"LIBRAW: Unpacked....\n");
if(!(RawProcessor.imgdata.idata.filters || RawProcessor.imgdata.idata.colors == 1))
{
if(verbose) fprintf(stderr,"LIBRAW: Only Bayer-pattern RAW files supported, sorry....\n");
return 0;
}
RawProcessor.raw2image();
RawProcessor.imgdata.idata.colors = 1;
S.width = S.iwidth;
S.height = S.iheight;
x->type = 3; //IIO_TYPE_INT16;
x->pixel_dimension = 4;
x->dimension = 2;
x->format = 0; //IIO_FORMAT_WHATEVER;
x->contiguous_data = false;
//bool caca[3];
x->sizes[0] = S.iwidth/2;
x->sizes[1] = S.iheight/2;
x->data = (void*) malloc(sizeof(uint16_t)*S.iwidth/2 * S.iheight/2 * 4);
uint16_t * odata = (uint16_t*)x->data;
int ncout = S.iwidth/2;
int color[] = {0,1,3,2};
for (int j=0; j<2; j++)
for (int i=0; i<2; i++)
for (int rr = 0; rr < S.iheight/2; rr++)
for (int rc = 0; rc < S.iwidth/2; rc++) {
odata[(rr*S.iwidth/2 + rc)*4 +color[i+2*j]] =
RawProcessor.imgdata.image[(2*rr+j)*S.iwidth + 2*rc+i][color[i+2*j]];
}
if(verbose) fprintf(stderr,"LIBRAW: Sent to IIO\n");
return 1;
}
示例13: main
int main(int ac, char *av[])
{
int i, ret, output_thumbs=0;
// don't use fixed size buffers in real apps!
LibRaw RawProcessor;
if(ac<2)
{
printf(
"mem_image - LibRaw sample, to illustrate work for memory buffers. Emulates dcraw [-4] [-1] [-e] [-h]\n"
"Usage: %s [-D] [-T] [-v] [-e] raw-files....\n"
"\t-6 - output 16-bit PPM\n"
"\t-4 - linear 16-bit data\n"
"\t-e - extract thumbnails (same as dcraw -e in separate run)\n",
"\t-h - use half_size\n");
return 0;
}
putenv ((char*)"TZ=UTC"); // dcraw compatibility, affects TIFF datestamp field
#define P1 RawProcessor.imgdata.idata
#define S RawProcessor.imgdata.sizes
#define C RawProcessor.imgdata.color
#define T RawProcessor.imgdata.thumbnail
#define P2 RawProcessor.imgdata.other
#define OUT RawProcessor.imgdata.params
for (i=1;i<ac;i++)
{
if(av[i][0]=='-')
{
if(av[i][1]=='6' && av[i][2]==0)
OUT.output_bps = 16;
if(av[i][1]=='4' && av[i][2]==0)
{
OUT.output_bps = 16;
OUT.gamm[0] = OUT.gamm[1] = OUT.no_auto_bright = 1;
}
if(av[i][1]=='e' && av[i][2]==0)
output_thumbs++;
if(av[i][1]=='h' && av[i][2]==0)
OUT.half_size=1;
continue;
}
printf("Processing %s\n",av[i]);
if( (ret = RawProcessor.open_file(av[i])) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot open %s: %s\n",av[i],libraw_strerror(ret));
continue; // no recycle b/c open file will recycle itself
}
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack %s: %s\n",av[i],libraw_strerror(ret));
continue;
}
// we should call dcraw_process before thumbnail extraction because for
// some cameras (i.e. Kodak ones) white balance for thumbnal should be set
// from main image settings
ret = RawProcessor.dcraw_process();
if(LIBRAW_SUCCESS !=ret)
{
fprintf(stderr,"Cannot do postpocessing on %s: %s\n",
av[i],libraw_strerror(ret));
if(LIBRAW_FATAL_ERROR(ret))
continue;
}
libraw_processed_image_t *image = RawProcessor.dcraw_make_mem_image(&ret);
if(image)
{
write_ppm(image,av[i]);
LibRaw::dcraw_clear_mem(image);
}
else
fprintf(stderr,"Cannot unpack %s to memory buffer: %s\n" , av[i],libraw_strerror(ret));
if(output_thumbs)
{
if( (ret = RawProcessor.unpack_thumb() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack_thumb %s: %s\n",av[i],libraw_strerror(ret));
if(LIBRAW_FATAL_ERROR(ret))
continue; // skip to next file
}
else
{
libraw_processed_image_t *thumb = RawProcessor.dcraw_make_mem_thumb(&ret);
if(thumb)
{
write_thumb(thumb,av[i]);
LibRaw::dcraw_clear_mem(thumb);
}
//.........这里部分代码省略.........
示例14: main
int main(int argc, char *argv[])
{
int i, ret,rep=1;
LibRaw RawProcessor;
#ifdef OUT
#undef OUT
#endif
#define OUT RawProcessor.imgdata.params
#define S RawProcessor.imgdata.sizes
if(argc<2)
{
printf(
"postprocessing benchmark: LibRaw %s sample, %d cameras supported\n"
"Measures postprocessing speed with different options\n"
"Usage: %s [-a] [-H N] [-q N] [-h] [-m N] [-n N] [-s N] [-B x y w h] [-R N]\n"
"-a average image for white balance\n"
"-H <num> Highlight mode (0=clip, 1=unclip, 2=blend, 3+=rebuild)\n"
"-q <num> Set the interpolation quality\n"
"-h Half-size color image\n"
"-m <num> Apply a num-passes 3x3 median filter to R-G and B-G\n"
"-n <num> Set threshold for wavelet denoising\n"
"-s <num> Select one raw image from input file\n"
"-B <x y w h> Crop output image\n"
"-R <num> Number of repetitions\n"
"-c Do not use rawspeed\n"
,LibRaw::version(), LibRaw::cameraCount(),
argv[0]);
return 0;
}
char opm,opt,*cp,*sp;
int arg,c;
int shrink = 0;
argv[argc] = (char*)"";
for (arg=1; (((opm = argv[arg][0]) - 2) | 2) == '+'; )
{
char *optstr = argv[arg];
opt = argv[arg++][1];
if ((cp = strchr (sp=(char*)"HqmnsBR", opt))!=0)
for (i=0; i < "1111141"[cp-sp]-'0'; i++)
if (!isdigit(argv[arg+i][0]) && !optstr[2])
{
fprintf (stderr,"Non-numeric argument to \"-%c\"\n", opt);
return 1;
}
switch (opt)
{
case 'a':
OUT.use_auto_wb = 1;
break;
case 'H':
OUT.highlight = atoi(argv[arg++]);
break;
case 'q':
OUT.user_qual = atoi(argv[arg++]);
break;
case 'h':
OUT.half_size = 1;
OUT.four_color_rgb = 1;
shrink = 1;
break;
case 'm':
OUT.med_passes = atoi(argv[arg++]);
break;
case 'n':
OUT.threshold = (float)atof(argv[arg++]);
break;
case 's':
OUT.shot_select = abs(atoi(argv[arg++]));
break;
case 'B':
for(c=0; c<4;c++) OUT.cropbox[c] = atoi(argv[arg++]);
break;
case 'R':
rep = abs(atoi(argv[arg++]));
if(rep<1) rep = 1;
break;
case 'c':
OUT.use_rawspeed = 0;
break;
default:
fprintf (stderr,"Unknown option \"-%c\".\n", opt);
return 1;
}
}
for ( ; arg < argc; arg++)
{
printf("Processing file %s\n",argv[arg]);
timerstart();
if( (ret = RawProcessor.open_file(argv[arg])) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot open_file %s: %s\n",argv[arg],libraw_strerror(ret));
continue; // no recycle b/c open file will recycle itself
}
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack %s: %s\n",argv[arg],libraw_strerror(ret));
continue;
//.........这里部分代码省略.........
示例15: execute
bool NefImporter::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
if (pInArgList == NULL || pOutArgList == NULL)
{
return false;
}
//setting up mpRasterElement
parseInputArgList(pInArgList);
RasterElement* pRaster = getRasterElement();
VERIFY(pRaster != NULL);
RasterDataDescriptor *pDescriptor = dynamic_cast<RasterDataDescriptor*>(pRaster->getDataDescriptor());
VERIFY(pDescriptor != NULL);
FileDescriptor *pFileDescriptor = pDescriptor->getFileDescriptor();
VERIFY(pFileDescriptor != NULL);
//data accessor
//RED
DimensionDescriptor firstBand = pDescriptor->getActiveBand(0);
FactoryResource<DataRequest> pRequest;
pRequest->setInterleaveFormat(BSQ);
pRequest->setBands(firstBand, firstBand);
pRequest->setWritable(true);
DataAccessor firstBandDa = pRaster->getDataAccessor(pRequest.release());
//GREEN
DimensionDescriptor secondBand = pDescriptor->getActiveBand(1);
FactoryResource<DataRequest> qRequest;
qRequest->setInterleaveFormat(BSQ);
qRequest->setBands(secondBand, secondBand);
qRequest->setWritable(true);
DataAccessor secondBandDa = pRaster->getDataAccessor(qRequest.release());
//BLUE
DimensionDescriptor thirdBand = pDescriptor->getActiveBand(2);
FactoryResource<DataRequest> rRequest;
rRequest->setInterleaveFormat(BSQ);
rRequest->setBands(thirdBand, thirdBand);
rRequest->setWritable(true);
DataAccessor thirdBandDa = pRaster->getDataAccessor(rRequest.release());
std::string filename = pRaster->getFilename();
Progress *pProgress = getProgress();
FactoryResource<Filename> pFilename;
pFilename->setFullPathAndName(filename);
LibRaw RawProcessor;
putenv ((char*)"TZ=UTC");
#define P1 RawProcessor.imgdata.idata
#define S RawProcessor.imgdata.sizes
#define C RawProcessor.imgdata.color
#define T RawProcessor.imgdata.thumbnail
#define P2 RawProcessor.imgdata.other
#define OUT RawProcessor.imgdata.params
const char *fname=filename.c_str();
RawProcessor.open_file(fname);
// Let us unpack the image
if (RawProcessor.unpack() != LIBRAW_SUCCESS)
{
return false;
}
/*
unsigned int *r=NULL;
unsigned int *g=NULL;
unsigned int *b=NULL;
unsigned int *h=NULL;
*/
unsigned int *zero=0;
int row=0,col=0,r=0,c=0;
/*
r=(unsigned int*)(&RawProcessor.imgdata.image[i][0]);
g=(unsigned int*)(&RawProcessor.imgdata.image[i][1]);
b=(unsigned int*)(&RawProcessor.imgdata.image[i][2]);
h=(unsigned int*)(&RawProcessor.imgdata.image[i][3]);
*/
//secondBandDa->toPixel(row,col);
//thirdBandDa->toPixel(row,col);
unsigned short *pData=reinterpret_cast<unsigned short*>(pRaster->getRawData());
if (pData == NULL)
{
return NULL;
}
memcpy(pData, RawProcessor.imgdata.rawdata.raw_image, sizeof(unsigned short) * RawProcessor.imgdata.sizes.raw_height * RawProcessor.imgdata.sizes.raw_width);
//.........这里部分代码省略.........