I have sets of images (each contains about 3000 images where many objects are seen, each image is 4 Megapixels large, format is 8bit, gray scale, png).
To get an impression about the trajectories of the objects I superpose all images and produce a single colorized image where the objects in each image have a specific color corresponding to the image number.
The background ist black, the tracks start with blue and stop with red.
The problem in the code below is that it crashes when many and larges images are used since all of them are read at once in memory.
Is there a solution that image by image can be read and superposed on top of each other, instead of reading them at once?
example image that contains only a single object:
a sample of small images for testing the code: http://tinyurl.com/ht5362l
code:
ChoiceDialog[{FileNameSetter[Dynamic[imageDir], "Directory"], Dynamic[imageDir]}];
SetDirectory[imageDir];
fNames = FileNames["*.png"];
numImages = Length[fNames];
colTable = {
{Black},
Table[
{Blend[{Blue, Green, Yellow, Red}, x]},
{x, 2/numImages, 1, 1/numImages}
]
};
colTable = Flatten[colTable];
threshold = FindThreshold[Import[fNames[[1]], Method -> "Entropy"]];
bins = Table[
Clip[
Import[fNames[[i]], "GrayLevels"], {threshold, threshold},
{0, i/numImages}
],
{i, 1, numImages}
];
superImg = Colorize[
Image[
Map[Max, Transpose[bins, {3, 1, 2}], {2}]
],
ColorFunction -> (Blend[colTable, #] &)
]
superposed image: