3
$\begingroup$

I am trying to calculate the sum of intensities present in my agarose gel:

Example of agarose gel

I want to compare the intensity of the total white band on the top with that of the one on the bottom. The idea is to binarize the image at a certain threshold and use that matrix (the 1's) to determine the gray scale value at that same index in the original picture. However in order to properly binarize I want to substract the background. As seen over here there is a kind of gradient present. Do you guys have any ideas how to properly identify the background and substract it from the original image.

EDIT:

I now try to cut the image in two parts beforehand (top part and bottom part) then I can neglect the background in a certain way. I use the following code to identify the bands with image

Image_1:

topintens = Import["Image_1"];
topintens = MedianFilter[topintens, 1];
imt = Binarize[TopHatTransform[topintens, 4.09], 0.013];
imtfil = DeleteSmallComponents[imt, 7]

However I then end up with not so smooth bands, I want to apply dilation/erosion in order to make neat bands however this does not work out for me yet:

Output

So tips are welcome

$\endgroup$
  • $\begingroup$ I don't think it's a question of definitions or identification. In my opinion, your picture simply does not have a uniform background. You can 1) take another picture; or 2) ignore the gradient artifact. It would also be helpful if you could express the procedure you described in Mathematica code and include it in your post. $\endgroup$ – MarcoB Jun 21 '16 at 20:13
  • $\begingroup$ I edited my question, thanks for your response $\endgroup$ – Glenn Jun 21 '16 at 20:42
  • $\begingroup$ Is there no other way for you to take a picture with better contrast during electrophoresis? $\endgroup$ – J. M. is away Jun 21 '16 at 21:16
  • $\begingroup$ Well the quality of the gels is always different, this was actually a pretty good image. Therefore we are searching for image analysis tools to interpret our data better $\endgroup$ – Glenn Jun 21 '16 at 22:01
3
$\begingroup$

One possibility would be to apply a highpass filter, since what you want to remove is the slowly undulating background.

img = Import["http://i.stack.imgur.com/rvRAc.png"];
imgHP = ImageAdjust[HighpassFilter[img, 0.05]]

enter image description here

then binarize:

Binarize[imgHP]

enter image description here

To follow your original idea of locating the background and subtracting it -- this can be approached with a lowpass filter, followed by taking the difference between the image and the lowpass-filtered version:

bg = LowpassFilter[img, 0.1];
ImageAdjust[ImageDifference[bg, img]]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you, very helpful to apply a highpass filter $\endgroup$ – Glenn Jun 21 '16 at 22:00
  • $\begingroup$ Can you make a mask from known data about geometrie/mechanical dimensions of the setup? That would be my Approach to be Independent of the Image Quality. $\endgroup$ – Eisbär Jun 27 '16 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.