The following code reads all gray scale png images inside of a folder and then calculates the maximum intensity for each pixel and finally export the resulting image. This is until now the fastest code that can do that.
Please see also the answer from nikie in: Maximum brightness of two gray scale images
My question: can this code be compiled?
SetDirectory["f:\\images_dir\\"];
fNames = FileNames["*.png"];
numFiles = Length[fNames];
image = Import[fNames[[1]]];
newImage = ImageMultiply[image, 0];
Do[
{d1, d2} = ImageData /@ {image, newImage};
comp = UnitStep[d1 - d2];
newImage = Image[comp*d1 + (1 - comp)*d2];
image = Import[fNames[[i]]];
, {i, 2, numFiles}
];
Export["f:\\images_dir\\analysis\\super.png", newImage, "png"],
Importis much much slower. If so, compiling isn't the solution, replacingImportis... – Niki Estner Oct 18 '16 at 07:04Import[#, "Data"]&/@fNames) and then you can work on the raw data using a compiled version of the rest of your code. A customImageMultiplycan be easily written that works directly on an integer array. Then youExportagain on the ME. – István Zachar Oct 18 '16 at 07:39