如何从数码相机的raw照片中提取Bayer Pattern Image和raw照片参数

  现在大多数的数码相机都带拍摄raw照片的功能,和直出的jpeg照片不同,raw片具有很大的后期处理空间。Adobe制定了DNG(Digital Negative)规范,这个规范目前已经到了版本1.4。DNG是开放的规范,大家只要有兴趣,都可以到Adobe的网站下下载Digital Negative (DNG) Specification。虽然DNG是开放的规范,但是大多数的大牌数码相机厂商还不支持DNG,因此Adobe搞了个DNGConverter。

 

  有了raw照片,你可以用ps或light room做后期。如果你想自己做raw照片处理呢?那么请跟随ispforfun的脚步,ispforfun将带你走进数字图像处理。

 

  让我们从raw照片的参数提取和Bayer Pattern Image的分离开始吧。

 

  LibRaw: http://www.libraw.org/

  LibRaw的工程中包含了一个应用程序unprocessed_raw,让我们一起改造这个应用程序。

<p> </p><pre class="cpp" name="code">/* -*- C++ -*-
 * File: unprocessed_raw.cpp
 * Copyright 2009-2013 LibRaw LLC (info@libraw.org)
 * Created: Fri Jan 02, 2009
 *
 * LibRaw sample
 * Generates unprocessed raw image: with masked pixels and without black subtraction
 *

LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:

1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
   (See file LICENSE.LGPL provided in LibRaw distribution archive for details).

2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
   (See file LICENSE.CDDL provided in LibRaw distribution archive for details).

3. LibRaw Software License 27032010
   (See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).

 */

/*
   Modified by ispforfun
   1. add more dump information for camera raw images.
   2. write out naive raw file.
*/
 
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#ifndef WIN32
#include <netinet/in.h>
#else
#include <sys/utime.h>
#include <winsock2.h>
#endif

#include "libraw/libraw.h"

#ifdef WIN32
#define snprintf _snprintf
#endif

#if !(LIBRAW_COMPILE_CHECK_VERSION_NOTLESS(0,14))
#error This code is for LibRaw 0.14+ only
#endif

void  gamma_curve (unsigned short curve[]);
void write_ppm(unsigned width, unsigned height, unsigned short *bitmap, const char *basename);
void write_tiff(int width, int height, unsigned short *bitmap, const char *basename);
// added by ispforfun
void write_raw(int width, int height, unsigned short *bitmap, const char *fn);


int main(int ac, char *av[])
{
    int  i, ret;
    int v
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值