How to get image from a matrix which contains PIXEL values ?

2 visualizaciones (últimos 30 días)
Hi,
I have an image of 400*400. I applied LBP to this and obtained 400*400 matrix which contains LBP value for each pixel. Now I want to convert this LBP matrix to an image. I was expecting some grey scale image, but instead I am getting with yellow color. Expecting something like this.
function LBP_Im = LBP(Input_Im, R)
% %=======================================================================
% %=======================================================================
% This function computes the LBP transformation of the input image
% Input_Im.
% The parameters of the LBP operator are (P = 8, R),
% where P - the number of sampling points in the region with the radius R.
% Radius R is the input parameter of the function.
% Possible values for R = 1, 2, 3, etc.
% If input image is COLOR, then the grayscale transformation is performed.
% %=======================================================================
% %=======================================================================
Input_Im = imread('akaf.jpg');
R= 1
if size(Input_Im, 3) == 3
Input_Im = rgb2gray(Input_Im);
end;
L = 2*R + 1; %%The size of the LBP label
C = round(L/2);
Input_Im = uint8(Input_Im);
row_max = size(Input_Im,1)-L+1;
col_max = size(Input_Im,2)-L+1;
%%for creating array of image dimensions
LBP_Im = zeros(row_max, col_max);
for i = 1:row_max
for j = 1:col_max
A = Input_Im(i:i+L-1, j:j+L-1);
A = A+1-A(C,C);
A(A>0) = 1;
LBP_Im(i,j) = A(C,L) + A(L,L)*2 + A(L,C)*4 + A(L,1)*8 + A(C,1)*16 + A(1,1)*32 + A(1,C)*64 + A(1,L)*128;
end;
end;
t = image(LBP_Im);
%

Respuesta aceptada

Image Analyst
Image Analyst el 25 de Jul. de 2016
It looks like some colormap is being applied for some reason. I know imagesc() does that but I didn't think image() did. Anyway, you should use imshow(), then call colormap() just to make sure it's gray scale.
imshow(LBP_Im, []);
colormap(gray(256));
colorbar;

Más respuestas (1)

Thorsten
Thorsten el 25 de Jul. de 2016
I used
Input_Im = imread('peppers.png');
and it worked fine. What do you get with peppers.png?

Community Treasure Hunt

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

Start Hunting!

Translated by