Posts by Hakan

    Dear Jayasuriya,


    Since your function is : R*0.299 + G*0.587 + B*0.114 you can also write it as : ( R*299 + G*587 + B114)/1000

    In your design you used DIV operation 3 times. You can use DIV operation just one time and get the same result. Also in your design using DIV operator 3 times decrease the precision. For example your first pixel value is R:21 G:27 B:45 acording to your design output od DIV operators are: 21*299/1000 = 6 and 27*587/1000=15 and 45*114/1000=5 and your final gray value will be 15+5+6 = 26. However your exact value must be 27.258 you will have 26. If you use DIV operator just one time then you will have : (21*299 + 27*587 + 45*114) / 1000 = 27. In this case you will increase the precision and also decrease the number of operators. Attachment you can have a look the example design. This is my suggestion to you. I dont know if there is another better solution.Hope that helps to you:)


    Have a nice day

    Files

    • rgb2gray.va

      (6.63 kB, downloaded 3 times, last: )