Background Subtraction And The Median Filter As Methods Of Correcting For Lack Of Contrast And Noise
Introduction
Typically, cell counting is done using a hemocytometer. A hemocytometer is a glass chamber with a counting grid which holds a specified volume of a cell suspension. This grid is used to count the cells per cubic volume, counts which are subsequently used to find the total number of cells in the suspension. This is a very time-consuming task and, due to its manual nature, introduces a significant amount of uncertainty due to human error. One way to alleviate this issue would be to create an algorithm which automatically counts cells as imaged on a glass slide.
Background and noise in an image can degrade the quality, and lead to incorrect cell counts. Matlab is a software that can be used to correct and analyze images. Matlab uses many different commands in order to complete the background and noise corrections. Before segmenting the image so that the colour is binary, a step imperative in order for accurate counts, the histogram of the image must be equalized. This is to adjust the image intensities such that the contrast of the image will increase. Following the histogram equalization, the image must be thresholded, which is the process of choosing the point on the histogram at which all pixels with intensity values greater than the threshold will be set to white, and less that the threshold will be set to black. To correct for the background, the function blckproc is used, which finds a coarse estimate of the background of the image. This estimate can be made more accurate by increasing the number of units, such that the area of pixels being averaged per unit decreases in order to calculate a more accurate mean background value. The histogram can then be adjusted to fit the entire intensity range, with a threshold below the average background value chosen. This ensures that the background will be entirely white.
In this experiement, the images have been effected with salt-and-peper noise, which can be identified by the fact that the pixel intensities are completely independent from their surrounding pixels2. In noise correction, the images pixels were filtered using both median and mean filters which determines a disc with a pre-determined area. With these filters, a disc of specified area is scanned over the image, and the average or median intensity value within the disc at all positions are calculated. All pixel values within the disc are subsequently replaced with the corresponding mean or median. This rids the image of any noise, as the varying intensity values are all being replaced with a constant value. In the present study, the effects of correcting for background and noise in images will be examined.
Methods
All image processing was executed using the image processing toolbox in MatLab. Two segmentation methods were used to determine how best to account for lack of contrast in order accurately count cells (or rice grains) in MatLab. In addition to this, two modes of noise reduction were executed to determine the best method to do so while maintaining image quality. Histogram Equalization and SegmentationThe histogram of the original image was equalized so that the contrast was enhanced, and the dynamic range of the image was increased. The threshold was then chosen at a point where there was a large gradient of intensities, with the pixels with intensity values above the threshold being set to 1 and below the threshold being set to 0.
Using the function blkproc the background was estimated and rescaled using imresize. The intensity values were scaled to fit the entire dynamic range using imadjust. The calculated background was subsequently subtracted from the original image to yield the edited image.
Results
Both the graythresh and im2bw segmenting methods yielded the same count of N=102, while the background subtraction method using blkproc yielded a count of N=83. A manual count of the original image yielded N=79. It was observed that the automatic segmentation using graythresh and im2bw created a white aberration in the image which was not created when using the background subtraction method. The averaging filter fsepcial(‘average’, N) returned an image with minimal noise reduction. The median filter reduced the noise to a much larger extent, though with a significant amount of blurriness. Both graythresh and im2bw return a binary image with a large white aberration in the center. This is most likely due to the fact that the corresponding area in the original image is slightly lighter, meaning the intensity values would be slightly higher. Therefore, when the threshold was chosen, this entire area had intensity values above the threshold that were subsequently set to 1. The background subtraction method was clearly superior in this situation, leading to a count that was much more similar to the manual count obtained from the original image. The noise reduction was done on three images with varying degrees of salt and pepper noise.
It is important to note that the hsize is a variable that should be optimized for noise reduction on a case by case basis. In addition to this, even though background subtraction is a good solution for contrast correction, the counts are not exactly accurate. This may be a point of interest in future research.
Conclusions
It can be concluded from the resulting images that background subtraction and the median filter medfilt2 were the superior methods in terms of correcting for lack of contrast and noise respectively. It is important to apply these conclusions to microscopy images in order to optimize your cell counts and keep the counts reproducible. Though the counts were not entirely accurate, if your correction is kept constant it can be assumed that this error will remain constant as well. Moving forward, it would be beneficial to utilize an actual microscopy image so that the effects on cell counts can be quantified. In addition to this, after ascertaining the superiority of medfilt2, future work could be done to optimize this filtering to decrease noisy images while still maintaining image resolution.