From: Samuel Dorrell on
I've made a Simulink model to do image segmentation on a TI DM6437EVM (davinci processor evaluation board). My algorithm uses only the luminance values and since the format of the input image is UYVY (i.e. 4:2:2 YCbCr) I'm doing some processing at either end to convert to and from an array of Y's. When it comes to displaying the output I pass the luminance values to the chrominance channels both for ease and better color seperatation in the output image.

In my Simulink model at the video capture side I'm using a selector to select the even columns only. At the video display side I'm using a selector (to crop my intensity image to a factor of 32 as required by the DM643x video display) and a DM643x video display block with 'Horizontal zoom' set to *2 in order to oversample the intensity image back to something which looks like UYVY. So far this all works ok in simulation and executing on the evm, but I've noticed some suboptimalities in the generated source code and would like to know what I can do to my model to address these. Any suggestions greatly appreciated.

1. The selector on the video display side uses memcpy to copy whole rows at a time making the crop operation quite fast. However, it seems like it might be a bit of a waste to copy all this memory just for the benefit of the video display block downstream. Another way could be to oversample the image by a factor of 2 (and set the video display block 'Horizontal zoom' to *1); is there a fast way to do this?

2. The selector block produces the following code
/* Selector: '<S16>/Selector1' */
for (i = 0; i < 480; i++) {
for (tmp = 0; tmp < 720; tmp++) {
dm64_captureSegmentAndDispaly_B.Selector1[tmp + 720 * i] =
capFrmPtr[((tmp << 1) + 1) + 1440 * i];
}
}
However all that is really needed is the following
for (i = 0, j=0; i < 480*720; i++, j+=2) {
dm64_captureSegmentAndDispaly_B.Selector1[i] = capFrmPtr[j];
}
How can I make this clear in my model?

I hope this is clear, please ask for clarifiation of anything if needed.
Best Regards
Sam

---------------------------------------------------------------------------------
P.S To further illustrate what I'm trying to do both at the input and output side (skipping the processing in the middle) here's an example:
input = [U1 Y1 V2 Y2; U3 Y3 V4 Y4]
lumin = [ Y1 Y2; Y3 Y4]
output = [Y1 Y1 Y2 Y2; Y3 Y3 Y4 Y4]