[Image-SIG] What is the best way to anti-alias a very large resolution image in PIL
mankoff at gmail.com
Tue Sep 13 16:51:10 CEST 2011
Newbie to Python here so please excuse dumb suggestions, but...
Must you use pure Python and PIL?
It seems PyLibTiff was written to solve something like this.
Or you could perhaps load the TIFF with numpy which allows you to
load just parts of the file, down-sample in segments, then combine.
Or just use 3rd party tools (I have used gdal with very large files,
though none larger than my RAM).
On Thu, 8 Sep 2011, Craig Coleman (C) wrote:
> I have a really thorny problem.
> I need to downsample a raster map that is 23622x23622 pixels to
> 7874x7874 pixels using the ANTIALIAS filter.
> I have the following Python code:
>>>> import Image
>>>> img = Image.open(r"C:\temp\24bit_nd.tif")
>>>> nimg = img.resize((7874,7874),Image.ANTIALIAS)
> As soon as the resize method is called, python crashes instantly. I
> presume this is a memory allocation issue.
> Is there another way of performing anti-aliasing on such a large image
> (its 2.7GB uncompressed although I'm using LZW for storage).
> I have tried converting the file to 8bit with a palette and this
> successfully downsamples but the ANTIALIAS is not performed. What am I
> doing wrong?
> Craig Coleman
> Technical Lead
> Information Systems, Ordnance Survey
> L0F2, Adanac Drive, SOUTHAMPTON, United Kingdom, SO16 0AS
> Phone: +44 (0) 2380 054641
> www.ordnancesurvey.co.uk <http://www.ordnancesurvey.co.uk/> |
> craig.coleman at ordnancesurvey.co.uk
> Please consider your environmental responsibility before printing this
> This email is only intended for the person to whom it is addressed and may contain confidential information. If you have received this email in error, please notify the sender and delete this email which must not be copied, distributed or disclosed to any other person.
> Unless stated otherwise, the contents of this email are personal to the writer and do not represent the official view of Ordnance Survey. Nor can any contract be formed on Ordnance Survey's behalf via email. We reserve the right to monitor emails and attachments without prior notice.
> Thank you for your cooperation.
> Ordnance Survey
> Adanac Drive
> Southampton SO16 0AS
> Tel: 08456 050505
More information about the Image-SIG