I have the following image
, with a "large" object and 3 visible bright pixels:
What I do not understand:
Why do I count in the this image
more pixels with brightness $\ge0$ (= 191688) than pixels are available (326$\cdot$294 = 95844). Also is not clear to me why so many pixels have brightness = 1.
image = ColorConvert[image, "Grayscale"]
dim = ImageDimensions[image]
{326, 294}
dim[[1]]*dim[[2]]
95844
Count[Flatten[ImageData[image]], a_ /; a >= 0]
191688
Count[Flatten[ImageData[image]], a_ /; a == 1]
95843
Accordingly, the histogram of the image
is surprising:
Histogram[Flatten@ImageData@image, {0, 1.01, 0.01}, ScalingFunctions -> "Log"]
As next I wanted to measure the mean brightness center of the large object.
Here I do not understand why the resultingImage
includes the bright pixels visible in the original image
and also has pixels with brightness $\ge0$, although the binarized image binImage
containes only pixels with brightness of = 0 and = 1.
What am I doing wrong?
binImage = Binarize[image, 0.4]
Histogram[Flatten@ImageData@binImage, {0, 1.01, 0.01}, ScalingFunctions -> "Log"]
resultingImage = ImageMultiply[image, binImage]
Histogram[Flatten@ImageData@resultingImage, {0, 1.01, 0.01}, ScalingFunctions -> "Log"]
The following code measured the center of the large object and the three bright pixels:
meanValue = ComponentMeasurements[resultingImage, "Centroid"]
{1 -> {170.5, 231.5}, 2 -> {125.372, 172.731}, 3 -> {94.5, 70.5}, 4 -> {175.5, 70.5}}
Length@Flatten[ImageData[image]]
is twice the value ofdim[[1]]*dim[[2]]
$\endgroup$image
brightness=1? $\endgroup$