[英]how to get gray values for a set of x and y coordinates in matlab?
使用此代碼:
gray = rgb2gray(I5);
imtool(gray)
graydata = 0;
graydata = gray(sub2ind(size(gray)),(y(:)),(x(:)));
我收到以下錯誤:
Error in fourierdescriptorscode (line 18)
這是第18行:
graydata = gray(sub2ind(size(gray)),(y(:)),(x(:)));
要獲取特定x和y坐標的值,只需將其作為指標即可。 例如,您要像素第2行,第3列
pixel_of_interest = gray(2,3);
如果您有索引並想要獲取對應的行列val
[row_of_interest, col_of_interest] = ind2sub(size(gray),INDEX_OF_INTEREST);
看來您放錯了括號。 sub2ind
至少需要3個參數:
graydata = gray(sub2ind(size(gray)),(y(:)),(x(:)));
move this ^ ^ after this...
graydata = gray(sub2ind(size(gray),(y(:)),(x(:))));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.