MATLAB: Please how can i save the extracted feature in bmp format, i tried saving it but is not working

Image Processing Toolboximwrite

here is the code
% Dir = 'C:\Users\Markama\Documents\MATLAB\Ahmad lema\Att faces\orl_faces\test\';
% % Read images from Images folder
% Imgs = dir(fullfile(Dir, '*.bmp'));
% for i=1:length(Imgs)
% im = imread(fullfile(Dir, Imgs(i).name));
im= imread('test.bmp');
rows=size(im,1);
cols=size(im,2);
t=5;
%// Reordering vector - Essentially for getting binary strings
reorder_vector = [8 7 4 1 2 3 6 9];
%// For the upper and lower LTP patterns
ltp_upper = zeros(size(im));
ltp_lower = zeros(size(im));
%// For each pixel in our image, ignoring the borders...
for row = 2 : rows - 1
for col = 2 : cols - 1
cen = im(row,col); %// Get centre
%// Get neighbourhood - cast to double for better precision
pixels = double(im(row-1:row+1,col-1:col+1));
%// Get ranges and determine LTP
out_LTP = zeros(3, 3);
low = cen - t;
high = cen + t;
out_LTP(pixels < low) = -1;
out_LTP(pixels > high) = 1;
out_LTP(pixels >= low & pixels <= high) = 0;
%// Get upper and lower patterns
upper = out_LTP;
upper(upper == -1) = 0;
upper = upper(reorder_vector);
lower = out_LTP;
lower(lower == 1) = 0;
lower(lower == -1) = 1;
lower = lower(reorder_vector);
%// Convert to a binary character string, then use bin2dec
%// to get the decimal representation
upper_bitstring = char(48 + upper);
ltp_upper(row,col) = bin2dec(upper_bitstring);
lower_bitstring = char(48 + lower);
ltp_lower(row,col) = bin2dec(lower_bitstring);
end
end
figure
imshow(ltp_upper);
imwrite (ltp_upper, ltp_lower,'1.bmp');
% end

Best Answer

You can't save two images in one call. Do two separate calls:
imwrite(ltp_upper, '1.bmp');
imwrite(ltp_lower, '2.bmp');
Also, IMPORTANT, don't use "upper" and "lower" for variable names since those are the names of built-in functions.