# Pre-processing and deconvolution of CLSM images

I have some confocal laser scanning microscopy data sets that I want to binarize for further analyses. Due to the fast bleaching dyes and the general scanning duration we established a setup which results in data sets of 1024x1024x50 voxels. The spacing is 0.1µm x 0.1µm x 0.53µm, which means that the total imaged volume is about 102µm x 102µm x 27µm.

Image quality could be better and unfortunately, the exact PSF is not known. I have put together some image processing steps ranging from de-noising to binarization (segmentation correction via object separation etc. will happen afterwards). For better results I have saved rescaling of the processed image to the actual image aspect ratio until binarization (although I show a rescaled image after every step). Quadratic Resampling seemed to produce the best result. For demonstration I will show the procedure in 2d only, extension to 3d can easily be done.

I am not yet satisfied with the current result, maybe someone comes up with a better idea how to tackle this problem.

Here is an exemplary z-slice of a volume:

img = Import["http://i.imgur.com/kIratE9.png"]
ImageResize[%, {1024, 265}, Resampling -> "Quadratic"]


At first I apply a TotalVariationFilter:

imgtv = TotalVariationFilter[img, 0.05, MaxIterations -> 100]
ImageResize[%, {1024, 265}, Resampling -> "Quadratic"]


Then an ImageDeconvolve is performed. I selected this specific kernel since it yielded the best visual result:

gmat = GaussianMatrix[{{5, 5}, {1.5, 2.5}}];


imgdec = ImageDeconvolve[imgtv, gmat, Method -> {"SteepestDescent", "Preconditioned" -> False}, MaxIterations -> 15]
imgdec2 = ImageResize[%, {1024, 265}, Resampling -> "Quadratic"]


For the final step I use LocalAdaptiveBinarize, Closing and FillingTransform:

imgbin = FillingTransform[Closing[LocalAdaptiveBinarize[imgdec2, 150], DiskMatrix[2]]]


The poor image quality (influence of the PSF, noise, etc.) in conjuction with the rescaling results in spiky object borders in z-direction. An extra processing step would be needed to counter this problem adequately. Here is an overlay of the original image and the result:

HighlightImage[ImageResize[img, {1024, 265}, Resampling -> "Quadratic"], imgbin]


Following the request by Rahul I have performed resizing prior to all image processing steps. The result is worse as I pointed out above:

Update

Following an idea by halirutan I have put an unidirectional GaussianFilterbefore the TotalVariationFilterto get rid of the spikes. The result still could be better:

img = GaussianFilter[img, {{0, 4}}]


• Why are you not satisfied with the result and what are you expecting to be improved? You could maybe try smoothening the final shapes, or fit some splines on the, etc. – anderstood Jun 29 '16 at 16:06
• What happens if you resize the image to the correct aspect ratio before applying all those steps, rather than after? – Rahul Jun 29 '16 at 17:30
• @Rahul: I have provided an answer to your request in my post. – Kardashev3 Jun 30 '16 at 11:47
• @anderstood: The problem here is the poor quality of the original images. Resizing these images also "resizes" and thereby intensifies the noise in z-direction. Before deconvolution I perform a TotalVariationFilter to remove the noise, but maybe another procedure should be employed instead. I expect to produce more rounded objects that correspond to the original structures more strictly. I have put an unidirectional GaussianFilter before the TotalVariationFilter (see the post update) to get rid of the spikes. The result is somewhat better but far from perfect due to the additional blurring. – Kardashev3 Jun 30 '16 at 12:15
• @anderstood: Could you please elaborate on smoothening the final shapes while keeping the actual structure's shape? – Kardashev3 Jun 30 '16 at 12:16

Basically following the outline of the OPs processing:

img = Import["http://i.imgur.com/kIratE9.png"];
imR = ImageResize[%, {1024, 265}, Resampling -> "Quadratic"];
imM = MeanShiftFilter[imR, 1, 0.1, MaxIterations -> 20];
imL = LocalAdaptiveBinarize[imM, 66, {0.7, 0, 0.1}];
imgF = DeleteSmallComponents[FillingTransform[imL], 20];
HighlightImage[imR, imgF]


This replaces the TotalVariation and the deconvolution with a Meanshift filter, and shuffles around a few of the other commands.

• For some structures this works quite well, but in the top left something went wrong. Maybe the result could benefit from some local adaptive contrast enhancement of the original image (just a guess)? – Kardashev3 Jul 4 '16 at 11:05