Error by using function imclose() and implementation of MATLAB code into Simulink model
显示 更早的评论
I would like to detect objects on a picture by segmenting, analyzing regions and some other preprocessing. The code is already working in MATLAB and now I am trying to realise this functionality with Simulink. After loading the data (uint8) the RGB image gets converted to gray (uint8) and then to BW (logical) through a threshold. The next step is closing the image with the function imclose. At this point the following error appears:
Expected input number 1, BWP, to be one of these types: uint32. Instead its type was double.
Function 'MATLAB Function2' (#60.208.226), line 8, column 13:
"imclose(bwImg, se)"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
According to the Documentation the input array (bwImg) "can be any numeric or logical class and any dimension, and must be nonsparse. If IM is logical, then SE must be flat." bwImg does not have the data type uint32, but is logical. Like I said, the code is working in MATLAB.
Below you can see the code that is located in the MATLAB Function Block.
function closedImg = thresCloseImg(grayImg, threshold)
%%Thresholding Image
bwImg = grayImg > threshold;
%%Close with disc
radius = 5;
decomposition = 8;
se = strel('disk', radius, decomposition);
closedImg = imclose(bwImg, se);
end
Thank you in advance for your Answer!
P.s.: I did not find Simulink blocks from the Image Processing Toolbox which represent apps like the Image Segmenter or the Image Region Analyzer in the MATLAB environment. Because of that I would like to use the generated code in MATLAB Function Blocks. Are there any tips or even better ways to do image processing with Simulink?
3 个评论
Ryan Livingston
2018-3-18
Is the error prefixed by a statement like "Simulink was unable to determine ..." something about the sizes of signals? If so, then please keep reading. If you specify the size and data type of closedImg on the MATLAB Function Block ports and data manager (see edit data entry here) then does the error go away?
Elias
2018-3-19
Ryan Livingston
2018-3-19
Great! I'll move this to an answer. You can click the View Report button to open the MATLAB Function Report that shows data types and sizes in the MATLAB code.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Computer Vision with Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!