Re: Calculate median of stacks of images using IDL [message #88709 is a reply to message #88707] |
Sun, 08 June 2014 12:06   |
Phillip Bitzer
Messages: 223 Registered: June 2006
|
Senior Member |
|
|
On Friday, June 6, 2014 3:46:37 PM UTC-5, Nitsorn Wongsajjathiti wrote:
> Hi,
>
> I am trying to compute a median of a stack of images in TIF format for my research. From another source I found out a way to compute this from stack of images present in a GDF format, using
>
>
>
> IDL> buf=read_gdf('demo.gdf')
>
So, I suppose READ_GDF is from another library, yes? Do you _need_ things in GDF?
If you have TIFFs, you can just use READ_TIFF, and create a 3d array like David suggests.
Depending on how many TIFFs you have, you may find this modification to David's snippet to be slightly more efficient:
filenames = file_search("my_filename_regex*.tif", COUNT=fileCount) ;get the filenames, and how many
isGood = QUERY_TIFF(filenames[0], tiffInfo) ;get information about the first TIFF file
;assuming the TIFFs are 8 bit....if 16bit you can change to UINTARR
buf = BYTARR([tiffInfo.resolution, fileCount]) ;assuming all TIFFs are the same size, preallocate the array
FOREACH f in filenames DO $
buf[0, 0, i] = READ_TIFF(f) ;read each TIFF into the buf array
b = median(buf, /double, dimension=3)
|
|
|