In [1]:
%run ../common.ipynb
from __future__ import division
In [10]:
image = imread('../mp.tif')
gimshow(image)
Tophat filter with a line as structured element might be an technique to get quantitative data about lines in an image. Lets try it out.
In [28]:
s = np.identity(20)
black_tophat = ndimage.morphology.black_tophat(image, structure=s)
gimshow(black_tophat)
In [29]:
s[:,:] = 0
mid = floor(s.shape[0]/2)
s[mid,:] = 1 #horisontal line
In [30]:
black_tophat = ndimage.morphology.black_tophat(image, structure=s)
gimshow(black_tophat)
In [31]:
s[:,:] = 0
s[:,mid] = 1 # vertical line
In [32]:
black_tophat = ndimage.morphology.black_tophat(image, structure=s)
gimshow(black_tophat)
In [41]:
subtracted = image.astype(np.int) - black_tophat.astype(np.int)
gimshow(scale(subtracted))
In [40]:
imsave('sub.tif', scale(subtracted))