image block indices

1 回表示 (過去 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 Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by