I have a Bayer Pattern that I have to demosaic with matlab by writing an own implementation of bilinear interpolation.
What I have read so far is often unprecise. So I would like to ask whether I got that right (my result for my Bayer Pattern goes in the right direction, but it still has some color-flaws so I assume my algo is not correct)
I think I have an error when it am on a field that is a green value.
If I am on green:
red = value of the field over and below my current pixel divided by 2
blue = the pixel to my left and to my right divided by 2
Is that correct?
Are you taking into account that there is actually two different cases for a green pixel? If the pixel is on a red row, the red pixels will be on the left and right of the green pixel. If it is on a blue row, the red pixels will be above and below the green pixel. If your algorithm always assume that the red pixels are above and below, you will mix the blue and red channels of the blue columns.