快速径向对称变换(FRST)的实现(python)会产生异常的十字准线伪像

时间:2019-06-04 03:10:32

标签: image image-processing computer-vision computational-geometry

我正在尝试在python上实现FRST以检测椭圆形对象(例如显微图像中的细胞)的质心,但是我的实现未找到椭圆形对象的种子点(或多或少的中心点)。这项工作来自复制轮廓图像中重叠椭圆对象的分段https://ieeexplore.ieee.org/document/7300433)中的FRST。我不知道为什么会有这些假象。有趣的是,我看到每个对象的这些图案(交叉)都在相同的方向上。在正确方向上产生与论文相同结果的任何点(只是查找种子点)将是最受欢迎的。

原始论文:Loy和Zelinsky编写的用于检测兴趣点的快速径向对称变换(ECCV 2002)

我还尝试了针对FRST的现有python软件包:https://pypi.org/project/frst/。这样就导致了相同的工件。奇怪的。

  1. 第一张图片:原始图片
  2. 第二张图片:Sobel经营的图片
  3. 第三张图片:幅值投影图片
  4. 第四幅图像:幅值投影图像,仅具有积极影响的像素
  5. 第五张图片:FRST图片:带有原始图片(阴影)的最终产品
  6. 第六张图片:通过预先存在的python包FRST生成的图片,原始图片被覆盖(阴影)。

Original Image Sobel-operated Image
Magnitude Projection Image Magnitude Projection Image with positively affected pixels only FRST'd image: end-product with original image overlaid (shadowed) FRST pre-existing python package

from scipy.ndimage import gaussian_filter
import numpy as np
from scipy.signal import convolve


# Get orientation projection image
def get_proj_img(image, radius):

    workingDims = tuple((e + 2*radius) for e in image.shape)

    h,w = image.shape

    ori_img = np.zeros(workingDims) # Orientation Projection Image
    mag_img = np.zeros(workingDims) # Magnitutde Projection Image 

    # Kenels for the sobel operator 
    a1 = np.matrix([1, 2, 1])
    a2 = np.matrix([-1, 0, 1])
    Kx = a1.T * a2
    Ky = a2.T * a1

    # Apply the Sobel operator
    sobel_x = convolve(image, Kx)
    sobel_y = convolve(image, Ky)
    sobel_norms = np.hypot(sobel_x, sobel_y)

    # Distances to afpx, afpy (affected pixels)    
    dist_afpx = np.multiply(np.divide(sobel_x, sobel_norms, out = np.zeros(sobel_x.shape), where = sobel_norms!=0), radius)
    dist_afpx = np.round(dist_afpx).astype(int)

    dist_afpy = np.multiply(np.divide(sobel_y, sobel_norms, out = np.zeros(sobel_y.shape), where = sobel_norms!=0), radius)
    dist_afpy = np.round(dist_afpy).astype(int)


    for cords, sobel_norm in np.ndenumerate(sobel_norms):
        i, j = cords

        pos_aff_pix = (i+dist_afpx[i,j], j+dist_afpy[i,j])
        neg_aff_pix = (i-dist_afpx[i,j], j-dist_afpy[i,j])

        ori_img[pos_aff_pix] += 1
        ori_img[neg_aff_pix] -= 1
        mag_img[pos_aff_pix] += sobel_norm
        mag_img[neg_aff_pix] -= sobel_norm

    ori_img = ori_img[:h, :w]
    mag_img = mag_img[:h, :w]

    print ("Did it go back to the original image size? ")
    print (ori_img.shape == image.shape)

    # try normalizing ori and mag img
    return ori_img, mag_img

def get_sn(ori_img, mag_img, radius, kn, alpha):

    ori_img_limited = np.minimum(ori_img, kn)
    fn = np.multiply(np.divide(mag_img,kn), np.power((np.absolute(ori_img_limited)/kn), alpha))

    # convolute fn with gaussian filter. 
    sn = gaussian_filter(fn, 0.25*radius)

    return sn

def do_frst(image, radius, kn, alpha, ksize = 3):
    ori_img, mag_img = get_proj_img(image, radius)
    sn = get_sn(ori_img, mag_img, radius, kn, alpha)

    return sn

参数:

radius = 50
kn = 10
alpha = 2
beta = 0 
stdfactor = 0.25

0 个答案:

没有答案