代码之家  ›  专栏  ›  技术社区  ›  Prachi

基于深度阈值的手部分割

  •  1
  • Prachi  · 技术社区  · 7 年前

    我想使用深度阈值从深度图像中分割手。我使用了这个链接中的kinect和leap数据集-

    http://lttm.dei.unipd.it/downloads/gesture/

    我尝试了这两个代码,但在这两种情况下,我得到的输出都是完全黑色的图像。原始.png图像是 original depth image

    我从1_depth中选择了深度值。数据集中的bin文件。

    I = fopen('D:\dsktop\kinect_leap_dataset\acquisitions\P1\G1\1_depth.bin', 'r');
    A = fread(I, 480*640, 'uint8=>uint8');
    A = reshape(A, 480, 640);
    
    min_row = min(A);
    min_col = min(min_row);
    
    for i = 1:480
        for j = 1:640
            if ((A(i,j) > (min_col + 10)) || (A(i,j) == (min_col + 10)))
               A(i,j) = 1;
           else
               A(i,j) = 0;
            end
        end
    end
    imshow(A)
    

    代码2

    image = imread('D:\dsktop\kinect_leap_dataset\acquisitions\P1\G1\1_depth.png');
    I = fopen('D:\dsktop\kinect_leap_dataset\acquisitions\P1\G1\1_depth.bin', 'r');
    A = fread(I, 480*640, 'uint8=>uint8');
    A = reshape(A, 480, 640);
    
    min_row = min(A);
    min_col = min(min_row);
    for i = 1:480
        for j = 1:640
            if ((A(i,j) > (min_col + 10)) || (A(i,j) == (min_col + 10)))
                image(i,j) = 1;
            else
                image(i,j) = 0;
            end
        end
    end
    imshow(image)
    

    我得到的结果是 output image

    请告诉我这段代码出了什么问题,以及为什么我没有得到任何信息?

    1 回复  |  直到 7 年前
        1
  •  0
  •   Shai    7 年前

    I = fopen('D:\dsktop\kinect_leap_dataset\acquisitions\P1\G1\1_depth.bin', 'r');
    A = fread(I, 480*640, 'uint8=>uint8');
    A = reshape(A, 480, 640);
    
    min_ = min(A(:));  % minimal value across rows and columns
    mask = A>=(min_+10);  % no need for loop, vectorize code.
    imshow(mask, []);