How to extract nearest pixel value [roi] by selection of reference pixel on a image?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
How to extract nearest pixel value [roi] by selection of reference pixel on a image?
0 comentarios
Respuestas (1)
Swarooph
el 2 de Ag. de 2017
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 comentarios
Binu
el 3 de Ag. de 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.
Ver también
Categorías
Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!