MATLAB: How to get the coordinates from a certain image.

digital image processingimage processingMATLAB

Hi, I have some problems about getting all the coordinates from a certain image, the code I use is following:
R = imread('B1slicer.jpg');
[C,handle] = imcontour(R);
x = C (1,:);
y = C(2,:);
[K,V] = convhull(x,y);
plot (x,y,'+b',x(K),y(K),'-r');
However, there are some extra points getting extracted, and I donnot know how to solve this problem.
Is there any other methods to solve this problem?
Thanks.

Best Answer

You can use the inequalities and remove them from the points.
idx = y<200 ;
x(idx) = [] ; y(idx) = [] ;
Also you can use below:
I = imread('B1slicer.jpg') ;
[y,x] = find(I) ;