Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

Color Filter Question

Hi all, I'm trying to implement a color filter of Red with a RAW2RGB. I try running this code along side the beyer pattern converter:

always@(posedge iCLK or negedge iRST_n)

begin

if(rRed>250)

begin

bRed <= rRed;

bGreen <= rGreen;

bBlue <= rBlue;

end

else if (rRed<255)

begin

bRed <= 0;

bRed <= 0;

bRed <= 0;

end

end

and it gives me an error

Error (10200): Verilog HDL Conditional Statement error at RAW2RGB.v(62): cannot match operand(s) in the condition to the corresponding edges in the enclosing event control of the always construct

Can anyone help?

Thanks!

9 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    nevermind i got it to compile by removing negedge. But the filter doesn't work! the information sent through the camera is 12 bits, so i try setting the color filter higher

    eg. if( rRed > 1500), but all i get are weird strands on my output screen? Can someone help? thanks!
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I also doing the same project? Did you successfully compile the code?..

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I am very new to verilog. I am still learning on it in order to write the color filter code. I found a module which can translate to binary image. Can I modify the threshold of the code in order to filter out only the red color?

    module Binary (

    input iCLK,

    input iRST_N,

    input [9:0] iTHRESHOLD,

    input iDVAL,

    input [9:0] iDATA,

    output reg oDVAL,

    output reg [9:0] oDATA

    );

    always@(posedge iCLK, negedge iRST_N) begin

    if (!iRST_N) begin

    oDVAL <= 1'b0;

    oDATA <= 10'h0;

    end

    else begin

    oDVAL <= iDVAL;

    if (iDVAL)

    oDATA <= (iDATA > iTHRESHOLD) ? 1023 : 0;

    else

    oDATA <= 10'b0;

    end

    end

    endmodule
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    This the module where it will interface between the SDRAM controller. Do i need to modify the bit length of iDATA in binary module in order to get in RGB? What threshold parameter must I change to?

    // RGB

    wire [9:0] wVGA_R = Read_DATA2[9:0];

    wire [9:0] wVGA_G = {Read_DATA1[14:10],Read_DATA2[14:10]};

    wire [9:0] wVGA_B = Read_DATA1[9:0];

    // binary

    parameter THRESHOLD = 10'b0011111000;

    wire wDVAL_binary;

    wire [9:0] wBinary;

    Binary binary0 (

    .iCLK(ltm_nclk),

    .iRST_N(DLY_RST_2),

    .iTHRESHOLD(THRESHOLD),

    .iDVAL(Read),

    .iDATA(wVGA_G),

    .oDVAL(wDVAL_binary),

    .oDATA(wBinary)

    );
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi.. i using your code above. I successfully filter out red color.. but if i want to filter out green and blue instead. What threshold should i change?

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    HI..

    i try changing the threshold to some value, and that is my code-->

    iTHRESHOLD_0=248

    iTHRESHOLD_1=255

    However, i get the screen all red, where did i goes wrong?

    module Binary (

    input iCLK,

    input iRST_N,

    input [9:0] iTHRESHOLD_0,

    input [9:0] iTHRESHOLD_1,

    input iDVAL,

    input [29:0] iDATA,

    output reg oDVAL,

    output reg [29:0] oDATA

    );

    always@(posedge iCLK, negedge iRST_N) begin

    if (!iRST_N) begin

    oDVAL <= 1'b0;

    oDATA <= 29'h0;

    end

    else begin

    oDVAL <= iDVAL;

    if(iDATA[19:10]>iTHRESHOLD_0)

    begin

    oDATA[19:10]<= iDATA[19:10];

    end

    else if (iDATA[29:20]>iTHRESHOLD_0)

    begin

    oDATA[29:20] <= iDATA[29:20];

    end

    else if (iDATA[19:10]<iTHRESHOLD_1)

    begin

    oDATA[19:10] <= 10'h0;

    end

    else if (iDATA[29:20]<iTHRESHOLD_1)

    begin

    oDATA[29:20] <= 10'h0;

    end

    // else

    // oDATA[9:0] <= iDATA[9:0];

    //

    end

    end

    endmodule
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi, i get my color filter correct as i obtain clear RED color object after filtering. However, when i proceed with my object recognition under different lightning condition and environment, i can see the color filter using this thresholding method is not effective as the threshold may not apply in every condition. Do anyone has any ideas for filtering the object more clearly?