Giter Club home page Giter Club logo

Comments (4)

wywu avatar wywu commented on July 2, 2024 1

Hi,

Line width is 1 pixel in our implementation. With a binary boundary map img_boundary.jpg (where pixels of the boundary line are set to be 255 while others are set to be 0), you can use the code below to get the distance transform results. Then the ground-truth boundary heatmap cen be obtained with Eq.1 in our paper.

`import cv2
import numpy as np
import matplotlib.pyplot as plt

img = cv2.imread('img_boundary.jpg', 0)
dist = cv2.distanceTransform(255-img, cv2.DIST_L2, cv2.DIST_MASK_PRECISE)
plt.figure()
plt.imshow((dist).astype(np.uint8), cmap='gray')
plt.show()`

Best,
Wayne

from lab.

wuneng avatar wuneng commented on July 2, 2024

Hi, wywu
Thanks for your reply.
I have modified the code.Here is my code.
import cv2
import numpy as np
import matplotlib.pyplot as plt
from utils import loadFromPts
import skimage.io as io

image = io.imread('/home/xiang/pytorch/testset/common/123.jpg')
ldms = loadFromPts('/home/xiang/pytorch/testset/common/123.pts')

def gauss(x, a, b, c, d=0):
return a * np.exp(-(x - b) ** 2 / (2 * c ** 2)) + d

def color_heatmap(x):

color = np.zeros((x.shape[0],x.shape[1],3))
color[:,:,0] = gauss(x, .5, .6, .2) + gauss(x, 1, .8, .3)
color[:,:,1] = gauss(x, 1, .5, .3)
color[:,:,2] = gauss(x, 1, .2, .3)
color[color > 1] = 1
color = (color * 255).astype(np.uint8)
return color

binary_map = np.zeros([256,256]).astype(np.uint8)
for i in range(15):
binary_map = cv2.line(binary_map,tuple(ldms[i].astype(np.int32)),tuple(ldms[i+1].astype(np.int32)),(255),1)
#plt.imshow(binary_map)
dist = cv2.distanceTransform(255-binary_map, cv2.DIST_L2, cv2.DIST_MASK_PRECISE)
#print(np.max(dist),np.min(dist))
#plt.figure()
##plt.imshow((dist).astype(np.uint8), cmap='gray')
#plt.imshow((dist).astype(np.uint8), cmap='gray')
#plt.show()
dist = dist / (np.max(dist))
heatmap = color_heatmap(dist)
new_img = (image0.7 + heatmap0.3).astype(np.uint8)
plt.imshow(new_img)

I still can not get the result as same as the distance map in your paper. Maybe some difference in the visualization function between yours and mine? The visualization of distance map uploaded to Baidu Drive,https://pan.baidu.com/s/13WxL6yUMIIPUlJZJI4wu2A(since some went wrong with github, i can not upload the distance map to github). Thanks.

from lab.

wywu avatar wywu commented on July 2, 2024

Hi,

It could be better to discuss the detail problem by e-mail. Please contact me at [email protected]

Best,
Wayne

from lab.

misnowman avatar misnowman commented on July 2, 2024

想请教下是怎么生成轮廓线的,直接画多边形吗

from lab.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.