How to find the pixel information at a point whose coordinates are known ?

조회 수: 1 (최근 30일)
Kushal Joshi
Kushal Joshi 2016년 8월 12일
댓글: Mahsa khodaee 2017년 11월 30일
I have a set of (x,y) coordinates and I wish to know the values of pixels at each of these points. How do I do that. Normally, finding the coordinates from pixel value is easy using 'find' function in MATLAB. But this problem is exactly inverse of it. I know coordinates and I want to find pixel values

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 8월 12일
Im=randi(10,4)
x=[1 2 3]
y=[2 3 4]
id=sub2ind(size(Im),x,y)
pixels=Im(id)
  댓글 수: 2
Image Analyst
Image Analyst 2016년 8월 12일
If x is horizontal, and y is vertical coordinate (as usual), then this should be
id=sub2ind(size(Im), y, x)
since sub2ind() uses row, column, not x,y. So the rows come first, not the columns.
Mahsa khodaee
Mahsa khodaee 2017년 11월 30일
Thanks for your answer! I have the same question! your answer with X, Y matrix is fine! how about the time that we have a points file with a specific coordinate system! In this case, we wouldn't have two specific X and Y matrix.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 3-D Volumetric Image Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by