开发者

MATLAB Embedded Coder: fft2 operation for uint8?

I'd like to generate some code using MATLAB Embedded Coder that runs an fft2 operation on a uint8 datatype. The end application is going to operate on images up to 4096 by 4096, so I'd like to not have to use the double 开发者_运维问答(~134MB of double data vs. ~16MB) input required to get emlc to compile my code right now.

Here's a sample of what I'm running:

%#eml
function bar = emlc_test(foo)
    bar = fft2(foo);
end

with compiler command:

emlc -T rtw emlc_test -c -report -v -eg { zeros(32,32,'uint8') }

This throws error:

??? Function 'fft' is not defined for values of class 'uint8'.

The same code/compilation command works fine when changing 'uint8' to 'double'

But looking at the generated code it seems like processing should be capable of running in uint8 space. Is there a flag I'm missing to allow my fft2 operation to work on uint8 data rather than double data?


The MATLAB fft2 reference documentation is explicit on its requirement of types double or single.

It seems you may have to use a "monster" (*) matrix based on singles even for the input. I think that the reason for this is that there is no way for MATLAB to decide the type desired in the output, other that it being the same as the input.
(**) Actually not that big: single type is only 4 times what you intended.


No, not possible. fft and fft2 only support single and double floats. Not much you can do about it. If you want to save memory space, try single floats.


If you really need the optimisation, I think the only thing you can do is reinvent the wheel: implement your FFT function from scratch (it's a lot of work).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜