def compute_weights_3d(data,raw,alpha, beta, eps=1.e-6):
    # raw is the test image(3D grayscale), data is an image from prior knowledge(3D grayscale)
    # raw and data have same size, while data has a driver(label) 
    # Weight calculation is main difference in multispectral version
    # Original gradient**2 replaced with sum of gradients ** 2
    inter_gradients = np.concatenate([np.diff(data[..., 0], axis=ax).ravel()
         for ax in [2, 1, 0] if data.shape[ax] > 1], axis=0) ** 2 # gradient ^2
    intra_gradients = (raw - data)**2
    # Normalize gradients
    inter_gradients = (inter_gradients - np.amin(inter_gradients))/(np.amax(inter_gradients)- np.amin(inter_gradients))
    intra_gradients = (intra_gradients - np.amin(intra_gradients))/(np.amax(intra_gradients)- np.amin(intra_gradients))

    # All dimensions considered together in this standard deviation
    #------------------------------------------------------
    inter_scale_factor  = -beta  / (10 * data.std())
    inter_weights = np.exp(inter_scale_factor * inter_gradients)
    inter_weights += eps
    #------------------------------------------------------
    intra_scale_factor  = -alpha / (10 * data.std())
    inter_weights = np.exp(intra_scale_factor * intra_gradients)
    intra_weights += eps
    #------------------------------------------------------
    return -inter_weights, -intra_weights
0
Belal Homaidan 15 अप्रैल 2020, 22:08

1 उत्तर

सबसे बढ़िया उत्तर

उत्तर है कि:

  1. कागज के अनुसार वजन कार्यों का कार्यान्वयन गलत है, नीचे सही है।
  2. उन्होंने वेटिंग फंक्शन पर सिग्नल को उलट दिया और मैट्रिसेस गणना में इसे फिर से उलट दिया ताकि कोई अंतर न हो।
def compute_weights(image,mask,alpha, beta, eps=1.e-6):
    # Weight calculation is main difference in multispectral version
    # Original gradient**2 replaced with sum of gradients ** 2
    intra_gradients = np.concatenate([np.diff(image, axis=ax).ravel()
     for ax in [1, 0] ], axis=0) ** 2            # gradient ^2
    # print('intra_gradients shape',intra_gradients.shape)
    # 5-Connected
    inter_gradients = np.concatenate([np.diff(mask, axis=ax).ravel()
    for ax in [1, 0] ], axis=0)**2 
    # inter_gradients = np.concatenate((inter_gradients,(mask-image).ravel()),axis=0)**2  # gradient ^2
    # print('inter_gradients shape',inter_gradients.shape)
    #----------------------------------------
    # 1-Connected
    # inter_gradients = (image - mask)**2
    #----------------------------------------
    # Normalize gradients
    intra_gradients = (intra_gradients - np.amin(intra_gradients))/(np.amax(intra_gradients)- np.amin(intra_gradients))
    inter_gradients = (inter_gradients - np.amin(inter_gradients))/(np.amax(inter_gradients)- np.amin(inter_gradients))
    # print('Intra Gradiesnt_Shape: ',intra_gradients.shape)    
    # All dimensions considered together in this standard deviation
    #------------------------------------------------------
    intra_scale_factor  = -beta  / (10 * image.std())
    intra_weights = np.exp(intra_scale_factor * intra_gradients)
    intra_weights += eps
    #------------------------------------------------------
    inter_scale_factor  = -alpha / (10 * image.std())
    inter_weights = np.exp(inter_scale_factor * inter_gradients)
    inter_weights += eps
    #------------------------------------------------------
    return -intra_weights, inter_weights # [W_old , w_new]
0
Bilal 2 मई 2020, 04:00