Info

此问题已关闭。 请重新打开它进行编辑或回答。

I got subscript indices must be real positive integers or logicals on my code

1 次查看(过去 30 天)
Im trying to equalized my picture with this loop
for baris = 1 : jum_baris
for kolom = 1 : jum_kolom
Hasil(baris, kolom) = C(img(baris, kolom)); %this line got me that error
end
end
Hasil = uint8(Hasil);
  1 个评论
Tommy
Tommy 2020-4-5
What is C? It is likely that
img(baris, kolom)
is the culprit. If C is a matrix, the above statement should return a real positive integer or logical.

回答(2 个)

drummer
drummer 2020-4-5
What is C?
I suppose your original image to be equalized is img. So is C any function applied in img?
If that's not the case, your just playing with the indexes.
Previously to your code, you can say the height and width of img.
[jum_baris, jum_kolon] = size(img);
That way, jum_baris and jum_kolom will be integers and positives. if you're taking them elsewhere, and they have decimal places, using them as indexes for matrix won't work.
yourNewMatrix(1.3, 1.12) % is not possible.
If they go randomly between positive and negative numbers, they won't work as well
yourMatrix(1,-2) % is not possible as well.
Cheers

Image Analyst
Image Analyst 2020-4-5
This is a FAQ (possibly the most F or the error message questions), so see the FAQ:
It has a pretty thorough discussion.

标签

Community Treasure Hunt

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

Start Hunting!

Translated by