This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/TDA2P-ACD: Chroma Keying Values For Transparent Image Background

Part Number: TDA2P-ACD

Tool/software: TI-RTOS

Hello All,

Further to referring to one of the TI forum's post,

I need some more information. I am trying to remove the white background of my image which I want to overlay on display.

It is mentioned in the above post that one needs to replace the while pixel values (0xFF) in the header file generated by bin2C tool with chroma keying value. Can someone please elaborate more on these and suggest what exactly needs to be replaced with 0xFF. How do I get these chroma keying values.

Thanks & Regards,

Abhay

  • Hi Abhay,

    You could remove colors two ways,

    1, you could make it transparent by changing alpha value of this specific portion to 0
    2, you could also make it transparent by enabling transparency key. You could set the color as white and enable transparency.

    Rgds,
    Brijesh
  • Hi Brijesh,

    Thanks for reply.

    1, you could make it transparent by changing alpha value of this specific portion to 0
    ==> I have set the image format to RGB565 which does not have any alpha component

    2, you could also make it transparent by enabling transparency key. You could set the color as white and enable transparency.
    ==> I am finding it difficult to get what this transparency key is and how to set it. Can you tell me exactly where to make the changes in vision sdk.

    Thanks,
    Abhay
  • Hi Brijesh,

    I am trying to overlay below image on display

    As you can see it has white background. Then I generated a header file using bin2C tool and replaced all the values of 0xFF with 0x00. With this I was able to removed the white background but not quite though. Below is the image which still has some white boundary around it. So how do I remove that white boundary. Please suggest.

    Thanks,

    Abhay

  • Hi Abhay,

    Refer to the section 'DISPC Transparency Color Keys' in the TRM.
    Replacing 0xff with 0x00 is not correct way..

    Rgds,
    Brijesh
  • Hi Brijesh,

    After going through the TRM section referred by you, I tried to do following in my usecase code,

    1. /* Destination transparency color key mode selection for TV*/
    UInt32 *pDISPC_CONFIG1 = (UInt32 *) (0x58001044);
    UInt32 *pDISPC_TRANS_COLOR1 = (UInt32 *) (0x58001058);

    *pDISPC_CONFIG1 |= (1 << 12); /* Enable transparency color key for TV */
    *pDISPC_CONFIG1 |= (0 << 13); /* Destination transparency color key selected */
    *pDISPC_TRANS_COLOR1 |= (0xFFFF); /* [23:0] set white color as transparency key */

    2. I got following values for the above registers after printing on console,
    DISPC_CONFIG1 = 0x1000
    DISPC_TRANS_COLOR1 = 0xffff

    But still I am getting the white background. Above changes are done for TV and I also tried with LCD1 type, but still I am getting white background. Can you tell me if I am going in the correct direction.

    Thanks,
    Abhay
  • Hi Abhay,

    The transparency actually makes the alpha value of the matching color to 0, so then when two layers are blended, this pixel becomes transparent. So we need to make sure that this layer is blended and the alpha value of this layer is used in blending..
    I guess you are using two layers, one grpx and one video. Can you change the priority of the layer, where you want to make white color transparent, such that this layer is on the top of the other layer?

    Rgds,
    Brijesh
  • Hi Brijesh,

    For changing priority of the layers, do I need to make changes in DISPC_GFX_ATTRIBUTES (0x5800 10A0). If yes, what all changes needs to be done. If no, could you please help me out what needs to be done.

    Thanks,
    Abhay
  • Hi Abhay,

    No, transparency color is enabled in DISPC_CONFIG register, bit 12 and 13. and transparency color can be set in DISPC_TRANS_COLOR registers..
    The color is specified in RGB format..

    Rgds,
    Brijesh
  • Hi Brijesh,

    I have already done the configurations for DISPC_CONFIG & DISPC_TRANS_COLOR as below,
    1. /* Destination transparency color key mode selection for TV*/
    UInt32 *pDISPC_CONFIG1 = (UInt32 *) (0x58001044);
    UInt32 *pDISPC_TRANS_COLOR1 = (UInt32 *) (0x58001058);

    *pDISPC_CONFIG1 |= (1 << 12); /* Enable transparency color key for TV */
    *pDISPC_CONFIG1 |= (0 << 13); /* Destination transparency color key selected */
    *pDISPC_TRANS_COLOR1 |= (0xFFFF); /* [23:0] set white color as transparency key */

    2. I got following values for the above registers after printing on console,
    DISPC_CONFIG1 = 0x1000
    DISPC_TRANS_COLOR1 = 0xffff

    You were telling about changing the priority of the layers. So what needs to be done for that.

    Regards,
    Abhay
  • Abhay,

    oh sorry, yes, you need to enable zorder bit 25 in attribute register and set the zorder in bits 26:27..

    Rgds.
    Brijesh
  • Hi Brijesh,

    I tried again with below configurations but still not able to make white color transparent,

    /* Destination transparency color key mode selection for TV*/
    UInt32 *pDISPC_GFX_ATTRIBUTES = (UInt32 *) (0x580010A0);
    UInt32 *pDISPC_CONFIG1 = (UInt32 *) (0x58001044);
    UInt32 *pDISPC_TRANS_COLOR1 = (UInt32 *) (0x58001058);
    *pDISPC_CONFIG1 |= (1 << 12); /* Enable transparency color key for TV */
    *pDISPC_CONFIG1 |= (0 << 13); /* Destination transparency color key selected */
    *pDISPC_TRANS_COLOR1 |= (0xFFFF); /* [23:0] set white color as transparency key */
    *pDISPC_GFX_ATTRIBUTES |= (1 << 25); /* Z-order enable */
    *pDISPC_GFX_ATTRIBUTES |= (1 << 27) | (1 << 26); /* Layer above all layers */
    *pDISPC_GFX_ATTRIBUTES |= (1 << 8) | (0x6 << 1); /* TV output & RGB565 format selected */
    *pDISPC_GFX_ATTRIBUTES |= (1 << 0); /* graphics enable */

    Do you think these are correct. If yes, do I need to try the same configurations for LCD1, LCD2 & LCD3 as well.

    Regards,
    Abhay
  • Hi Brijesh,

    Do you have any suggestions for me.

    Thanks,
    Abhay
  • Hi Abhay,

    In addition to grpx, what other pipeline you are using? Can you check if you have also enabled blending?
    Why are you setting priority to 0x3?

    Rgds,
    Brijesh
  • Hi Brijesh,

    Here's my usecase,

    **********************************************
    NetworkRx (A15) -> Decode -> VPE -> Sync -> Dup -> Alg_A (DSP1) -> DssM2mWb -> Display_Video
    Dup -> Gate -> Alg_B (DSP1)
    OverlayLink (IPU1_0) -> Display_Grpx
    **********************************************

    So I am using one display and one Grpx pipeline.

    Why are you setting priority to 0x3?
    ==> I have tried with all the other three priorities as well as it is not yet clear to me about what priority I should set.

    Can you check if you have also enabled blending?
    ==> I have not enabled blending. Do I need to enable it.

    Is there any particular sequence in which I need to set these register values.

    Regards,
    Abhay
  • Abhay,

    Since you have display_video also enabled in the path, you need to make sure the video pipeline/layer is below the grpx pipeline/layer and then enable the blending and transparency to get video and grpx blended. Please set the priority in the video pipeline also..
    Problably, you could do all of these experiments from the CCS memory windows and check the output..

    Rgds,
    Brijesh
  • The other way is, you could the change the parameters for the transparency color keying in the function ChainsCommon_SetDctrlConfig in the file vision_sdk\apps\src\rtos\usecases\common\chains_common.c, at around line number 550..

    Rgds,
    Brijesh
  • Hi Brijesh,

    I could not achieve the desired result by even changing the parameters in the function ChainsCommon_SetDctrlConfig() in the file "vision_sdk\apps\src\rtos\usecases\common\chains_common.c". Eventually I had to change the white background of my original image to black in the paint. And then with no changes in the code, I could get to the desired output as by default black color is made transparent in the above said file .

    But still if the image is with white background there is no way to make white color transparent. Also I saw in function ChainsCommon_SetDctrlConfig(), only source transparency key is set and if I change the parameter,

    ovlyPrms->colorKeySel = SYSTEM_DSS_DISPC_TRANS_COLOR_KEY_SRC; //source transparency key
    to
    ovlyPrms->colorKeySel = SYSTEM_DSS_DISPC_TRANS_COLOR_KEY_DEST; //dest transparency key

    no change in the output is observed. Is there any usecase or example code in vision sdk where destination transparency key is set that I can refer to.

    Regards,
    Abhay
  • Abhay,

    Well, i dont have example, but surprisingly, why it is not working?
    Can you share DSS register dump? Let me have a look at it.

    Rgds,
    Brijesh
  • Hi Abhay,

    Any further question on this thread. I am currently closing thread, due to no activity for long time.
    We could reopen it if you have any questions.

    Rgds,
    Brijesh
  • Sure Brijesh.

    I will reopen the thread for any further questions as currently I am using image with black background. So no settings for transparency key are needed in this case.

    Thanks & Regards,
    Abhay