[Tutor] how to read and transmit/send only section of the image (sub-image)

Mac Ryan quasipedia at gmail.com
Fri Sep 4 01:45:10 CEST 2009


On Fri, 2009-09-04 at 00:01 +0200, Jojo Mwebaze wrote:
> thanks guys, 
> 
> 
> Currently i am using pyfits, a bit slow cause loads the file in
> memory, creates a subimage and then saves the file then transmits
> the file over the network! My idea is,  if there is a way of creating
> a file pointer to the location on disk, where the subimage lies,
> reading a specific size, and  sending only the data read (like wayne
> had suggested) 
> 
> 
> Do you think this possible? 
> 
> 
> Johnson


I had no chance to look at the specific format of your image files, but
unless it is an uncompressed raster I would guess what you want to do is
rather difficult. Chances are indeed that the data in the image files
are compressed, and this means that part of the information needed to
properly render your sub-image lies in another part of the image that
you are not interested in.

Just think of compressed videos, a lot of codecs use the idea of "key
frames": if for any reason you lose a key-frame, for a few seconds after
that missing frame you won't see a proper video, but most probably a
greenish moving blob, as what the video player is actually trying to do
is modifying parts of the key-frame that is not there.

Another problem is that the ratio raw data / compressed data is not
constant throughout the entire file: I would guess that a portion of an
image that is simply black deep space will be compressed in a few bytes,
while a portion of the image of equal extension but with a galaxy in it
will be compressed into a larger chunk of bytes, so - unless you have an
index - it will be *very* hard for you to guess where your "sub-image"
lies in your master file.

Again: as I did not check out your file format specifically, you should
check out by yourself if what above applies to you or not. It might well
be that the format you are using was specifically designed to allow
operations like the one you describe, and that the metainformation
needed for you to access you sub-image are in the header of the master
image. I just wanted to give you some input on you question "do you
think this is possible?". :)

Mac.



More information about the Tutor mailing list