我正在Matlab中完成我们的项目(使用梯度局部三元模式的面部表情识别)。在这个项目中,我们有一张图像,应用Sobel算子在该图像上找到一个正的负梯度,然后将这些梯度组合起来。之后,我们可以在中心应用具有某个值(例如t = 80)的阈值,然后找到使用梯度局部三元模式的正负代码。通过应用代码找到正负图像后,我们可以使用mat2cell
将这些图像划分为块,以创建正负图像这些块的直方图。
% this an ltp lower(pattern for local terernary pattern for ngptl
imshow(ltp_lower),title('Pgptl')
subplot(3,3,6);
imshow(ltp_upper),title('Ngptl')
figure('Name','Ngptl');
ltp_lower1 = zeros(81,64);%zero padding to increase column
ltp_lower1(1:81,1:61)= ltp_lower;
% create a blocks for ltp_lower1 using mat2cell
[rows columns numberOfColorBands] = size(ltp_lower1)
blockSizeR = 9; %define the block size of row
blockSizeC = 8;% define the block size of column
wholeBlockRows = rows / blockSizeR; % the number of total block sin a image of an row
blockVectorR = [blockSizeR * ones(1, wholeBlockRows)];
wholeBlockCols = columns / blockSizeC;% the number of total block sin a image of an column
blockVectorC = [blockSizeC * ones(1, wholeBlockCols)];
ca = mat2cell(ltp_lower1, blockVectorR, blockVectorC);
plotIndex = 1;
numPlotsR = size(ca, 1);
numPlotsC = size(ca, 2);
% show the blocks of an ltp_lower1
for r = 1 : numPlotsR
for c = 1 : numPlotsC
fprintf('plotindex = %d, c=%d, r=%d\n', plotIndex, c, r);
subplot(numPlotsR, numPlotsC, plotIndex);
rgbBlock = ca{r,c};
imshow(rgbBlock);
size(rgbBlock);
plotIndex = plotIndex + 1;
end
end
这是我的代码,我在创建所有单元格的直方图时遇到问题,但是在我的代码中,我们按regBlock显示块,但是regBlock仅具有最后一个单元格值。在这里,我的问题是直方图给出了什么输入?