image block indices
2 次查看(过去 30 天)
显示 更早的评论
hi all,
i've this following code
function [rc, gc, bc, out, fileList] = histogram(f)
%------ ini adalah program untuk mentimpan histogram----------
%bersihin dulu variabelnya
% clear all;
%set path tempat siimpan database citra, terus baca semua citra di database
f = 'D:/pengenalan pola/tugas image retrieve/image';
fileList = dir(fullfile(f,'*.jpg'));
%Read in RGB image file.
%baca citra dan bagi citra menjadi 4 blok berukuran sama
%cari nilai pixel masing-masing komponen warna (RGB)
%simpan dalam variabel
for i = 1:length(fileList)
I{i} = imread((fullfile(f,fileList(i).name)));
out{i} = mat2cell(I{i}, ones(120/60,1)*60, ones(120/60,1)*60, 3);
[ra{i} rb{i} rc{i}] = cellfun(@(x) unique(x(:,:,1)), out{i} , 'un', 0);
[ga{i} gb{i} gc{i}] = cellfun(@(x) unique(x(:,:,2)), out{i} , 'un', 0);
[ba{i} bb{i} bc{i}] = cellfun(@(x) unique(x(:,:,3)), out{i} , 'un', 0);
for j = 1:4
rr{i}{j} = rc{i}{j}(ra{i}{j});
end
end
after i run, it shows error:
??? Subscript indices must either be real positive integers or logicals.
Error in ==> histogram at 21 rr{i}{j} = rc{i}{j}(ra{i}{j});
how can i fix it??
0 个评论
回答(1 个)
David Young
2011-11-14
It doesn't make sense to use ra{i}{j} as an index into rc{i}{j}. You can avoid the error message by swapping their roles,
rr{i}{j} = ra{i}{j}(rc{i}{j});
but since this just reconstructs unique(out{i}{j}(:,:,1)) I'm not sure that it helps. Can you explain what the code is intended to do and how it is meant to work?
2 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!