image block indices

2 次查看(过去 30 天)
Rusmaya Luthfina
Rusmaya Luthfina 2011-11-14
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??

回答(1 个)

David Young
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 个评论
Rusmaya Luthfina
Rusmaya Luthfina 2011-11-15
i've already solved my problem,, but thx for ur answer..
i'm running image retrieval histogram color based,, but still haven't got the idea what to do with the histogram
Image Analyst
Image Analyst 2011-11-15
Yes, that's apparent. Why not just use imhist()?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by