Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to compute mean/std? #12

Closed
DMCNerooo opened this issue Dec 23, 2019 · 7 comments
Closed

How to compute mean/std? #12

DMCNerooo opened this issue Dec 23, 2019 · 7 comments

Comments

@DMCNerooo
Copy link

Hello, thanks for your interesting work! I wonder how to compute mean/std in the data folder, i.e. are they some statistics on training set? Looking forward to your reply!

@zhangboshen
Copy link
Owner

Sorry that I just see your comments yet.
And yes, we compute mean/std on training set, specifically, we first crop the original depth maps according to center points, which give us a hand-centered sub-image, then we compute the mean/std of all of these images.

@zhangboshen
Copy link
Owner

def findMean(center):
    trainingImageDir = './train_nyu/'
    mean_D = 0
    for i in tqdm(range(72757)):    #72757
        D_ = scio.loadmat(trainingImageDir + str(i+1) + '.mat')['depth']
        D_ = np.array(D_,dtype=np.float)
        new_Xmin = center[i][0][0] - cropHandWidth//2 
        new_Ymin = center[i][0][1] - cropHandHeight//2 
        new_Xmax = center[i][0][0] + cropHandWidth//2 
        new_Ymax = center[i][0][1] + cropHandHeight//2 

        D = D_[int(new_Ymin):int(new_Ymax), int(new_Xmin):int(new_Xmax)]
        D[np.where(D >= center[i][0][2] + 200)] = center[i][0][2]
        D[np.where(D <= center[i][0][2] - 200)] = center[i][0][2]
        D -= center[i][0][2]
                   
        
        mean_D_ = D.mean(0).mean(0)
        mean_D += mean_D_
#        print(i)
        
    mean_D /= 72757
    
    return mean_D

I hope this helps.

@DMCNerooo
Copy link
Author

Yes it really helps and I have understood. Thanks for your kind explanation! I will close this issue

@canuck6ix
Copy link

Hello @zhangboshen, I tried to reproduce this but don't get the same results as yours. I believe it is the cropHandWidth and cropHandHeight. What values do you use for the above?

@DMCNerooo does yours match mean = -0.66877532 and std= 28.32958208

@DMCNerooo
Copy link
Author

Hello @canuck6ix , I just want to understand the computation of mean/std in the data folder, but don't re-compute it. I use the value provided by the author. I think you can try to utilize above code "findMean" to get mean and then std, maybe there is little difference with author's but doesn't matter.
By the way, both cropHandWidth and cropHandHeight are set to 176 in this paper and project. Good luck!

@canuck6ix
Copy link

@DMCNerooo Thanks for confirming width and height. I did utilize the code above and they are a bit different from the pre-computed ones. Here are the two for comparison:
autor's: mean = -0.67 std = 28.33
mine: mean = -3.86 std = 21.13

@zhangboshen
Copy link
Owner

@DMCNerooo Thanks for confirming width and height. I did utilize the code above and they are a bit different from the pre-computed ones. Here are the two for comparison:
autor's: mean = -0.67 std = 28.33
mine: mean = -3.86 std = 21.13

@canuck6ix , I am sorry I just see your discuss now. And you can use your mean/std, I think you can also get a resonable result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants