Question

Could you please help me with this question:

Assume that on average in binary images, 75% of the pixels are white, and 25% are black. What is the entropy of this source? Model this source in Matlab and generate some sample images according to this process

Was it helpful?

Solution

To find the entropy, you just need to apply the definition:

H = -0.25 * log2(0.25) - 0.75 * log2(0.75)

Since we are using log2, the result will be in bits.

As for generating a Matlab B&W (i.e. binary) image of size 512x512, you can simply do:

im = rand(512) < 0.75;

By convention, true = 1 = white and false = 0 = black.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top