Search code examples
matlabimage-processingcomputer-visionrgbpixel

get pixel coordination by rgb values matlab


how can I get the x,y coordinates for pixels in an image by rgb values in matlab ?

for example : I've got an image that I want to locate the pixels coordinates od the black area in it..


Solution

  • If you want to find all coordinates of pixles with values (R, G, B) then

    [y, x] = find(img(:,:,1)==R & img(:,:,2)==G & img(:,:,3)==B);
    

    For black pixels choose R=0, G=0, B=0