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

5 次查看(过去 30 天)
How to extract nearest pixel value [roi] by selection of reference pixel on a image?

回答(1 个)

Swarooph
Swarooph 2017-8-2
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 2017-8-3
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 2017-8-3
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Read, Write, and Modify Image 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by