File Exchange

image thumbnail

FPGA implementation of RGB to Gray Color conversion using HDL coder.

version 1.0.0.0 (37.5 KB) by SUMEET
In this submission RGB_GRAY color converison has been implemented using HDL coder.

3 Downloads

Updated 10 Mar 2014

View License

In this submission RGB_Gray Color converted has been implemented using HDL coder.

Cite As

SUMEET (2020). FPGA implementation of RGB to Gray Color conversion using HDL coder. (https://www.mathworks.com/matlabcentral/fileexchange/45798-fpga-implementation-of-rgb-to-gray-color-conversion-using-hdl-coder), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Shiyu Hatsuse

Thank you for your sample code.
I try using this one by the HDL coder.
I realized that maybe your code is unsynchronized between y_out/x_out with gray.

So I fixed your code like below.

function [x_out, y_out,gray] = rgb_gray(x_in, y_in, r_in, g_in, b_in)
%#codegen

persistent RGB_Reg RGB
persistent x1 x2 y1 y2

if isempty(RGB_Reg)
RGB_Reg = zeros(3,1);
RGB = zeros(3,1);
x1=0;
x2=0;
y1=0;
y2=0;

end
D = [.299 .587 .144];
gray = D*RGB_Reg;
RGB_Reg = RGB;
RGB = [r_in; g_in; b_in];
x_out = x2;
x2 = x1;
x1 = x_in;
y_out = y2;
y2 = y1;
y1 = y_in;

Julian Wei

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux