Matlab论坛
直播中

Lucky_Doglin

5年用户 6经验值
擅长:可编程逻辑
私信 关注
[问答]

基于System Generator处理图像

有做System Generator处理图像的吗?遇到一些问题,一起商量下

  • 微信截图_20200929194649.png
  • 微信截图_20200929194624.png
  • 微信截图_20200929194614.png

回帖(2)

杨平

2020-9-29 11:32:32
可以详细描述一下什么问题
1 举报
  • Lucky_Doglin: 在用system generator对图像进行高斯平滑时,出现了错误:
    The addra port has data type UFix_10_0.
    The addra port must be a UFix_8_0 signal.

    Error occurred during "Rate and Type Error Checking".


    Reported by:
      'untitled/3LineBuffer/Dual Port RAM'
    Component:System Generator | Category:Block error
    A summary of Sysgen errors has been written to 'E:/heiheihei/SystemGenerator/jiuyuejianmo/Image/tuxiangzengqiang/gaosipinghua/untitled_sysgen_error.log'

    Reported by:
      'untitled/3LineBuffer/Dual Port RAM'
    Component:System Generator | Category:Block error
    The S-function 'sysgen' in 'untitled/Gateway Out' has specified the option SS_OPTION_PORT_SAMPLE_TIMES_ASSIGNED and specified inherited for sample time number 0. Inheriting a sample time is not supported when specifying SS_OPTION_PORT_SAMPLE_TIMES_ASSIGNED
    Component:Simulink | Category:Block error

Lucky_Doglin

2020-9-29 19:50:51
这是我的模型,其中回调函数如下:
LoadImage.m:
%读取原始图像数据
SourceImage2D = rgb2gray(imread('lena1.jpg'));%这里将彩色图像先变为灰度图像
%得到图像的长宽尺寸
ImageWidth = size(SourceImage2D,2);
ImageHeight = size(SourceImage2D,1);
%将二维数组转换为一维数组
SourceImage1D = reshape(SourceImage2D,1,ImageWidth*ImageHeight);
%按照格式形成Simulink的To Workspace模块要求的数据格式
SourceImage1D = [double(0:ImageWidth*ImageHeight-1)' double(SourceImage1D)'];
%设置整个模块的输入到输出延时
DesignLatency = 0;

ShowImage.m:
%将DestImage1D一维数组转换成规定大小的DestImage2D二维数组
DestImage2D = reshape(DestImage1D(DesignLatency+1:DesignLatency+ImageHeight*ImageWidth),ImageWidth,ImageHeight);
%按照格式显示输入/输出图像
h = figure;
clf;
colormap(gray(256));

set(h,'Name',' Bypass Results');
subplot(1,2,1);
image(SourceImage2D),axis equal,axis square,axis off;title('Input Image');
subplot(1,2,2);
image(DestImage2D),axis equal,axis square,axis off;title('Output Image');
colormap(gray(256));


举报

更多回帖

发帖
×
20
完善资料,
赚取积分