Return-Path: <tiff-bounces@lists.maptools.org>
Delivered-To: info@awaresystems.be
Received: (qmail 22852 invoked from network); 21 Nov 2008 19:13:32 -0000
Received: from cliffy.telenet-ops.be ([195.130.136.2])
          (envelope-sender <tiff-bounces@lists.maptools.org>)
          by angelia.telenet-ops.be (qmail-ldap-1.03) with SMTP
          for <info@awaresystems.be>; 21 Nov 2008 19:13:32 -0000
Received: from waldo.telenet-ops.be (waldo.telenet-ops.be [195.130.136.10])
	by cliffy.telenet-ops.be (8.13.1/8.13.1) with ESMTP id mALJDVAR010778
	for <info@awaresystems.be>; Fri, 21 Nov 2008 20:13:31 +0100
Received: from localhost (localhost.localdomain [127.0.0.1])
	by waldo.telenet-ops.be (Postfix) with SMTP id D92941C007
	for <info@awaresystems.be>; Fri, 21 Nov 2008 20:13:31 +0100 (CET)
Received: from ladon.telenet-ops.be (ladon.telenet-ops.be [195.130.132.50])
	by waldo.telenet-ops.be (Postfix) with ESMTP id D01301C006
	for <info@awaresystems.be>; Fri, 21 Nov 2008 20:13:31 +0100 (CET)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153])
	by ladon.telenet-ops.be (Postfix) with ESMTP id 8915E312773
	for <info@awaresystems.be>; Fri, 21 Nov 2008 20:13:31 +0100 (CET)
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 mALJBrpR011681;
	Fri, 21 Nov 2008 14:12:41 -0500
Received: from scooby.simplesystems.org (scooby.simplesystems.org
	[65.66.246.67])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id mALJBoMW011678
	for <tiff@lists.maptools.org>; Fri, 21 Nov 2008 14:11:50 -0500
Received: from freddy.simplesystems.org (freddy.simplesystems.org
	[65.66.246.65])
	by scooby.simplesystems.org (8.12.10+Sun/8.12.10) with ESMTP id
	mALJBlCI005617; Fri, 21 Nov 2008 13:11:47 -0600 (CST)
Date: Fri, 21 Nov 2008 13:11:47 -0600 (CST)
From: Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
X-X-Sender: bfriesen@freddy.simplesystems.org
To: Kevin Myers <kmyers1@clearwire.net>
Subject: Re: [Tiff] 24 bit Color to 8 bit Palettized Conversion Utility
	(tiffcp enhancement/variation?)
In-Reply-To: <Pine.SOC.4.64.0811211243070.28940@freddy.simplesystems.org>
Message-ID: <Pine.SOC.4.64.0811211302380.28940@freddy.simplesystems.org>
References: <447CCFB3F95C4D7FB3D5514F39BF0B2C@KAM1720>
	<Pine.SOC.4.64.0811211243070.28940@freddy.simplesystems.org>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
Cc: tiff@lists.maptools.org
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-SpamCatcher-Score: 10 [X]

On Fri, 21 Nov 2008, Bob Friesenhahn wrote:
>
> Did you try VIPS?  VIPS is able to accomplish many things without loading the 
> whole image into memory and it is usually quite fast.  I don't know if its 
> color reduction works without loading the whole image though since that would 
> require a several-pass algorithm.

Actually, from looking at the VIPS documentation, I am not finding an 
algorithm for color reduction at all.  Maybe it does not exist. :-(
Still, a programmer could use the VIPS API to develop a muti-pass 
color reduction algorithm.

In order to color reduce you need to

  1) Build a color tree / histogram of the existing colors in the
     image. This requires reading all the image pixels.

  2) Evaluate the color tree and build a colormap which best
     approximates it.

  3) Re-read the image pixels and generate colormap indexes which best
     approximate the image given the colormap which was selected.  This
     may include dithering.

So it can be seen that to color reduce an image using the color tree / 
histogram method requires reading the pixels at least twice.  RAM is 
now about 10,000 times faster than disk so reading from disk multiple 
times is prohibitive unless the decoded image can not fit in RAM.

Bob
======================================
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

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