Array indices must be positive integers or logical values (image processing)

x = imread('cameraman.jpg');
[M,N]=size(x)
for i=1:M
for j=1:N
I=x(i,j);
x(i,j)=xL(I)+( L(I)*lambda(i,j) );
end
end
where
xL is 1x256 dimension, xL is 1x256 dimension, and lambda is 256x256 dimension which is same with x that has 256x256 dimension.
I get this error:
Array indices must be positive integers or logical values.
Error in edge_enhancing (line 134)
x(i,j)=xL(I)+( L(I)*lambda(i,j) );
Ple

 採用された回答

KSSV
KSSV 2019 年 3 月 22 日
I=x(i,j); % here I will be pixel value of image, it cannot be a index
x(i,j)=xL(I)+( L(I)*lambda(i,j) );
Note that in MATLAB indices should be positive integers or logicals.
A = rand(10) ;
A(1) % no error
A(10) % no error
A(5,4) % no error
A(-1) % error
A(0) % error
A(23.5) % error

3 件のコメント

Yohanes Setiawan
Yohanes Setiawan 2019 年 3 月 22 日
Alright. Thanks for your answer.
All I want is:
Suppose I = x(1,2) = 250 (intensity of the pixel).
I want to compute x(1,2)=xL(250) + ( L(250)*lambda(1,2) );
So how can I compute the x(i,j) if the pixel value can't be an index :(
KSSV
KSSV 2019 年 3 月 22 日
編集済み: KSSV 2019 年 3 月 22 日
Try using double/logical. If the vlaue is 250, it should work. Read about double. But I am surprised..why you want to index with a pixel value.
Yohanes Setiawan
Yohanes Setiawan 2019 年 3 月 22 日
using double will output the same thing. I want to index with a pixel value because I want to multiply lambda with the L in k-intensity.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by