我有一些圖片A 和大小MaxH*MaxW
(如例如800 * 600) 畫面尺寸越小, 我想添加黑色邊框,在代碼中的圖片大小會後800 * 600黑色邊框的圖像添加在MATLAB
我想類似的東西:
function [ output_args ] = t(A)
im=imread(A);
global MaxH;
global MaxW;
global Max;
[rowsA colsA numberOfColorChannelsA] = size(im);
% Get size of existing image B.
% See if lateral sizes match.
if MaxH ~= rowsA || MaxW ~= colsB
% Size of B does not match A, so resize B to match A's size.
% imresize(A, [MaxH MaxW Max]);
d=padarray(A,[(MaxW-size(im,1))/2 (MaxH-size(im,2))/2]);
imwrite(d,A);
end
end
**edit**
function [ output_args ] = Resize(A)
%TT Summary of this function goes here
% Detailed explanation goes here
im=imread(A);
global MaxH;
global MaxW;
global Max;
[H W N] = size(im);
y=floor((MaxH-H)/2);
x=floor((MaxW-W)/2);
d=padarray(im,[y x]);
d= imresize(d,[MaxH MaxW]);
imwrite(d,A);
end
TNX所有
是否要調整大小或添加黑色邊框?兩件不同的事情。 – Divakar 2014-09-02 13:25:45
你試圖用這個函數't'實現什麼功能? – Divakar 2014-09-02 14:13:29
@Divakar我想添加黑色邊框 – 2014-09-02 14:20:48