Search code examples
matlabimage-processingcoordinatespixelmatlab-cvst

Get coordinates of inlier points in Matlab


I need to find pixel values of inlier points obtained in object detection using impixel(). I am using the same code as provided in the example at the link

How can I get x,y coordinates of the inlier points being with respect to image dimensions.(Top-left corner of image considered as 0 row, 0 col) so that I can use the coordinates to find their respective pixel values. I couldn't find any solution in Matlab same as KeyPoint object in C++ that gives coordinate values easily.


Solution

  • You do not need impixel here. impixel lets you get the pixel value from in image displayed in a figure, which is not what you are trying to do.

    In the example you are using, inlierBoxPoints and inlierScenePoints are SURFPoints objects. You can get the (x,y) locations of the points as inlierBoxPoints.Location. Then you can get the pixel value for the i-th point as follows:

    loc = round(inlierBoxPoints.Location(i, :));
    pixVal = boxImage(loc(2), loc(1), :);
    

    Keep in mind that in MATLAB the images are indexed as (row, col), and that the top-left corner pixel is (1,1), not (0,0). You have to round off the coordinates, because the points are detected with sub-pixel accuracy.