As you are not specific here is an answer (in c). You have to iterate through all the input pixels and check if the color matches the one you are looking for:
No, you are not, as it seems from your original question that you are working with HEX number. So, first convert 30 HEX in decimal system and then build the targetColor vector (FYI, #303030 HEX is [48 48 48]).