[HELP] Extract double array from cell

6 ビュー (過去 30 日間)
Seprienna
Seprienna 2014 年 9 月 3 日
コメント済み: Seprienna 2014 年 9 月 3 日
I have an image which has been divided into 49 blocks. from the block I would like to get the feature vector of LBP from each cell. what can i do?
any advise is greatly appreciated.
proceed = 1;
data_matrix = [];
ids = [];
conut = 0;
l=0;
for i=1:100
for j=1:10
s = sprintf('database/s%i/%i.jpg',i,j);
X = double(imread(s));
[rows columns] = size(X);
blockSizeR = 45; % Rows in block.
blockSizeC = 34; % Columns in block.
% Figure out the size of each block in rows.
% Most will be blockSizeR but there may be a remainder amount of less than that.
wholeBlockRows = floor(rows / blockSizeR);
blockVectorR = [blockSizeR * ones(1, wholeBlockRows), rem(rows, blockSizeR)];
% Figure out the size of each block in columns.
wholeBlockCols = floor(columns / blockSizeC);
blockVectorC = [blockSizeC * ones(1, wholeBlockCols), rem(columns, blockSizeC)];
% Dividing the image into 49 Blocks
ca = mat2cell(X, blockVectorR, blockVectorC);
eval(['out_' num2str(l) '=ca' ]);
l=l+1;
MAPPING=getmapping(8,'riu2');
feature_vector = lbp(ca,1,8,MAPPING,'hist');
feat_vect=feature_vector';
data_matrix = [data_matrix,feat_vect];
end
end
  2 件のコメント
Guillaume
Guillaume 2014 年 9 月 3 日
What is the problem with the code you've written? Doesn't it do what you're asking?
Seprienna
Seprienna 2014 年 9 月 3 日
編集済み: Seprienna 2014 年 9 月 3 日
it suppose to work, but I couldn't get the new input image to be working. any advise. i'm getting this error'Conversion to double from cell is not possible.

サインインしてコメントする。

採用された回答

Guillaume
Guillaume 2014 年 9 月 3 日
I'm assuming that the lbp code you're referring to is from http://www.cse.oulu.fi/CMV/Downloads/LBPMatlab, which would indeed give you the error you mention if you pass it the cell array ca since it is expecting an image.
Possibly, what you want to do is:
feature_vectors = cellfun(@(cell) lbp(cell, 1, 8, MAPPING, 'hist'), ca, 'UniformOutput', false);
which will send each cell in turn to lbp and collate all the returned values in a cell array.
If you want to then stuff these return values in your data_matrix you'll have to change its declaration to:
data_matrix = {}; %cell array instead of matrix
and concatenate it with
data_matrix = [data_matrix {feature_vectors}];
or you could just do
data_matrix{l} = feature_vectors;
  1 件のコメント
Seprienna
Seprienna 2014 年 9 月 3 日
thank you very much..very helpful information. and yes that the standard lbp code i'm using.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePoint Cloud Processing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by