Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas022.isp.belgacom.be (localhost [127.0.0.1])
        by inav028.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AV-3.00) with ESMTP id j8KB4t49009609
        for <joris.at.lebbeke@skynet.be>; Tue, 20 Sep 2005 13:04:56 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx014.isp.belgacom.be (inmx014.isp.belgacom.be [195.238.2.217])
        by inas022.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AS-2.03) with ESMTP id j8KB4rHE026256
        for <joris.at.lebbeke@skynet.be>; Tue, 20 Sep 2005 13:04:53 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx014.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id j8KB4iXG023125
        for <joris.at.lebbeke@skynet.be>; Tue, 20 Sep 2005 13:04:44 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (duke.maptools.org [127.0.0.1])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id j8KAxUp3014627;
	Tue, 20 Sep 2005 06:59:40 -0400
Received: from outmx021.isp.belgacom.be (outmx021.isp.belgacom.be
	[195.238.2.202])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id j8KAxRAY014624
	for <tiff@lists.maptools.org>; Tue, 20 Sep 2005 06:59:28 -0400
Received: from outmx021.isp.belgacom.be (localhost [127.0.0.1])
	by outmx021.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with
	ESMTP id j8KAxKcl021704
	for <tiff@lists.maptools.org>; Tue, 20 Sep 2005 12:59:20 +0200
	(envelope-from <joris.at.lebbeke@skynet.be>)
Received: from dfgrrxsknr4e (216-162.246.81.adsl.skynet.be [81.246.162.216])
	by outmx021.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with SMTP
	id j8KAxHaP021653; Tue, 20 Sep 2005 12:59:17 +0200
	(envelope-from <joris.at.lebbeke@skynet.be>)
Message-ID: <005b01c5bdd2$70f20c20$6fb0f551@dfgrrxsknr4e>
From: "Joris" <joris.at.lebbeke@skynet.be>
To: "katrina maramba" <ka3na_423@yahoo.com>,
        "tiff mail list" <tiff@lists.maptools.org>
References: <20050920091526.57559.qmail@web60221.mail.yahoo.com>
Subject: Re: [Tiff] Parse image into YCbCr data
Date: Tue, 20 Sep 2005 12:59:41 +0200
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2800.1506
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
Cc: 
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.4
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-UIDL: 000000000023ceae.00000c42
X-MSP-STORE: Tue, 20 Sep 2005 13:05:00 +0200
Status:   

katrina maramba wrote:
> What is the simplest way to parse a tiff image into
> YCbCr data?  What is the API to call for this?  What I
> found in the files was an API to convert YCbCr to RGB.
>  Is there an API that has the same behavior as
> TIFFReadRGBAStrip but instead output YCbCr??

No, there is no such function.

You can, however, easilly convert the RGBA returned from
TIFFReadRGBAStrip into YCbCr. The relation between these color spaces is
documented in the TIFF spec, and in the LibJpeg jdcolor.c and jccolor.c
files. It's the same YCbCr.

        R = Y                + 1.40200 * Cr
        G = Y - 0.34414 * Cb - 0.71414 * Cr
        B = Y + 1.77200 * Cb

       Y  =  0.29900 * R + 0.58700 * G + 0.11400 * B
       Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B  + 128
       Cr =  0.50000 * R - 0.41869 * G - 0.08131 * B  + 128

Note that these are floating point convertions. To optimize to integer
arithmatic, multiply all coëfficients with 65536, add 32767 to the
complete result, and shift right 16 bits. Or consult jccolor.c.

Also note that these aren't completely round trip. If you need 16bit or
floating point precision, and you want a convertion from RGB to YCbCr to
RGB to yield the exact values you started with, you'll have to do some
matrix convertion of your own with greater precision.


Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html

_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
