Is there any function that can find the black image in a group of images? Images are grey scale (8 bit)
You can use the
getStatistics(area, mean, min, max, std, histogram) macro function (https://imagej.nih.gov/ij/developer/macro/functions.html#getStatistics) and test if the
mean parameter is 0, or less than some value, if the images are not completely black.
I used this command but for an image which is not black, it returns zero mean. The image is 32 bit and it is masked. I added an image as an example which returns zero.
I think there’s a few ways you can do it with getStatistics() with some conditional formatting. This might not work all the time, but might give you something to test.
- min == max
- mean == 0 & std == 0
- max == mean == 0
Just a few ideas to get you going. hopefully that’s helpful.
@Wilson_Adams I tried that and the problem is I get zero for non-black image.
Hi, the image you show has A LOT more black pixels than white, so the mean would still be 0. Try other parameters as Wilson suggested, perhaps max > 0, but for that condition the “black” image should really be all 0 pixel values.
they should be shown in the histogram. I’m confused why they arent. Those white pixels should pop up as 255, shouldnt they?
That’s weird, min and max are both 0, but mode is not zero. In 32 but image the pixel values are not integer, but they are floating point values. Can you describe the steps you do to generate the images? It looks like you do a threshold and generate a mask. The problem with mask images is that they use a lookup table for display, so the pixel values might be different from what you see.
if this a 32 bit image, your bins might be too wide to separate 1 and 0.
@Wilson_Adams I increased the bin numbers, again the same.
That seems right. Can you instead use 8 bit images as the output of segmentation?
@AlesK Do you mean changing 32 bit to 8 bit?
when your bin width is 1700, and the differences in your signal and background is <1700, those pixels are going to be jammed into one histogram bin.
You can try it, but if you get all zero pixels, then try to change one of the previous steps, so that you don’t get the 32 bit image
yeah if you can avoid the 32-bit image, you might be able to get around this problem.
If the problem is masking and lookup table, why changing from 32 bit to other type would solve the problem? I changed the image that I have (already masked) to 16 bit, did not change.
I think the getStatistics function uses 256 bins, so if your values are 0 and 1, they would end up in the same bin for 32 and 16 bit images.
Update: I realized even with 32 bit image it returns non zero value. look at here:
The problem arises from masking.
I need to have the histogram after masking. Any new suggestion regarding this update?