Clear Filters
Clear Filters

Please correct my code : rgb2gray image conversion using VHDL code

4 views (last 30 days)
Please correct my code : rgb2gray image conversion using VHDL code. I need in help in VHDL coding. This code is not working.
entity colorfilter is Port ( RI : in STD_LOGIC_VECTOR (7 downto 0); GI : in STD_LOGIC_VECTOR (7 downto 0); BI : in STD_LOGIC_VECTOR (7 downto 0); RTarget : in STD_LOGIC_VECTOR (7 downto 0); GTarget : in STD_LOGIC_VECTOR (7 downto 0); BTarget : in STD_LOGIC_VECTOR (7 downto 0); O : out STD_LOGIC); end colorfilter;
architecture Behavioral of colorfilter is
signal sqrtsum : std_logic_vector(17 downto 0);
signal threshold : std_logic_vector(17 downto 0) : ="000000001100000000"
begin
process(RI, BI, GI)
varible Rdiff, Gdiff, Bdiff : std_logic_vector(17 downto 0);
variable sum : std_logic_vector(17 downto 0);
variable R2, G2, B2 : std_logic_vector(15 downto 0);
begin
if (RI > RTarget) then
Rdiff := RI-Rtarget;
else
Rdiff := Rtarget-RI;
end if;
if (GI > GTarget) then
Gdiff := GI - GTarget;
colorfilter.vhd
else
end if;
if (BI > BTarget) then
Bdiff := BI - BTarget;
else
Bdiff := BTarget - BI;
end if;
R2 := Rdiff*Rdiff;
G2 := Gdiff*Gdiff;
B2 := Bdiff*Bdiff;
sqrtsum <= ("00"&R2) + ("00"&G2) + ("00"&B2);
if (sqrtsum > threshold) then
O <= '0';
else
O <= '1';
end if;
end process;
end Behavioral;

Answers (0)

Categories

Find more on FPGA, ASIC, and SoC Development in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!