现在大多数的数码相机都带拍摄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

本文介绍了如何从数码相机的raw照片中提取Bayer Pattern Image和raw照片参数。通过理解Adobe的DNG规范,以及利用开源库LibRaw,可以进行自定义的raw照片后期处理。通过改造LibRaw的unprocessed_raw应用程序,读者可以深入数字图像处理领域。
最低0.47元/天 解锁文章
2467

被折叠的 条评论
为什么被折叠?



