主要内容

本页翻译不是最新的。点击此处可查看最新英文版本。

使用半精度数据类型的图像量化

此示例说明量化对图像的影响。ex_imagequantization 模型计算棋盘图像的二维傅里叶变换。最左列显示原始图像,结果以定点、半精度和单精度数据类型显示。您可以在生成的图像中看到,虽然定点数据类型并不始终产生可接受的结果,但使用与定点数据类型相同位数的半精度数据类型产生的结果与单精度结果相当。

model = 'ex_image_quantization.slx';
open_system(model);
sim(model)

Figure contains 12 axes objects. Hidden axes object 1 with title fixdt(1,16,4) contains an object of type image. Hidden axes object 2 with title half precision contains an object of type image. Hidden axes object 3 with title single precision contains an object of type image. Hidden axes object 4 with title original chessboard image range [0, 1024] contains an object of type image. Hidden axes object 5 with title fixdt(1,16,4) contains an object of type image. Hidden axes object 6 with title half precision contains an object of type image. Hidden axes object 7 with title single precision contains an object of type image. Hidden axes object 8 with title original chessboard image range [0, 1] contains an object of type image. Hidden axes object 9 with title fixdt(1,16,4) contains an object of type image. Hidden axes object 10 with title half precision contains an object of type image. Hidden axes object 11 with title single precision contains an object of type image. Hidden axes object 12 with title original chessboard image range [0, 1/1024] contains an object of type image.