MATLAB Answers

How to extract nearest pixel value [roi] by selection of reference pixel on a image?

조회 수: 8(최근 30일)
Selva Karna
Selva Karna 2 Aug 2017
Commented: Binu 3 Aug 2017
How to extract nearest pixel value [roi] by selection of reference pixel on a image?

  댓글 수: 0

로그인 to comment.

답변 수 (1)

Swarooph
Swarooph 2 Aug 2017
Use the impoint function.
Example:
img = imread('peppers.png');
figure;imshow(img)
h = impoint(gca,[]);
position = wait(h); %Double click on a pixel in the figure window
pixelLoc = round(position) %Get nearest pixel location
img(pixelLoc(2),pixelLoc(1),1:3) %Use pixel location to index into RGB image
Result:
pixelVal =
(:,:,1) =
158
(:,:,2) =
50
(:,:,3) =
56

  댓글 수: 2

Selva Karna
Selva Karna 3 Aug 2017
Hi Swarooph , thanks for answer , actually my question is extract nearest pixel [ROI] its means region so , how to extract region by selection of pixel value?
Binu
Binu 3 Aug 2017
Swarooph's answer gives you both the pixel position(x,y) and pixel value. If you are looking for a ROI and not just a pixel, try imrect or imellipse. They both use the imroi class and functions are similar to impoint.

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by