Displaying image in Simulink using pixel stream

조회 수: 5 (최근 30일)
Naz
Naz 2015년 12월 7일
편집: Naz 2015년 12월 9일
I am trying to display stream of pixels in Simulink. To start with, I create a 2D array, where the first column contains integers 0 1 2 ... and the other column contains pixel data. I use this approach to mimic the stream of pixels as would be supplied by an image sensor:
data = zeros(576*1024*300,2);
n=1;
for frame = 1:300
for row = 1:576
for col = 1:1024
data(n,2) = GRAY(row,col,frame);
data(n,1) = n-1;
n = n+1;
end
end
end
The buffer collects enough pixel data for a single frame which is then converted back to a 2D matrix and displayed. The simulation refreshes frames very slow - probably every two seconds, i.e. 0.5fps. It seems like the D1 rate is very slow and the pixel data takes a long time to fill the buffer. Thus, currently, to view 300 frames takes about 10 minutes. But the data is ready prior to simulation - why does it take this so long?
I tried to change the 'time' values in the first column to smaller values, but this does not help. There are, probably, some simulation settings that should be adjusted. Any ideas, suggestions? The simulation does not involve any complicated functions, so the refresh rate is definitely not limited by the computer resources.

채택된 답변

Bharath Venkataraman
Bharath Venkataraman 2015년 12월 8일
Using the video viewer block instead of the matrix viewer will enable you to display the image. You likely need to set a sample time for the From Workspace block.
  댓글 수: 1
Naz
Naz 2015년 12월 9일
편집: Naz 2015년 12월 9일
Replacing the Matrix Viewer with the Video Viewer did not make any difference. However, setting "Samples per frame" field to '200' in the "From Workspace" discrete block helped speeding up the process.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by