view release on metacpan or search on metacpan
src/Source/FreeImage/WuQuantizer.cpp view on Meta::CPAN
+gm2[INDEX(cube->r0, cube->g1, cube->b0)]
+gm2[INDEX(cube->r0, cube->g0, cube->b1)]
-gm2[INDEX(cube->r0, cube->g0, cube->b0)];
return (xx - (dr*dr+dg*dg+db*db)/(float)Vol(cube,wt));
}
// We want to minimize the sum of the variances of two subboxes.
// The sum(c^2) terms can be ignored since their sum over both subboxes
// is the same (the sum for the whole box) no matter where we split.
// The remaining terms have a minus sign in the variance formula,
// so we drop the minus sign and MAXIMIZE the sum of the two terms.
float
WuQuantizer::Maximize(Box *cube, BYTE dir, int first, int last , int *cut, LONG whole_r, LONG whole_g, LONG whole_b, LONG whole_w) {
LONG half_r, half_g, half_b, half_w;
int i;
float temp;
LONG base_r = Bottom(cube, dir, mr);
LONG base_g = Bottom(cube, dir, mg);
src/Source/FreeImage/tmoReinhard05.cpp view on Meta::CPAN
// get statistics about the data (but only if its really needed)
f = exp(-f);
if((m == 0) || (a != 1) && (c != 1)) {
// avoid these calculations if its not needed after ...
LuminanceFromY(Y, &maxLum, &minLum, &Lav, &Llav);
k = (log(maxLum) - Llav) / (log(maxLum) - log(minLum));
if(k < 0) {
// pow(k, 1.4F) is undefined ...
// there's an ambiguity about the calculation of Llav between Reinhard papers and the various implementations ...
// try another world adaptation luminance formula using instead 'worldLum = log(Llav)'
k = (log(maxLum) - log(Llav)) / (log(maxLum) - log(minLum));
if(k < 0) m = 0.3F;
}
}
m = (m > 0) ? m : (float)(0.3 + 0.7 * pow(k, 1.4F));
float max_color = -1e6F;
float min_color = +1e6F;
// tone map image
src/Source/FreeImageToolkit/MultigridPoissonSolver.cpp view on Meta::CPAN
const int rhs_pitch = FreeImage_GetPitch(RHS) / sizeof(float);
float *u_bits = (float*)FreeImage_GetBits(U);
const float *rhs_bits = (float*)FreeImage_GetBits(RHS);
for (ipass = 0, jsw = 1; ipass < 2; ipass++, jsw = 3-jsw) { // Red and black sweeps
float *u_scan = u_bits + u_pitch;
const float *rhs_scan = rhs_bits + rhs_pitch;
for (row = 1, isw = jsw; row < n-1; row++, isw = 3-isw) {
for (col = isw; col < n-1; col += 2) {
// Gauss-Seidel formula
// calculate U(row, col) =
// 0.25 * [ U(row+1, col) + U(row-1, col) + U(row, col+1) + U(row, col-1) - h2 * RHS(row, col) ]
float *u_center = u_scan + col;
const float *rhs_center = rhs_scan + col;
*u_center = *(u_center + u_pitch) + *(u_center - u_pitch) + *(u_center + 1) + *(u_center - 1);
*u_center -= h2 * *rhs_center;
*u_center *= 0.25F;
}
u_scan += u_pitch;
rhs_scan += rhs_pitch;
src/Source/LibJPEG/jaricom.c view on Meta::CPAN
* ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81, and Table 24
* in the JBIG spec, ISO/IEC IS 11544 and CCITT Recommendation ITU-T T.82.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
/* The following #define specifies the packing of the four components
* into the compact INT32 representation.
* Note that this formula must match the actual arithmetic encoder
* and decoder implementation. The implementation has to be changed
* if this formula is changed.
* The current organization is leaned on Markus Kuhn's JBIG
* implementation (jbig_tab.c).
*/
#define V(i,a,b,c,d) (((INT32)a << 16) | ((INT32)c << 8) | ((INT32)d << 7) | b)
const INT32 jpeg_aritab[113+1] = {
/*
* Index, Qe_Value, Next_Index_LPS, Next_Index_MPS, Switch_MPS
*/
src/Source/LibJPEG/jcarith.c view on Meta::CPAN
* This 1 byte per statistics bin contains the meaning of the MPS
* (more probable symbol) in the highest bit (mask 0x80), and the
* index into the probability estimation state machine table
* in the lower bits (mask 0x7F).
*/
#define DC_STAT_BINS 64
#define AC_STAT_BINS 256
/* NOTE: Uncomment the following #define if you want to use the
* given formula for calculating the AC conditioning parameter Kx
* for spectral selection progressive coding in section G.1.3.2
* of the spec (Kx = Kmin + SRL (8 + Se - Kmin) 4).
* Although the spec and P&M authors claim that this "has proven
* to give good results for 8 bit precision samples", I'm not
* convinced yet that this is really beneficial.
* Early tests gave only very marginal compression enhancements
* (a few - around 5 or so - bytes even for very large files),
* which would turn out rather negative if we'd suppress the
* DAC (Define Arithmetic Conditioning) marker segments for
* the default parameters in the future.
src/Source/LibJPEG/jcarith.c view on Meta::CPAN
* anyway), one might optimize this behaviour in the future,
* and then it would be disadvantageous to use custom tables if
* they don't provide sufficient gain to exceed the DAC size.
*
* On the other hand, I'd consider it as a reasonable result
* that the conditioning has no significant influence on the
* compression performance. This means that the basic
* statistical model is already rather stable.
*
* Thus, at the moment, we use the default conditioning values
* anyway, and do not use the custom formula.
*
#define CALCULATE_SPECTRAL_CONDITIONING
*/
/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32.
* We assume that int right shift is unsigned if INT32 right shift is,
* which should be safe.
*/
#ifdef RIGHT_SHIFT_IS_UNSIGNED
src/Source/LibPNG/libpng-manual.txt view on Meta::CPAN
The default values come from the PNG file cHRM chunk if present; otherwise, the
defaults correspond to the ITU-R recommendation 709, and also the sRGB color
space, as recommended in the Charles Poynton's Colour FAQ,
<http://www.poynton.com/>, in section 9:
<http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC9>
Y = 0.2126 * R + 0.7152 * G + 0.0722 * B
Previous versions of this document, 1998 through 2002, recommended a slightly
different formula:
Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
Libpng uses an integer approximation:
Y = (6968 * R + 23434 * G + 2366 * B)/32768
The calculation is done in a linear colorspace, if the image gamma
can be determined.
src/Source/LibPNG/libpng.3 view on Meta::CPAN
The default values come from the PNG file cHRM chunk if present; otherwise, the
defaults correspond to the ITU-R recommendation 709, and also the sRGB color
space, as recommended in the Charles Poynton's Colour FAQ,
<http://www.poynton.com/>, in section 9:
<http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC9>
Y = 0.2126 * R + 0.7152 * G + 0.0722 * B
Previous versions of this document, 1998 through 2002, recommended a slightly
different formula:
Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
Libpng uses an integer approximation:
Y = (6968 * R + 23434 * G + 2366 * B)/32768
The calculation is done in a linear colorspace, if the image gamma
can be determined.
src/Source/LibPNG/png.c view on Meta::CPAN
* We want log2(value/65535), we have log2(v'/255), where:
*
* value = v' * 256 + v''
* = v' * f
*
* So f is value/v', which is equal to (256+v''/v') since v' is in the range 128
* to 255 and v'' is in the range 0 to 255 f will be in the range 256 to less
* than 258. The final factor also needs to correct for the fact that our 8-bit
* value is scaled by 255, whereas the 16-bit values must be scaled by 65535.
*
* This gives a final formula using a calculated value 'x' which is value/v' and
* scaling by 65536 to match the above table:
*
* log2(x/257) * 65536
*
* Since these numbers are so close to '1' we can use simple linear
* interpolation between the two end values 256/257 (result -368.61) and 258/257
* (result 367.179). The values used below are scaled by a further 64 to give
* 16-bit precision in the interpolation:
*
* Start (256): -23591
src/Source/LibPNG/pngrtran.c view on Meta::CPAN
int r, g, b, p;
sp = row;
dp = row;
for (i = 0; i < row_width; i++)
{
r = *sp++;
g = *sp++;
b = *sp++;
/* This looks real messy, but the compiler will reduce
* it down to a reasonable formula. For example, with
* 5 bits per color, we get:
* p = (((r >> 3) & 0x1f) << 10) |
* (((g >> 3) & 0x1f) << 5) |
* ((b >> 3) & 0x1f);
*/
p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) &
((1 << PNG_QUANTIZE_RED_BITS) - 1)) <<
(PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) |
(((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) &
((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) <<
src/Source/LibTIFF4/ChangeLog view on Meta::CPAN
* libtiff/tif_read.c: Make sure tif_rawdatasize is cleared when tif_rawdata is freed.
* libtiff/tif_getimage.c: Add support for greyscale+alpha c/o Jérémie Laval.
http://bugzilla.maptools.org/show_bug.cgi?id=2398
2012-05-29 Frank Warmerdam <warmerdam@google.com>
* libtiff/tif_dir.c: avoid using specific set/get logic to process fields in custom directories,
like EXIF directories. This fixes problems like a tag "320" existing in a custom directory getting
processed as if it were a colormap when it isn't really. Damn the wide variety of argument formulations
to get/set functions for different tags!
* libtiff/tif_dir.c: Ensure that we keep track of when tif_rawdata
is a pointer into an mmap()ed file via TIFF_BUFFERMMAP flag.
2012-05-24 Frank Warmerdam <warmerdam@google.com>
* libtiff/tif_pixarlog.c: Allocate working buffer one word larger since we "forward
accumulate" and overwrite the end by one word in at least some cases.
src/Source/LibWebP/src/dsp/yuv.h view on Meta::CPAN
// V = 0.4394 * R - 0.3679 * G - 0.0715 * B + 128
// We use 16bit fixed point operations for RGB->YUV conversion (YUV_FIX).
//
// For the Y'CbCr to RGB conversion, the BT.601 specification reads:
// R = 1.164 * (Y-16) + 1.596 * (V-128)
// G = 1.164 * (Y-16) - 0.813 * (V-128) - 0.391 * (U-128)
// B = 1.164 * (Y-16) + 2.018 * (U-128)
// where Y is in the [16,235] range, and U/V in the [16,240] range.
// In the table-lookup version (WEBP_YUV_USE_TABLE), the common factor
// "1.164 * (Y-16)" can be handled as an offset in the VP8kClip[] table.
// So in this case the formulae should read:
// R = 1.164 * [Y + 1.371 * (V-128) ] - 18.624
// G = 1.164 * [Y - 0.698 * (V-128) - 0.336 * (U-128)] - 18.624
// B = 1.164 * [Y + 1.733 * (U-128)] - 18.624
// once factorized.
// For YUV->RGB conversion, only 14bit fixed precision is used (YUV_FIX2).
// That's the maximum possible for a convenient ARM implementation.
//
// Author: Skal (pascal.massimino@gmail.com)
#ifndef WEBP_DSP_YUV_H_
src/Source/LibWebP/src/enc/enc.picture_csp.c view on Meta::CPAN
#define SUM2(ptr) \
LinearToGamma(GammaToLinear((ptr)[0]) + GammaToLinear((ptr)[rgb_stride]), 1)
#define SUM2ALPHA(ptr) ((ptr)[0] + (ptr)[rgb_stride])
#define SUM4ALPHA(ptr) (SUM2ALPHA(ptr) + SUM2ALPHA((ptr) + 4))
#if defined(USE_INVERSE_ALPHA_TABLE)
static const int kAlphaFix = 19;
// Following table is (1 << kAlphaFix) / a. The (v * kInvAlpha[a]) >> kAlphaFix
// formula is then equal to v / a in most (99.6%) cases. Note that this table
// and constant are adjusted very tightly to fit 32b arithmetic.
// In particular, they use the fact that the operands for 'v / a' are actually
// derived as v = (a0.p0 + a1.p1 + a2.p2 + a3.p3) and a = a0 + a1 + a2 + a3
// with ai in [0..255] and pi in [0..1<<kGammaFix). The constraint to avoid
// overflow is: kGammaFix + kAlphaFix <= 31.
static const uint32_t kInvAlpha[4 * 0xff + 1] = {
0, /* alpha = 0 */
524288, 262144, 174762, 131072, 104857, 87381, 74898, 65536,
58254, 52428, 47662, 43690, 40329, 37449, 34952, 32768,
30840, 29127, 27594, 26214, 24966, 23831, 22795, 21845,
src/Source/Utilities.h view on Meta::CPAN
SwapLong(DWORD *lp) {
*lp = __SwapUInt32(*lp);
}
// ==========================================================
// Greyscale and color conversion
// ==========================================================
/**
Extract the luminance channel L from a RGBF image.
Luminance is calculated from the sRGB model using a D65 white point, using the Rec.709 formula :
L = ( 0.2126 * r ) + ( 0.7152 * g ) + ( 0.0722 * b )
Reference :
A Standard Default Color Space for the Internet - sRGB.
[online] http://www.w3.org/Graphics/Color/sRGB
*/
#define LUMA_REC709(r, g, b) (0.2126F * r + 0.7152F * g + 0.0722F * b)
#define GREY(r, g, b) (BYTE)(LUMA_REC709(r, g, b) + 0.5F)
/*
#define GREY(r, g, b) (BYTE)(((WORD)r * 77 + (WORD)g * 150 + (WORD)b * 29) >> 8) // .299R + .587G + .114B
src/Source/ZLib/adler32.c view on Meta::CPAN
z_off64_t len2;
{
unsigned long sum1;
unsigned long sum2;
unsigned rem;
/* for negative len, return invalid adler32 as a clue for debugging */
if (len2 < 0)
return 0xffffffffUL;
/* the derivation of this formula is left as an exercise for the reader */
MOD63(len2); /* assumes len2 >= 0 */
rem = (unsigned)len2;
sum1 = adler1 & 0xffff;
sum2 = rem * sum1;
MOD(sum2);
sum1 += (adler2 & 0xffff) + BASE - 1;
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
if (sum1 >= BASE) sum1 -= BASE;
if (sum1 >= BASE) sum1 -= BASE;
if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
src/Whatsnew.txt view on Meta::CPAN
+ [Herve Drolon] added support for PNG tIME metadata (read/write, handle as Exif-TIFF DateTime)
+ [Carsten Klein] added explicit definition of endianness and color order in compiler options
+ [Carsten Klein] added FIQ_LFPQUANT quantizer algorithm
+ [Carsten Klein] added support for input 32-bit dib in Wu quantizer
+ [Tanner Helland] added FreeImage_ConvertToRGBAF and updated conversions in FreeImage_ConvertToType
+ [Herve Drolon] added FreeImage_ConvertToRGBA16 and updated conversions in FreeImage_ConvertToType
+ [Carsten Klein] added FreeImage_CreateView
+ [Carsten Klein] added FreeImage_RescaleRect
+ [Carsten Klein] added FreeImage_GetMemorySize
* [Tanner Helland] ICO plugin: improved support for Vista icons
* [fpgaminer] fixed a rounding error in RGB to greyscale conversion formula
* [Sven-Hendrik Haase] fixed Makefile.fip so that it installs symlinks
* [Joachim Reichel] fixed a potential memory access violation in PluginHDR Save function
* [Christian Schluchter] fixed a bug in FreeImage_LookupSVGColor ("green" color was not found)
* [Marco Altomonte] fixed TARGA signature validation for TARGA versions < 2.0
* [Jeremy Reyniers] fixed FreeImage_GetScanLine not working with very large images on x64 platforms
* [Herve Drolon] improved PluginTIFF compatibility with LibTIFF 4
* [Aaron Shumate] fixed a segfault occuring on a corrupted animated GIF
* [Herve Drolon] improved memory allocation in PluginRAW
* [Herve Drolon] fixed loading/saving of TIFF containing a GPS IFD inside the Exif-TIFF metadata segment (the solution is to ignore the tag)
* [Mihail Naydenov] fixed a bug in FreeImage_JPEGCrop*/_JPEGTransform* functions occuring when using the same source / destination filename
src/Whatsnew.txt view on Meta::CPAN
! FreeImage now uses OpenEXR 1.7.0
! FreeImage now uses ZLib 1.2.5
! FreeImage now uses LibPNG 1.4.3
! FreeImage now uses LibJPEG 8b
! FreeImage now uses LibTIFF 3.9.4 (CVS patch 2010-07-13)
! FreeImage now uses LibRaw 0.10-Beta3
! FreeImage now uses OpenJPEG 1.4.0 (SVN patch 2010-04-16)
! [Herve Drolon] FreeImage_AllocateT now builds a default greyscale palette for 8-bit images
! [Volodymyr Goncharov] FreeImage_LoadMultiBitmapFromMemory now supports read/write operations
! [Herve Drolon] FreeImage_OpenMultiBitmapFromHandle now supports read/write operations
! [Herve Drolon] greyscale conversions now use the Rec. 709 formula
! [Mihail Naydenov] saving RGBF images to TIFF no longer use LogLuv encoding (unless you use the TIFF_LOGLUV save flag)
+ [Herve Drolon] added FIT_FLOAT to FIT_RGBF conversion to FreeImage_ConvertToRGBF & FreeImage_ConvertToType
+ [Herve Drolon] added VS 2008 project files
+ [Herve Drolon] added FreeImage_ConvertToFloat
+ [Mihail Naydenov] added RLE saving to the Targa plugin (see flag TARGA_SAVE_RLE)
+ [Volodymyr Goncharov] added FreeImage_SaveMultiBitmapToHandle
+ [Herve Drolon] added FreeImage_SaveMultiBitmapToMemory
+ [Herve Drolon] added new Exif maker note tags
+ [Lucian Sabo] added JPEG_OPTIMIZE to PluginJPEG:Save
+ [Mihail Naydenov] improved support for Exif tag reading in TIFF plugin
src/Whatsnew.txt view on Meta::CPAN
+ [Herve Drolon] added FreeImage_HasPixels
+ [Herve Drolon] added FreeImage_FIFSupportsNoPixels
+ [Herve Drolon] added support for FIF_LOAD_NOPIXELS flag to JPEG, PNG, PCD, PCX plugins
+ [Mihail Naydenov] added support for FIF_LOAD_NOPIXELS flag to TGA, PSD, TIFF plugins
+ [Mihail Naydenov] added support for 16-bit image types to FreeImage_Invert
+ [Mihail Naydenov] improved PSD plugin (faster code, added support for CMYK and LAB loading) + added load flags PSD_CMYK & PSD_LAB
+ [Mihail Naydenov] improved TIFF plugin (CMYK 16-bit loading and saving / RGBAF saving) + added TIFF_LOGLUV save flag
* [Herve Drolon] fixed FreeImage_GetFileType behavior with ANI file formats
* [Herve Drolon] fixed loading of JNG with progressive-JPEG formats
* [Mihail Naydenov] fixed loading of TGA with a corrupted rle count
* [Herve Drolon] fixed conversion formula in FreeImage_PreMultiplyWithAlpha
* [Christoph Brill] removed the use of libmng_data.h private API in MNG Plugin
* [phe02sf] fixed handling of bad Exif-GPS data in a Nikon D5000 image
* [Atsuhiro Igarashi] fixed handling of last data block in PluginGIF::Save (sometimes it saves corrupted images)
* [Christian Heimes] fixed saving of G3 & G4 compressed TIFF with 1bpp on 64bit Linux
* [Herve Drolon] fixed long data type being 64-bit on Unix/Linux platforms (use LONG/DWORD instead of long/unsigned long)
* [Herve Drolon] fixed a memory leak in FreeImage_DeletePage
* [Herve Drolon] fixed the loading of RGBZ images in OpenEXR plugin
* [Lucian Sabo] improved conversion from 1-, 4-, 8-bpp transparent images to 32-bpp
* [Roy F.] fixed a bug in FreeImage_EnlargeCanvas (unable to crop an image on the right)
* [Herve Drolon] fixed the loading of Exif with unusual IFD offset value