Search code examples
pythonimage-processingimagej

Image Analysis: Finding proteins in an image


I am attempting to write a program that will automatically locate a protein in an image, this will ultimately be used to differentiate between two proteins of different heights that are present. proteins in a membrane

The white area on top of the background is a membrane in which the proteins sit and the white blobs that are present are the proteins. The proteins have two lobes hence they appear in pairs (actually one protein).

I have been writing a script in Fiji (Jython) to try and locate the proteins so we can work out the height from the local background. This so far involves applying an adaptive histogram equalisation and then subtracting the background with a rolling ball of radius 10 pixels. After that I have been applying a kernel of sorts which is 10 pixels by 10 pixels and works out the average of the 5 centre pixels and divides it by the average of the pixels on the 4 edges of the kernel to get a ratio. if the ratio is above a certain value then it is a candidate.

the output I got was this image which apart from some wrapping and sensitivity (ratio=2.0) issues seems to be ok. My questions are:

  1. Is this a reasonable approach or is there an obviously better way of doing this?
  2. Can you suggest a way on from here? I am a little stuck now and not really sure how to proceed.

enter image description here

code if necessary: http://pastebin.com/D45LNJCu

Thanks!

Sam


Solution

  • How about starting off a bit more simple and using the Harris-point approach and detect local maxima. Eg.

    import numpy as np
    import Image
    from scipy import ndimage
    import matplotlib.pyplot as plt
    
    roi = 2.5
    peak_threshold = 120
    
    im = Image.open('Q766c.png');
    image = im.copy()
    
    size = 2 * roi + 1
    image_max = ndimage.maximum_filter(image, size=size, mode='constant')
    mask = (image == image_max)
    image *= mask
    
    # Remove the image borders
    image[:size] = 0
    image[-size:] = 0
    image[:, :size] = 0
    image[:, -size:] = 0
    
    # Find peaks
    image_t = (image > peak_threshold) * 1
    
    # get coordinates of peaks
    f = np.transpose(image_t.nonzero())
    
    # Show
    img = plt.imshow(np.asarray(im))
    plt.plot(f[:, 1], f[:, 0], 'o', markeredgewidth=0.45, markeredgecolor='b', markerfacecolor='None')
    
    plt.axis('off')
    plt.savefig('local_max.png', format='png', bbox_inches='tight')
    plt.show()
    

    Which gives this:

    enter image description here