Help:I hava difficult in Circle LBP Code .

2 Ansichten (letzte 30 Tage)
meng wang
meng wang am 23 Feb. 2020
Bearbeitet: meng wang am 24 Feb. 2020
I'm doing the circular LBP feature,but i have some questions,The result is always white,here's my code,please help me,thanks:
clear;
% 声明默认neighbors为8
I = imread('lena.png');
[rows,cols] = size(I);
neighbors = 8;
radius = 3;
Ibpcode = 0;
CircleLBP = zeros(size(I), 'uint8');
for i = radius+1 : rows-radius
for j = radius+1 : cols-radius
%获得中心像素点的灰度值
centerPixel = I(i, j);
for k = 1 : neighbors
%根据公式计算第k个采样点的坐标
x = i + radius * cos(2.*pi.*k./neighbors);
y = j - radius * sin(2.*pi.*k./neighbors);
%根据取整结果进行双线性插值,得到第k个采样点的灰度值
%1 分别对x,y进行上下取整
x1 = floor(x); %向下取整
x2 = ceil(x); %向上取整
y1 = floor(y); %向下取整
y2 = ceil(y); %向上取整
%2 将坐标映射到0-1之间
tx = x - x1;
ty = y - y1;
%根据0-1之间的x,y的权重计算公式计算权重
w1 = (1 - tx)*(1 - ty);
w2 = tx*(1-ty);
w3 = (1-tx)*ty;
w4 = tx*ty;
%3.根据双线性插值公式计算第k个采样点的灰度值
neighbor = I(x1,y1)*w1 + I(x1,y2)*w2 + I(x2,y1)*w3 + I(x2,y2)*w4;
if(neighbor > centerPixel)
Ibpcode = 2^(neighbors - k -1) + Ibpcode;
end
end
CircleLBP(i,j) = Ibpcode;
end
end
imshow(CircleLBP);
clear;

Antworten (1)

Image Analyst
Image Analyst am 23 Feb. 2020
Try
imshow(CircleLBP, []);
  2 Kommentare
meng wang
meng wang am 24 Feb. 2020
Hello, it is always white when running, and the gray value of each pixel is 255. What's wrong with it? Please help me
meng wang
meng wang am 24 Feb. 2020
Bearbeitet: meng wang am 24 Feb. 2020
I have solved the question.But i don't know why Each of pixel expressed before were 255(error) ? please tell me the reason if you can.Thanks again
(1)error:
if(neighbor > centerPixel)
Ibpcode = 2^(neighbors - k -1) + Ibpcode;
end
end
CircleLBP(i-radius, j-radius) = Ibpcode; (It's copied upper)
(2)right:
if(neighbor > centerPixel)
flag = 1;
else
flag = 0;
end
CircleLBP(i-radius, j-radius) = flag * 2^(neighbors-k-1)+CircleLBP(i-radius, j-radius);
end

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by