Вам придется поиграть с точной реализацией Feval, но если вы будете внедрять ее непосредственно в Matlab, есть два варианта.
1. Просто игнорируйте альфа-канал
%this says show all rows, all cols, for channels 1 through 3 or R,G,B
imshow(rgba_im(:,:,1:3));
2. Используйте альфа-канал.
%this says show all rows, all cols, for channels 1 through 3 or R,G,B
%also saves the handle to the newly drawn image
hndl = imshow(rgba_im(:,:,1:3));
%isolates alpha channel
alpha = rgba_im(:,:,4);
%displays alpha channel
set(hndl , 'AlphaData', alpha);
ИЗМЕНИТЬ
Теперь, когда я знаю, что ваши данные не в стандартном формате rgba, вот код, чтобы исправить это, комментарии должны сказать вам все, что вам нужно
[num_rows,num_cols_x4]=size(rgba_matrix);
%we have to transpose the array to get it to unfold properly, which is
%first by columns, then rows
at = rgba_matrix.';
%converts data from [r1 g1 b1 a1 r2 g2 b2 a2 r3 g3 b3 a3....] to
% red_chan = [r1 r2 r3...]
% green_chan = [g1 g2 g3...]
% blue_chan = [b1 b2 b3...]
% alpha_chan = [a1 a2 a3...]
% it says start at some index and grab every 4th element till the end of the
% matrix
red_chan = at(1:4:end);
grn_chan = at(2:4:end);
blu_chan = at(3:4:end);
alp_chan = at(4:4:end);
% reshape each channel from one long vector into a num_rows x (num_cols_x4/4)
red_chan = reshape(red_chan, num_cols_x4/4, num_rows).';
grn_chan = reshape(grn_chan, num_cols_x4/4, num_rows).';
blu_chan = reshape(blu_chan, num_cols_x4/4, num_rows).';
alp_chan = reshape(alp_chan, num_cols_x4/4, num_rows).';
% we concatenate the channels into a num_rows x (num_cols_x4/4) x 4 matrix
standard_rgba = cat(3,red_chan,grn_chan,blu_chan,alp_chan);
С этого момента вы можете выполнять обработку, которую я предложил, используя массив standard_rgba
. Может быть более эффективный способ написать этот код, но я хотел сделать его максимально понятным и простым для понимания, надеюсь, это поможет.
person
andrew
schedule
16.06.2015