MATLAB: Image algo to vhdl conversion

HDL Coderimage to vhdlvhdl

I am unable to convert a simple image code into vhdl using hdl coder. Please help
FUNCTION:
%#codegen
function[a,b]=imate2vhdl(x)
a=imread(x);
b=im2bw(a);
TESTBENCH:
x = 'v.jpg';
[a,b]= imate2vhdl(x);
imshow(b);
is there any problem with the code?

Best Answer

The function you wish to generate HDL for contains two function calls (imread and im2bw), and neither function is supported for HDL code generation. imread reads a file from disk and decodes the binary format; in this case, JPEG. I'm not sure what hardware you expect HDL Coder to build for such a function call; in any case, HDL coder does not support it.
The reason that HDL Coder does not support im2bw is that it operates on a frame buffer. The entire image is processed at once, as an image. As written, HDL Coder has no idea even how large the image is.
In general, hardware processing of images or video needs to be performed in a streaming fashion. I could envision remodeling this design so that:
  • The image size is fixed and defined
  • The image is streamed, one pixel at a time, into the hardware design
  • The incoming data stream is processed, pixel by pixel, performing the transform
  • The transformed data is streamed out of the hardware portion back into an image buffer
This of course is one approach. It is so simple because the filter you wish to use is a simple pixel-level filter. The HDL Coder examples contain more complex examples of image processing code. For more information about generating HDL for image processing, see one or more of these published examples. They are a standard part of the HDL Coder documentation.
  • Sobel Edge Detection
  • 2D FIR Filter
  • Corner Detection
  • Adaptive Median Filter
  • Contrast Adjustment
  • Image Enhancement by Histogram Equalization
  • Image Format Conversion: RGB to YUV
  • High Dynamic Range Imaging
Related Question