[Image-SIG] reading 16-bit images in the "raw"

K Schutte schutte@fel.tno.nl
Fri, 20 Dec 2002 08:41:03 +0100


This is a multi-part message in MIME format.
--------------88F40F807FC4F2FEF78D2DAA
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

>From recent work reading 16 bit TIFF images (now in the PIL 1.1.4 alpha 2
release,
see attached message), I think that you should set self.mode to "I;16", and
also use the same mode specifier in the last line.

Using "I;16" denotes that it is a 16 bit unsigned integer. "F;16" should specify
16 bit float format, and my system only supports float of length 32 and 64
bits...

Good luck,

Klamer

Shemano David A Contr AFRL/SNJM wrote:
> 
> hi,
> i am having difficulty with writing my own file decoder.  the images are 16-bits per pixel straight binary with no header.  i wrote a decoder following the example in the pil documentation, but it seems not to work.  the images are 320x240 16-bits per pixel.  the image file has the right number of bytes. here is my decoder:
> 
> import Image, ImageFile
> 
> class MerlinImageFile(ImageFile.ImageFile):
> 
>     format = "MERLIN"
>     format_description = "Merlin camera raw little endian"
> 
>     def _open(self):
> 
>         self.size = (320, 240)
>         self.mode = "F"
> 
>         self.tile = [ ("raw", self.size, 0, ("F;16", 0, 1) ) ]
> 
> Image.register_open("MERLIN", MerlinImageFile)
> Image.register_extension("MERLIN", ".mln")
> 
> in the tile attribute the "F;16" is intended to mean that 2 bytes get read in, they are interpreted as a 16-bit little endian integer and the value of that integer is stored as a floating point value in my image.  (please set me straight if i have misinterpreted that)
> 
> here is an idle session where i attempt to use the above:
> 
> >>> import Image
> >>> import MerlinImageFile
> >>> im = Image.open("c:\\python22\\dave_projects\\test.mln")
> >>> print im.getextrema()
> Traceback (most recent call last):
>   File "<pyshell#4>", line 1, in ?
>     print im.getextrema()
>   File "c:\py22\pil\Image.py", line 528, in getextrema
>     self.load()
>   File "c:\py22\pil\ImageFile.py", line 143, in load
>     d.setimage(self.im, e)
> TypeError: argument 2 must be sequence of length 4, not 2
> >>>
> 
> any suggestions will be greatly appreciated.  thanks in advance.
> 
> dave shemano
> 
> _______________________________________________
> Image-SIG maillist  -  Image-SIG@python.org
> http://mail.python.org/mailman/listinfo/image-sig

-- 
Klamer Schutte, E-mail: Schutte@fel.tno.nl
Electro-Optical Systems, TNO Physics and Electronics Laboratory
Tel: +31-70-3740469 -- Fax: +31-70-3740654 -- Mobile: +31-6-51316671
--------------88F40F807FC4F2FEF78D2DAA
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Return-Path: <image-sig-admin@python.org>
Received: from pc1928.fel.tno.nl ([134.203.9.113]) by
          fs1.fel.tno.nl (Netscape Messaging Server 4.15) with SMTP id
          H62TPX00.FSQ for <Schutte@fel.tno.nl>; Sun, 24 Nov 2002 11:41:57 +0100 
Received: FROM kaikoura.fel.tno.nl BY pc1928.fel.tno.nl ; Sun Nov 24 11:41:56 2002 +0100
Received: by kaikoura.fel.tno.nl; id LAA03674; Sun, 24 Nov 2002 11:41:50 +0100 (MET)
Received: from nodnsquery(134.221.2.2) by kaikoura.fel.tno.nl via smap (V1.0)
	id xma003672; Sun, 24 Nov 02 11:41:34 +0100
Received: from mail7.messagelabs.com (mail7.messagelabs.com [194.151.197.68])
	by zeus.tno.nl (8.11.6+Sun/8.10.2) with SMTP id gAOAfYO01778
	for <Schutte@fel.tno.nl>; Sun, 24 Nov 2002 11:41:34 +0100 (MET)
X-VirusChecked: Checked
X-Env-Sender: image-sig-admin@python.org
X-Msg-Ref: server-7.tower-7.messagelabs.com!1038134493!1134
Received: (qmail 2234 invoked from network); 24 Nov 2002 10:41:33 -0000
Received: from mail.python.org (12.155.117.29)
  by server-7.tower-7.messagelabs.com with SMTP; 24 Nov 2002 10:41:33 -0000
Received: from localhost.localdomain ([127.0.0.1] helo=mail.python.org)
	by mail.python.org with esmtp (Exim 4.05)
	id 18FuCG-0003YZ-00; Sun, 24 Nov 2002 05:41:04 -0500
Received: from [80.79.165.82] (helo=pythonware.com)
	by mail.python.org with esmtp (Exim 4.05)
	id 18FuBo-0003Xc-00
	for image-sig@python.org; Sun, 24 Nov 2002 05:40:36 -0500
Received: from hagrid (brain.secret.pythonware.com [192.168.0.1])
	by pythonware.com (8.11.6/8.8.5) with SMTP id gAOAWwm02532
	for <image-sig@python.org>; Sun, 24 Nov 2002 11:32:58 +0100
Message-ID: <007301c293a5$eb0a8fa0$ced241d5@hagrid>
From: "Fredrik Lundh" <fredrik@pythonware.com>
To: <image-sig@python.org>
Organization: Secret Labs AB
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2720.3000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
X-Spam-Status: No, hits=0.8 required=5.0 tests=NOSPAM_INC,SPAM_PHRASE_00_01,USER_AGENT_OE
Subject: [Image-SIG] ANN: PIL 1.1.4 alpha 2
Sender: image-sig-admin@python.org
Errors-To: image-sig-admin@python.org
X-BeenThere: image-sig@python.org
X-Mailman-Version: 2.0.13 (101270)
Precedence: bulk
List-Help: <mailto:image-sig-request@python.org?subject=help>
List-Post: <mailto:image-sig@python.org>
List-Subscribe: <http://mail.python.org/mailman/listinfo/image-sig>,
	<mailto:image-sig-request@python.org?subject=subscribe>
List-Id: Image Processing with Python SIG <image-sig.python.org>
List-Unsubscribe: <http://mail.python.org/mailman/listinfo/image-sig>,
	<mailto:image-sig-request@python.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/image-sig/>
Date: Sun, 24 Nov 2002 11:40:22 +0100

A PIL 1.1.4 alpha 2 tarball is now available from effbot.org:

    http://effbot.org/downloads

(look for Imaging-1.1.4a2.tar.gz)

A list of changes can be found here:

    http://effbot.org/zone/pil-changes-114.htm

...and a draft handbook can be found here:

    http://effbot.org/books/imagingbook/

The final release will be released by Secret Labs AB, as usual.
We expect to release the final 1.1.4 version before the end of
the year.

Report bugs to this list or directly to me, as usual.

enjoy /F


_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

--------------88F40F807FC4F2FEF78D2DAA--