Subscript indices must either be real positive integers or logicals

1 回表示 (過去 30 日間)
alireza kooshafar
alireza kooshafar 2016 年 10 月 30 日
コメント済み: alireza kooshafar 2016 年 10 月 30 日
How can i solve 'Subscript indices must either be real positive integers or logicals. ' in this code?

採用された回答

Walter Roberson
Walter Roberson 2016 年 10 月 30 日
You have
b=Tinv*[i ;j ;1];
x2=b(1);
y2=b(2);
if (x2<1)||(x2>M)||(y2<1)||(y2>N)
I2(i , j , Channel)=0;
else
I2(i,j ,Channel)=I1(x2 ,y2 ,Channel);
end
where Tinv is the inverse of a matrix. The inverse of a matrix is seldom exactly an integer, so your x2 and y2 are unlikely to be integers, but you use them as indices in
I2(i,j ,Channel)=I1(x2 ,y2 ,Channel);
Part of the difficulty with transforms is that any one destination typically needs to combine multiple sources because the theoretical source location is not exactly in the center of a pixel.
One of the simplest approaches is to round() the coordinates -- and to boundary-check them. This approach does produce something sort of recognizable, but it can look pretty bad, especially for steeper angles.
One of the compromise approaches is a "sub-pixel" approach. Replicate each pixel in place (for example, create a new image with each pixel replaced by a 3 x 3 block of pixels of the same value). Do the transform on the expanded matrix, possibly using round() on the coordinates, in order to create an expanded transformation of the matrix. And then somehow decide how to combine all of the resulting sub-pixels of each pixel to become a new representative pixel; that might involve taking the brightest of the subpixels, or might involve taking the median, or the mean, or might use a weighted average, or other techniques.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Support Package for USB Webcams についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by