1
$\begingroup$

I would like to compute the product of two images. I tried with the code below. But the result is not like I expected. Can you tell me where is the problem in my code?

https://ibb.co/Njc8w3b

for (int i = 0; i < ImageWidth; i++)
{
    for (int j = 0; j < ImageHeight; j++)
    {
        PixelValueFirstImage = Giris1.GetPixel(i, j); 
        PixelValueSecondImage = Giris2.GetPixel(i, j);
        Greyscale1 = Convert.ToInt16(PixelValueFirstImage.R * 0.3 + PixelValueFirstImage.G * 0.58 + PixelValueFirstImage.B * 0.12); //Converting RGB to grayscale
        Greyscale1 = Convert.ToDouble((Greyscale1 - 0) / (255 - 0)); // scaling between 0-1
        Greyscale = Convert.ToInt16(PixelValueSecondImage.R * 0.3 + PixelValueSecondImage.G * 0.58 + PixelValueSecondImageB * 0.12); //Converting RGB to grayscale
        Greyscale = Convert.ToDouble((Greyscale - 0) / (255 - 0)); // scaling between 0-1
        product = Greyscale * Greyscale1; // result of product
        product =(255*product)  ; //scaling between 0-255
        OutputImage.SetPixel(i, j, Color.FromArgb((int)product, (int)cproduct, (int)product);
    }
}

```
$\endgroup$
  • 1
    $\begingroup$ What was your result, what did you expect and how are these two things different? $\endgroup$ – Hilmar Aug 5 at 12:56
1
$\begingroup$

Multiplication of two signals is formally called as modulation; one of them is modulating the other.

In image processing most typically this will be called masking, when one of the images is a special selective mask for pixels.

However, when neither of the images is a mask, then their multiplication will blend (mix) them into each other according to their bright and dark regions...

$\endgroup$
  • $\begingroup$ I think that masking can be a bit more complicated, because it can involve normalization (typically $[0,1]$) or saturation. $\endgroup$ – Laurent Duval Aug 5 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.