i have problem with : Attempted to access C(0); index must be a positive integer or logical. Error in HistogramEkualisasi (line 24)
1 回表示 (過去 30 日間)
古いコメントを表示
"Error in HistogramEkualisasi (line 24)
hasil(baris, kolom) = C(Img(baris, kolom));"
Img = imread('D:\Pengolahan Citra Digital\Program MATLAB\car.jpg');
ukuran = size(Img);
jum_baris = ukuran(1);
jum_kolom = ukuran(2);
L = 256;
histog = zeros (L, 1);
for baris=1 : jum_baris
for kolom=1 : jum_kolom
histog(Img(baris, kolom)+1) = ...
histog(Img(baris, kolom)+1) +1;
end
end
alpha = (L-1) / (jum_baris * jum_kolom);
C(1) = alpha * histog(1);
for i=1 : L-1
C(i+1) = C(i) + round(alpha * histog(i+1));
end
for baris=1 : jum_baris
for kolom=1 : jum_kolom
hasil(baris, kolom) = C(Img(baris, kolom));
end
end
hasil = uint8(hasil);
imshow(hasil);
0 件のコメント
回答 (1 件)
Walter Roberson
2016 年 3 月 23 日
Some of your counts will be 0, so Img(baris, kolom) will sometimes be 0. You are trying to index C(Img(baris, kolom)) so you are trying to index C(0) which is not permitted.
For consistency with your earlier code you should be referring to C(Img(baris,kolom)+1)
2 件のコメント
Walter Roberson
2016 年 3 月 23 日
With the test image that I used, I do not get an all-black result.
Note that you read in a .jpg image. .jpg images are almost always RGB images, but you ignore everything except what corresponds to the red color plane. If the red color plane is empty you would not get anything useful out.
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!